public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Russ Dill <russ.dill@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Russ Dill <Russ.Dill@gmail.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Yinghai Lu <yinghai@kernel.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org
Subject: [PATCH] x86/boot: Fail gracefully if SMP MP-table early_memremap fails
Date: Fri, 19 Aug 2022 15:44:00 -0700	[thread overview]
Message-ID: <20220819224400.2667654-1-Russ.Dill@gmail.com> (raw)

At least one older motherboard (Micronics W6-LI Pentium Pro) has been
observed to fill in the physptr but not actually populate the mpc when
only one CPU is present. In this specific case, this leads to the size
field being zero which causes early_memremap to fail. This then
causes a NULL pointer exception in smp_read_mpc.

Add a simple return check. Returning -1 here will cause the MP-table to
be ignored and the system to boot in nosmp mode.

Signed-off-by: Russ Dill <Russ.Dill@gmail.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Yinghai Lu <yinghai@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: x86@kernel.org
---
 arch/x86/kernel/mpparse.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/mpparse.c b/arch/x86/kernel/mpparse.c
index fed721f90116..ca2af4f42cb8 100644
--- a/arch/x86/kernel/mpparse.c
+++ b/arch/x86/kernel/mpparse.c
@@ -438,6 +438,10 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early)
 
 	size = get_mpc_size(mpf->physptr);
 	mpc = early_memremap(mpf->physptr, size);
+	if (!mpc) {
+		pr_err("MPTABLE: mpc early_memremap() failed\n");
+		return -1;
+	}
 
 	/*
 	 * Read the physical hardware table.  Anything here will
-- 
2.36.1


             reply	other threads:[~2022-08-19 22:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-19 22:44 Russ Dill [this message]
2022-08-20 15:33 ` [PATCH] x86/boot: Fail gracefully if SMP MP-table early_memremap fails Borislav Petkov

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=20220819224400.2667654-1-Russ.Dill@gmail.com \
    --to=russ.dill@gmail.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    --cc=yinghai@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