File tree Expand file tree Collapse file tree 3 files changed +9
-28
lines changed Expand file tree Collapse file tree 3 files changed +9
-28
lines changed Original file line number Diff line number Diff line change @@ -237,27 +237,6 @@ enum ssb_mitigation {
237
237
extern char __indirect_thunk_start [];
238
238
extern char __indirect_thunk_end [];
239
239
240
- /*
241
- * On VMEXIT we must ensure that no RSB predictions learned in the guest
242
- * can be followed in the host, by overwriting the RSB completely. Both
243
- * retpoline and IBRS mitigations for Spectre v2 need this; only on future
244
- * CPUs with IBRS_ALL *might* it be avoided.
245
- */
246
- static inline void vmexit_fill_RSB (void )
247
- {
248
- #ifdef CONFIG_RETPOLINE
249
- unsigned long loops ;
250
-
251
- asm volatile (ANNOTATE_NOSPEC_ALTERNATIVE
252
- ALTERNATIVE ("jmp 910f" ,
253
- __stringify (__FILL_RETURN_BUFFER (%0 , RSB_CLEAR_LOOPS , %1 )),
254
- X86_FEATURE_RETPOLINE )
255
- "910:"
256
- : "=r" (loops ), ASM_CALL_CONSTRAINT
257
- : : "memory" );
258
- #endif
259
- }
260
-
261
240
static __always_inline
262
241
void alternative_msr_write (unsigned int msr , u64 val , unsigned int feature )
263
242
{
Original file line number Diff line number Diff line change @@ -3330,13 +3330,8 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3330
3330
*/
3331
3331
x86_spec_ctrl_set_guest (svm -> spec_ctrl , svm -> virt_spec_ctrl );
3332
3332
3333
- local_irq_enable ();
3334
-
3335
3333
__svm_vcpu_run (svm -> vmcb_pa , (unsigned long * )& svm -> vcpu .arch .regs );
3336
3334
3337
- /* Eliminate branch target predictions from guest mode */
3338
- vmexit_fill_RSB ();
3339
-
3340
3335
#ifdef CONFIG_X86_64
3341
3336
wrmsrl (MSR_GS_BASE , svm -> host .gs_base );
3342
3337
#else
@@ -3366,8 +3361,6 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
3366
3361
3367
3362
reload_tss (vcpu );
3368
3363
3369
- local_irq_disable ();
3370
-
3371
3364
x86_spec_ctrl_restore_host (svm -> spec_ctrl , svm -> virt_spec_ctrl );
3372
3365
3373
3366
vcpu -> arch .cr2 = svm -> vmcb -> save .cr2 ;
Original file line number Diff line number Diff line change 3
3
#include <asm/asm.h>
4
4
#include <asm/bitsperlong.h>
5
5
#include <asm/kvm_vcpu_regs.h>
6
+ #include <asm/nospec-branch.h>
6
7
7
8
#define WORD_SIZE (BITS_PER_LONG / 8 )
8
9
@@ -78,6 +79,7 @@ SYM_FUNC_START(__svm_vcpu_run)
78
79
pop %_ASM_AX
79
80
80
81
/* Enter guest mode */
82
+ sti
81
83
1: vmload %_ASM_AX
82
84
jmp 3f
83
85
2: cmpb $0 , kvm_rebooting
@@ -99,6 +101,13 @@ SYM_FUNC_START(__svm_vcpu_run)
99
101
ud2
100
102
_ASM_EXTABLE(5b, 6b)
101
103
7:
104
+ cli
105
+
106
+ #ifdef CONFIG_RETPOLINE
107
+ /* IMPORTANT: Stuff the RSB immediately after VM-Exit, before RET! */
108
+ FILL_RETURN_BUFFER %_ASM_AX, RSB_CLEAR_LOOPS, X86_FEATURE_RETPOLINE
109
+ #endif
110
+
102
111
/* "POP" @regs to RAX. */
103
112
pop %_ASM_AX
104
113
You can’t perform that action at this time.
0 commit comments