Skip to contentSkip to conversation

x86/boot: Fail gracefully if SMP MP-table early_memremap fails

PATCH In review Russ Dill 2 participants 2 messages Aug 19, 2022 – Aug 20, 2022 x86

lore
Share & tools
lore

Russ Dill

author
#0 lore raw

PATCH 1/1 x86/boot: Fail gracefully if SMP MP-table early_memremap fails

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.

Cc Tom Lendacky <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Yinghai Lu <[email protected]>
Cc Dave Hansen <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 arch/x86/kernel/mpparse.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kernel/mpparse.c +4 -0
index fed721f90116..ca2af4f42cb8 100644
@@ -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
Signature · 1 line
2.36.1
maintainer
#1 lore raw
Quoted 26 lines · Russ Dill

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.

Cc Tom Lendacky <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Yinghai Lu <[email protected]>
Cc Dave Hansen <[email protected]>
Cc H. Peter Anvin <[email protected]>
---
 arch/x86/kernel/mpparse.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/kernel/mpparse.c +0 -0
index fed721f90116..ca2af4f42cb8 100644

arch/x86/kernel/mpparse.c static int __init check_physptr(struct mpf_intel *mpf, unsigned int early) · line 439

Quoted 2 lines
arch/x86/kernel/mpparse.c +0 -0
@@ -438,6 +438,10 @@ static int __init check_physptr(struct mpf_intel *mpf, unsigned int early)
 
 	size = get_mpc_size(mpf->physptr);

If the size is 0, why aren't you checking size and returning early here instead of the early_memremap() result which gets called with size=0?

Signature · 4 lines
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette