Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/sev: Prevent SECURE_AVIC_CONTROL MSR interception for Secure AVIC guests

The SECURE_AVIC_CONTROL MSR holds the GPA of the guest APIC backing page and
bitfields to control enablement of Secure AVIC and whether the guest allows
NMIs to be injected by the hypervisor.

This MSR is populated by the guest and can be read by the guest to get the GPA
of the APIC backing page. The MSR can only be accessed in Secure AVIC mode.
Any attempt to access it when not in Secure AVIC mode results in #GP. So, the
hypervisor should not intercept it. A #VC exception will be generated
otherwise. If this occurs and Secure AVIC is enabled, terminate the guest
execution.

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/20250828113119.209135-1-Neeraj.Upadhyay@amd.com

authored by

Neeraj Upadhyay and committed by
Borislav Petkov (AMD)
952aefee c4074ab8

+9
+9
arch/x86/coco/sev/vc-handle.c
··· 415 415 if (sev_status & MSR_AMD64_SNP_SECURE_TSC) 416 416 return __vc_handle_secure_tsc_msrs(ctxt, write); 417 417 break; 418 + case MSR_AMD64_SAVIC_CONTROL: 419 + /* 420 + * AMD64_SAVIC_CONTROL should not be intercepted when 421 + * Secure AVIC is enabled. Terminate the Secure AVIC guest 422 + * if the interception is enabled. 423 + */ 424 + if (cc_platform_has(CC_ATTR_SNP_SECURE_AVIC)) 425 + return ES_VMM_ERROR; 426 + break; 418 427 default: 419 428 break; 420 429 }