hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/virtext.h
....@@ -95,12 +95,6 @@
9595 return 0;
9696 }
9797
98
- if (boot_cpu_data.extended_cpuid_level < SVM_CPUID_FUNC) {
99
- if (msg)
100
- *msg = "can't execute cpuid_8000000a";
101
- return 0;
102
- }
103
-
10498 if (!boot_cpu_has(X86_FEATURE_SVM)) {
10599 if (msg)
106100 *msg = "svm not available";
....@@ -120,7 +114,21 @@
120114
121115 wrmsrl(MSR_VM_HSAVE_PA, 0);
122116 rdmsrl(MSR_EFER, efer);
123
- wrmsrl(MSR_EFER, efer & ~EFER_SVME);
117
+ if (efer & EFER_SVME) {
118
+ /*
119
+ * Force GIF=1 prior to disabling SVM to ensure INIT and NMI
120
+ * aren't blocked, e.g. if a fatal error occurred between CLGI
121
+ * and STGI. Note, STGI may #UD if SVM is disabled from NMI
122
+ * context between reading EFER and executing STGI. In that
123
+ * case, GIF must already be set, otherwise the NMI would have
124
+ * been blocked, so just eat the fault.
125
+ */
126
+ asm_volatile_goto("1: stgi\n\t"
127
+ _ASM_EXTABLE(1b, %l[fault])
128
+ ::: "memory" : fault);
129
+fault:
130
+ wrmsrl(MSR_EFER, efer & ~EFER_SVME);
131
+ }
124132 }
125133
126134 /** Makes sure SVM is disabled, if it is supported on the CPU