File tree Expand file tree Collapse file tree 7 files changed +42
-15
lines changed Expand file tree Collapse file tree 7 files changed +42
-15
lines changed Original file line number Diff line number Diff line change 19
19
#include <asm/suspend.h>
20
20
#include <asm/tlbflush.h>
21
21
#include <asm/tdx.h>
22
+ #include "../kvm/vmx/vmx.h"
22
23
23
24
#ifdef CONFIG_XEN
24
25
#include <xen/interface/xen.h>
@@ -107,4 +108,9 @@ static void __used common(void)
107
108
OFFSET (TSS_sp0 , tss_struct , x86_tss .sp0 );
108
109
OFFSET (TSS_sp1 , tss_struct , x86_tss .sp1 );
109
110
OFFSET (TSS_sp2 , tss_struct , x86_tss .sp2 );
111
+
112
+ if (IS_ENABLED (CONFIG_KVM_INTEL )) {
113
+ BLANK ();
114
+ OFFSET (VMX_spec_ctrl , vcpu_vmx , spec_ctrl );
115
+ }
110
116
}
Original file line number Diff line number Diff line change @@ -196,8 +196,8 @@ void __init check_bugs(void)
196
196
}
197
197
198
198
/*
199
- * NOTE: For VMX, this function is not called in the vmexit path.
200
- * It uses vmx_spec_ctrl_restore_host() instead .
199
+ * NOTE: This function is *only* called for SVM. VMX spec_ctrl handling is
200
+ * done in vmenter.S .
201
201
*/
202
202
void
203
203
x86_virt_spec_ctrl (u64 guest_spec_ctrl , u64 guest_virt_spec_ctrl , bool setguest )
Original file line number Diff line number Diff line change 4
4
5
5
#include <asm/vmx.h>
6
6
7
- #include "lapic.h"
8
- #include "x86.h"
7
+ #include "../ lapic.h"
8
+ #include "../ x86.h"
9
9
10
10
extern bool __read_mostly enable_vpid ;
11
11
extern bool __read_mostly flexpriority_enabled ;
Original file line number Diff line number Diff line change 1
1
/* SPDX-License-Identifier: GPL-2.0 */
2
2
#include <linux/linkage.h>
3
3
#include <asm/asm.h>
4
+ #include <asm/asm-offsets.h>
4
5
#include <asm/bitsperlong.h>
5
6
#include <asm/kvm_vcpu_regs.h>
6
7
#include <asm/nospec-branch.h>
8
+ #include <asm/percpu.h>
7
9
#include <asm/segment.h>
8
10
#include "run_flags.h"
9
11
@@ -73,6 +75,33 @@ SYM_FUNC_START(__vmx_vcpu_run)
73
75
lea (%_ASM_SP), %_ASM_ARG2
74
76
call vmx_update_host_rsp
75
77
78
+ ALTERNATIVE "jmp .Lspec_ctrl_done" , "", X86_FEATURE_MSR_SPEC_CTRL
79
+
80
+ /*
81
+ * SPEC_CTRL handling: if the guest's SPEC_CTRL value differs from the
82
+ * host's, write the MSR.
83
+ *
84
+ * IMPORTANT: To avoid RSB underflow attacks and any other nastiness,
85
+ * there must not be any returns or indirect branches between this code
86
+ * and vmentry.
87
+ */
88
+ mov 2*WORD_SIZE(%_ASM_SP), %_ASM_DI
89
+ movl VMX_spec_ctrl(%_ASM_DI), %edi
90
+ movl PER_CPU_VAR(x86_spec_ctrl_current), %esi
91
+ cmp %edi , %esi
92
+ je .Lspec_ctrl_done
93
+ mov $MSR_IA32_SPEC_CTRL, %ecx
94
+ xor %edx , %edx
95
+ mov %edi , %eax
96
+ wrmsr
97
+
98
+ .Lspec_ctrl_done:
99
+
100
+ /*
101
+ * Since vmentry is serializing on affected CPUs, there's no need for
102
+ * an LFENCE to stop speculation from skipping the wrmsr.
103
+ */
104
+
76
105
/* Load @regs to RAX. */
77
106
mov (%_ASM_SP), %_ASM_AX
78
107
Original file line number Diff line number Diff line change @@ -6988,14 +6988,6 @@ static fastpath_t vmx_vcpu_run(struct kvm_vcpu *vcpu)
6988
6988
6989
6989
kvm_wait_lapic_expire (vcpu );
6990
6990
6991
- /*
6992
- * If this vCPU has touched SPEC_CTRL, restore the guest's value if
6993
- * it's non-zero. Since vmentry is serialising on affected CPUs, there
6994
- * is no need to worry about the conditional branch over the wrmsr
6995
- * being speculatively taken.
6996
- */
6997
- x86_spec_ctrl_set_guest (vmx -> spec_ctrl , 0 );
6998
-
6999
6991
/* The actual VMENTER/EXIT is in the .noinstr.text section. */
7000
6992
vmx_vcpu_enter_exit (vcpu , vmx , __vmx_vcpu_run_flags (vmx ));
7001
6993
Original file line number Diff line number Diff line change 8
8
#include <asm/intel_pt.h>
9
9
10
10
#include "capabilities.h"
11
- #include "kvm_cache_regs.h"
11
+ #include "../ kvm_cache_regs.h"
12
12
#include "posted_intr.h"
13
13
#include "vmcs.h"
14
14
#include "vmx_ops.h"
15
- #include "cpuid.h"
15
+ #include "../ cpuid.h"
16
16
#include "run_flags.h"
17
17
18
18
#define MSR_TYPE_R 1
Original file line number Diff line number Diff line change 8
8
9
9
#include "evmcs.h"
10
10
#include "vmcs.h"
11
- #include "x86.h"
11
+ #include "../ x86.h"
12
12
13
13
asmlinkage void vmread_error (unsigned long field , bool fault );
14
14
__attribute__((regparm (0 ))) void vmread_error_trampoline (unsigned long field ,
You can’t perform that action at this time.
0 commit comments