mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhou JianFeng <jianfeng.zhou@intel.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, H Peter Anvin <hpa@zytor.com>,
	David Woodhouse <dwmw@amazon.co.uk>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Zhou JianFeng <jianfeng.zhou@intel.com>
Subject: [PATCH] x86/apic: use MSR programmming interface to read APIC register in x2APIC mode
Date: Thu, 24 Jun 2021 15:08:04 +0800	[thread overview]
Message-ID: <20210624070804.935474-1-jianfeng.zhou@intel.com> (raw)

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


                 reply	other threads:[~2021-06-24  7:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210624070804.935474-1-jianfeng.zhou@intel.com \
    --to=jianfeng.zhou@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dwmw@amazon.co.uk \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®