[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240913113705.419146-6-Neeraj.Upadhyay@amd.com>
Date: Fri, 13 Sep 2024 17:06:56 +0530
From: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
To: <linux-kernel@...r.kernel.org>
CC: <tglx@...utronix.de>, <mingo@...hat.com>, <dave.hansen@...ux.intel.com>,
<Thomas.Lendacky@....com>, <nikunj@....com>, <Santosh.Shukla@....com>,
<Vasant.Hegde@....com>, <Suravee.Suthikulpanit@....com>, <bp@...en8.de>,
<David.Kaplan@....com>, <x86@...nel.org>, <hpa@...or.com>,
<peterz@...radead.org>, <seanjc@...gle.com>, <pbonzini@...hat.com>,
<kvm@...r.kernel.org>
Subject: [RFC 05/14] x86/apic: Initialize APIC ID for Secure AVIC
Initialize the APIC ID in the APIC backing page with the
CPUID function 0000_000bh_EDX (Extended Topology Enumeration),
and ensure that APIC ID msr read from hypervisor is consistent
with the value read from CPUID.
Signed-off-by: Neeraj Upadhyay <Neeraj.Upadhyay@....com>
---
arch/x86/kernel/apic/x2apic_savic.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/x86/kernel/apic/x2apic_savic.c b/arch/x86/kernel/apic/x2apic_savic.c
index 99151be4e173..09fbc1857bf3 100644
--- a/arch/x86/kernel/apic/x2apic_savic.c
+++ b/arch/x86/kernel/apic/x2apic_savic.c
@@ -14,6 +14,7 @@
#include <linux/sizes.h>
#include <asm/apic.h>
+#include <asm/cpuid.h>
#include <asm/sev.h>
#include "local.h"
@@ -200,6 +201,8 @@ static void x2apic_savic_send_IPI_mask_allbutself(const struct cpumask *mask, in
static void init_backing_page(void *backing_page)
{
+ u32 hv_apic_id;
+ u32 apic_id;
u32 val;
int i;
@@ -220,6 +223,13 @@ static void init_backing_page(void *backing_page)
val = read_msr_from_hv(APIC_LDR);
set_reg(backing_page, APIC_LDR, val);
+
+ /* Read APIC ID from Extended Topology Enumeration CPUID */
+ apic_id = cpuid_edx(0x0000000b);
+ hv_apic_id = read_msr_from_hv(APIC_ID);
+ WARN_ONCE(hv_apic_id != apic_id, "Inconsistent APIC_ID values: %d (cpuid), %d (msr)",
+ apic_id, hv_apic_id);
+ set_reg(backing_page, APIC_ID, apic_id);
}
static void x2apic_savic_setup(void)
--
2.34.1
Powered by blists - more mailing lists