mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/apic: use MSR programmming interface to read APIC register in x2APIC mode
@ 2021-06-24  7:08 Zhou JianFeng
  0 siblings, 0 replies; only message in thread
From: Zhou JianFeng @ 2021-06-24  7:08 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86,
	H Peter Anvin, David Woodhouse, Dave Hansen, Peter Zijlstra
  Cc: linux-kernel, Zhou JianFeng

Memory-mapped interface is only supported when operating in xAPIC mode.

When x2APIC mode enabled, the following calling will read APIC register by
memory-mapping interface in x2APIC mode:
    default_setup_apic_routing()
        x2apic_cluster_probe()
            init_x2apic_ldr()
                apic_read(APIC_LDR)
The APIC id read by apic_read(APIC_LDR) is invalid(0xffffffff in my tests),
and will lead to MCE(machine check exception) when RAS(Reliability
Availability Serviceability) enabled.

Read APIC id by using programming interface in x2APIC mode.

Signed-off-by: Zhou JianFeng <jianfeng.zhou@intel.com>
---
 arch/x86/kernel/apic/x2apic_cluster.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index f4da9bb69a88..311a844bb779 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -100,9 +100,14 @@ static u32 x2apic_calc_apicid(unsigned int cpu)
 static void init_x2apic_ldr(void)
 {
 	struct cluster_mask *cmsk = this_cpu_read(cluster_masks);
-	u32 cluster, apicid = apic_read(APIC_LDR);
+	u32 cluster, apicid;
 	unsigned int cpu;
 
+	if (x2apic_enabled())
+		apicid = native_apic_msr_read(APIC_LDR);
+	else
+		apicid = apic_read(APIC_LDR);
+
 	this_cpu_write(x86_cpu_to_logical_apicid, apicid);
 
 	if (cmsk)
-- 
2.27.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-24  7:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24  7:08 [PATCH] x86/apic: use MSR programmming interface to read APIC register in x2APIC mode Zhou JianFeng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®