[PATCH v10 04/18] x86/apic: Initialize APIC ID for Secure AVIC

From: Neeraj Upadhyay
Date: Thu Aug 28 2025 - 07:04:42 EST


Initialize the APIC ID in the Secure AVIC APIC backing page with
the APIC_ID MSR value read from the hypervisor. CPU topology evaluation
later during boot would catch and report any duplicate APIC ID for
two CPUs.

Reviewed-by: Tianyu Lan <tiala@xxxxxxxxxxxxx>
Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@xxxxxxx>
---
Changes since v9:
- Commit log update.

arch/x86/kernel/apic/x2apic_savic.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/arch/x86/kernel/apic/x2apic_savic.c b/arch/x86/kernel/apic/x2apic_savic.c
index 5479605429c1..56c51ea4e5ab 100644
--- a/arch/x86/kernel/apic/x2apic_savic.c
+++ b/arch/x86/kernel/apic/x2apic_savic.c
@@ -150,6 +150,12 @@ static void savic_setup(void)
enum es_result res;
unsigned long gpa;

+ /*
+ * Before Secure AVIC is enabled, APIC MSR reads are intercepted.
+ * APIC_ID MSR read returns the value from the hypervisor.
+ */
+ apic_set_reg(ap, APIC_ID, native_apic_msr_read(APIC_ID));
+
gpa = __pa(ap);

/*
--
2.34.1