Control: tags -1 + patch upstream Hi Francesco,
On Fri, Dec 28, 2018 at 08:27:52PM +0100, Francesco Poli (wintermute) wrote: > Package: src:linux > Version: 4.19.12-1 > Severity: important > > Hi! > > After upgrading an i386 box (Soekris net5501) running testing (buster), > I found out that the newly migrated Linux kernel fails to boot. > > Looking at the boot through the serial console reveals the attached > output, in which I spotted the following line: > > [ 5.363599] kernel BUG at arch/x86/mm/pat.c:549! The attached patch should fix the issue, and is pending for the upcoming 4.19.13 stable version. If you have a chance to verify this, with https://kernel-team.pages.debian.net/kernel-handbook/ch-common-tasks.html#s4.2.2 that would be great. Regards, Salvatore
>From 51c3fbd89d7554caa3290837604309f8d8669d99 Mon Sep 17 00:00:00 2001 From: Dan Williams <dan.j.willi...@intel.com> Date: Tue, 11 Dec 2018 07:49:39 -0800 Subject: x86/mm: Fix decoy address handling vs 32-bit builds From: Dan Williams <dan.j.willi...@intel.com> commit 51c3fbd89d7554caa3290837604309f8d8669d99 upstream. A decoy address is used by set_mce_nospec() to update the cache attributes for a page that may contain poison (multi-bit ECC error) while attempting to minimize the possibility of triggering a speculative access to that page. When reserve_memtype() is handling a decoy address it needs to convert it to its real physical alias. The conversion, AND'ing with __PHYSICAL_MASK, is broken for a 32-bit physical mask and reserve_memtype() is passed the last physical page. Gert reports triggering the: BUG_ON(start >= end); ...assertion when running a 32-bit non-PAE build on a platform that has a driver resource at the top of physical memory: BIOS-e820: [mem 0x00000000fff00000-0x00000000ffffffff] reserved Given that the decoy address scheme is only targeted at 64-bit builds and assumes that the top of physical address space is free for use as a decoy address range, simply bypass address sanitization in the 32-bit case. Lastly, there was no need to crash the system when this failure occurred, and no need to crash future systems if the assumptions of decoy addresses are ever violated. Change the BUG_ON() to a WARN() with an error return. Fixes: 510ee090abc3 ("x86/mm/pat: Prepare {reserve, free}_memtype() for...") Reported-by: Gert Robben <t...@gert.gr> Signed-off-by: Dan Williams <dan.j.willi...@intel.com> Signed-off-by: Thomas Gleixner <t...@linutronix.de> Tested-by: Gert Robben <t...@gert.gr> Cc: sta...@vger.kernel.org Cc: Andy Shevchenko <andriy.shevche...@linux.intel.com> Cc: Dave Hansen <dave.han...@linux.intel.com> Cc: Andy Lutomirski <l...@kernel.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Borislav Petkov <b...@alien8.de> Cc: "H. Peter Anvin" <h...@zytor.com> Cc: platform-driver-...@vger.kernel.org Cc: <sta...@vger.kernel.org> Link: https://lkml.kernel.org/r/154454337985.789277.12133288391664677775.st...@dwillia2-desk3.amr.corp.intel.com Signed-off-by: Greg Kroah-Hartman <gre...@linuxfoundation.org> --- arch/x86/mm/pat.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c @@ -519,8 +519,13 @@ static u64 sanitize_phys(u64 address) * for a "decoy" virtual address (bit 63 clear) passed to * set_memory_X(). __pa() on a "decoy" address results in a * physical address with bit 63 set. + * + * Decoy addresses are not present for 32-bit builds, see + * set_mce_nospec(). */ - return address & __PHYSICAL_MASK; + if (IS_ENABLED(CONFIG_X86_64)) + return address & __PHYSICAL_MASK; + return address; } /* @@ -546,7 +551,11 @@ int reserve_memtype(u64 start, u64 end, start = sanitize_phys(start); end = sanitize_phys(end); - BUG_ON(start >= end); /* end is exclusive */ + if (start >= end) { + WARN(1, "%s failed: [mem %#010Lx-%#010Lx], req %s\n", __func__, + start, end - 1, cattr_name(req_type)); + return -EINVAL; + } if (!pat_enabled()) { /* This is identical to page table setting without PAT */