From: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
To: <linux-kernel@vger.kernel.org>, <tglx@linutronix.de>,
<mingo@redhat.com>, <bp@alien8.de>, <dave.hansen@linux.intel.com>,
<x86@kernel.org>
Cc: <hpa@zytor.com>, <gorcunov@openvz.org>,
<suresh.b.siddha@intel.com>,
Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>,
"Kishon Vijay Abraham I" <kvijayab@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>
Subject: [PATCH v1] x86/apic: Fix kernel panic when "intremap=off" and "x2apic_phys" are set
Date: Sat, 17 Jun 2023 02:52:36 +0530 [thread overview]
Message-ID: <20230616212236.1389-1-dheerajkumar.srivastava@amd.com> (raw)
x2APIC mode requires "Interrupt Remapping" to be enabled and the
"physical x2apic" driver can be used only when x2APIC mode is enabled.
However when "intremap=off" and "x2apic_phys" kernel command line
parameters are passed, "physical x2apic" driver is being used even when
x2APIC mode is disabled ("intremap=off" disables x2APIC mode).
This results in the below kernel panic:
unchecked MSR access error: RDMSR from 0x80f at rIP: 0xffffffff87eab4ec
(native_read_msr+0xc/0x40)
Call Trace:
<TASK>
native_apic_msr_read+0x1f/0x30
setup_local_APIC+0x4e/0x380
? zen_untrain_ret+0x1/0x1
? enable_IR_x2apic+0xe8/0x250
apic_intr_mode_init+0x4c/0x120
x86_late_time_init+0x28/0x40
start_kernel+0x626/0xa80
x86_64_start_reservations+0x1c/0x30
x86_64_start_kernel+0xbf/0x110
secondary_startup_64_no_verify+0x10b/0x10b
</TASK>
This is due to an incorrect conditional check in x2apic_phys_probe().
Fix it here by returning 0 when "x2apic_mode" is not set in
x2apic_phys_probe(). This now prevents default_setup_apic_routing() from
selecting "physical x2apic" driver.
Fixes: 9ebd680bd029 ("x86, apic: Use probe routines to simplify apic selection")
Reviewed-by: Kishon Vijay Abraham I <kvijayab@amd.com>
Reviewed-by: Vasant Hegde <vasant.hegde@amd.com>
Signed-off-by: Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
---
arch/x86/kernel/apic/x2apic_phys.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index 6bde05a86b4e..896bc41cb2ba 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -97,7 +97,10 @@ static void init_x2apic_ldr(void)
static int x2apic_phys_probe(void)
{
- if (x2apic_mode && (x2apic_phys || x2apic_fadt_phys()))
+ if (!x2apic_mode)
+ return 0;
+
+ if (x2apic_phys || x2apic_fadt_phys())
return 1;
return apic == &apic_x2apic_phys;
--
2.25.1
next reply other threads:[~2023-06-16 21:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-16 21:22 Dheeraj Kumar Srivastava [this message]
2023-06-18 22:24 ` Cyrill Gorcunov
2023-06-19 15:25 ` Thomas Gleixner
2023-06-19 14:50 ` Borislav Petkov
2023-06-19 16:31 ` Thomas Gleixner
2023-06-19 19:10 ` [tip: x86/urgent] x86/apic: Fix kernel panic when booting with intremap=off and x2apic_phys tip-bot2 for Dheeraj Kumar Srivastava
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=20230616212236.1389-1-dheerajkumar.srivastava@amd.com \
--to=dheerajkumar.srivastava@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=gorcunov@openvz.org \
--cc=hpa@zytor.com \
--cc=kvijayab@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=suresh.b.siddha@intel.com \
--cc=tglx@linutronix.de \
--cc=vasant.hegde@amd.com \
--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®