]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
x86/apic: Enable Secure AVIC in the control MSR
authorNeeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Thu, 28 Aug 2025 11:21:26 +0000 (16:51 +0530)
committerBorislav Petkov (AMD) <bp@alien8.de>
Mon, 1 Sep 2025 11:18:14 +0000 (13:18 +0200)
With all the pieces in place now, enable Secure AVIC in the Secure AVIC
Control MSR. Any access to x2APIC MSRs are emulated by the hypervisor
before Secure AVIC is enabled in the control MSR.  Post Secure AVIC
enablement, all x2APIC MSR accesses (whether accelerated by AVIC
hardware or trapped as a #VC exception) operate on the vCPU's APIC
backing page.

Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Tianyu Lan <tiala@microsoft.com>
Link: https://lore.kernel.org/20250828112126.209028-1-Neeraj.Upadhyay@amd.com
arch/x86/include/asm/msr-index.h
arch/x86/kernel/apic/x2apic_savic.c

index 1291e053e40c24cdf31a3559172ab6e2d2f23780..5951344009f1f21f94895003b08799ad21694ab2 100644 (file)
 #define MSR_AMD64_SNP_RESV_BIT         19
 #define MSR_AMD64_SNP_RESERVED_MASK    GENMASK_ULL(63, MSR_AMD64_SNP_RESV_BIT)
 #define MSR_AMD64_SAVIC_CONTROL                0xc0010138
+#define MSR_AMD64_SAVIC_EN_BIT         0
+#define MSR_AMD64_SAVIC_EN             BIT_ULL(MSR_AMD64_SAVIC_EN_BIT)
 #define MSR_AMD64_SAVIC_ALLOWEDNMI_BIT 1
 #define MSR_AMD64_SAVIC_ALLOWEDNMI     BIT_ULL(MSR_AMD64_SAVIC_ALLOWEDNMI_BIT)
 #define MSR_AMD64_RMP_BASE             0xc0010132
index 36e6d0dbcc9ce620165b415655f28eee0d1b705e..b846de0fbcfadfdf1f18cb4215b2d4651fe191af 100644 (file)
@@ -365,7 +365,8 @@ static void savic_setup(void)
        if (res != ES_OK)
                snp_abort();
 
-       native_wrmsrq(MSR_AMD64_SAVIC_CONTROL, gpa | MSR_AMD64_SAVIC_ALLOWEDNMI);
+       native_wrmsrq(MSR_AMD64_SAVIC_CONTROL,
+                     gpa | MSR_AMD64_SAVIC_EN | MSR_AMD64_SAVIC_ALLOWEDNMI);
 }
 
 static int savic_probe(void)