[Devel] [PATCH RHEL9 COMMIT] ms/x86/virt: Force GIF=1 prior to disabling SVM (for reboot flows)
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Nov 1 16:41:40 MSK 2023
The commit is pushed to "branch-rh9-5.14.0-284.25.1.vz9.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-284.25.1.vz9.30.6
------>
commit 738eab9eec92b62ab220dcac196a62dfcc752a9d
Author: Maxim Levitsky <mlevitsk at redhat.com>
Date: Mon May 1 10:12:13 2023 +0300
ms/x86/virt: Force GIF=1 prior to disabling SVM (for reboot flows)
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2177720
commit 6a3236580b0b1accc3976345e723104f74f6f8e6
Author: Sean Christopherson <seanjc at google.com>
Date: Wed Nov 30 23:36:48 2022 +0000
x86/virt: Force GIF=1 prior to disabling SVM (for reboot flows)
Set GIF=1 prior to disabling SVM to ensure that INIT is recognized if the
kernel is disabling SVM in an emergency, e.g. if the kernel is about to
jump into a crash kernel or may reboot without doing a full CPU RESET.
If GIF is left cleared, the new kernel (or firmware) will be unabled to
awaken APs. Eat faults on STGI (due to EFER.SVME=0) as it's possible
that SVM could be disabled via NMI shootdown between reading EFER.SVME
and executing STGI.
Link: https://lore.kernel.org/all/cbcb6f35-e5d7-c1c9-4db9-fe5cc4de579a@amd.com
Cc: stable at vger.kernel.org
Cc: Andrew Cooper <Andrew.Cooper3 at citrix.com>
Cc: Tom Lendacky <thomas.lendacky at amd.com>
Reviewed-by: Thomas Gleixner <tglx at linutronix.de>
Link: https://lore.kernel.org/r/20221130233650.1404148-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc at google.com>
Signed-off-by: Maxim Levitsky <mlevitsk at redhat.com>
(cherry picked from CentOS 9 Stream commit cadcf92788b9)
https://pmc.acronis.work/browse/VSTOR-76102
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
Feature: fix ms/KVM
---
arch/x86/include/asm/virtext.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h
index 8757078d4442..3b12e6b99412 100644
--- a/arch/x86/include/asm/virtext.h
+++ b/arch/x86/include/asm/virtext.h
@@ -126,7 +126,21 @@ static inline void cpu_svm_disable(void)
wrmsrl(MSR_VM_HSAVE_PA, 0);
rdmsrl(MSR_EFER, efer);
- wrmsrl(MSR_EFER, efer & ~EFER_SVME);
+ if (efer & EFER_SVME) {
+ /*
+ * Force GIF=1 prior to disabling SVM to ensure INIT and NMI
+ * aren't blocked, e.g. if a fatal error occurred between CLGI
+ * and STGI. Note, STGI may #UD if SVM is disabled from NMI
+ * context between reading EFER and executing STGI. In that
+ * case, GIF must already be set, otherwise the NMI would have
+ * been blocked, so just eat the fault.
+ */
+ asm_volatile_goto("1: stgi\n\t"
+ _ASM_EXTABLE(1b, %l[fault])
+ ::: "memory" : fault);
+fault:
+ wrmsrl(MSR_EFER, efer & ~EFER_SVME);
+ }
}
/** Makes sure SVM is disabled, if it is supported on the CPU
More information about the Devel
mailing list