[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174478829848.31282.16733995724256591570.tip-bot2@tip-bot2>
Date: Wed, 16 Apr 2025 07:24:58 -0000
From: "tip-bot2 for Mike Rapoport (Microsoft)" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Dave Hansen <dave.hansen@...el.com>, Arnd Bergmann <arnd@...nel.org>,
"Mike Rapoport (Microsoft)" <rppt@...nel.org>, Ingo Molnar <mingo@...nel.org>,
Andy Shevchenko <andy@...nel.org>, Arnd Bergmann <arnd@...db.de>,
Davide Ciminaghi <ciminaghi@...dd.com>, "H. Peter Anvin" <hpa@...or.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Matthew Wilcox <willy@...radead.org>, Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <seanjc@...gle.com>, kvm@...r.kernel.org, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [tip: x86/urgent] x86/e820: Discard high memory that can't be
addressed by 32-bit systems
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: e71b6094c20f5dc9c43dc89af8a569ffa511d676
Gitweb: https://git.kernel.org/tip/e71b6094c20f5dc9c43dc89af8a569ffa511d676
Author: Mike Rapoport (Microsoft) <rppt@...nel.org>
AuthorDate: Sun, 13 Apr 2025 11:08:58 +03:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Wed, 16 Apr 2025 09:16:02 +02:00
x86/e820: Discard high memory that can't be addressed by 32-bit systems
Dave Hansen reports the following crash on a 32-bit system with
CONFIG_HIGHMEM=y and CONFIG_X86_PAE=y:
> 0xf75fe000 is the mem_map[] entry for the first page >4GB. It
> obviously wasn't allocated, thus the oops.
BUG: unable to handle page fault for address: f75fe000
#PF: supervisor write access in kernel mode
#PF: error_code(0x0002) - not-present page
*pdpt = 0000000002da2001 *pde = 000000000300c067 *pte = 0000000000000000
Oops: Oops: 0002 [#1] SMP NOPTI
CPU: 0 UID: 0 PID: 0 Comm: swapper Not tainted 6.15.0-rc1-00288-ge618ee89561b-dirty #311 PREEMPT(undef)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
EIP: __free_pages_core+0x3c/0x74
...
Call Trace:
memblock_free_pages+0x11/0x2c
memblock_free_all+0x2ce/0x3a0
mm_core_init+0xf5/0x320
start_kernel+0x296/0x79c
i386_start_kernel+0xad/0xb0
startup_32_smp+0x151/0x154
The mem_map[] is allocated up to the end of ZONE_HIGHMEM which is defined
by max_pfn.
The bug was introduced by this recent commit:
6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
Previously, freeing of high memory was also clamped to the end of
ZONE_HIGHMEM but after this change, memblock_free_all() tries to
free memory above the of ZONE_HIGHMEM as well and that causes
access to mem_map[] entries beyond the end of the memory map.
To fix this, discard the memory after max_pfn from memblock on
32-bit systems so that core MM would be aware only of actually
usable memory.
Fixes: 6faea3422e3b ("arch, mm: streamline HIGHMEM freeing")
Reported-by: Dave Hansen <dave.hansen@...el.com>
Tested-by: Arnd Bergmann <arnd@...nel.org>
Tested-by: Dave Hansen <dave.hansen@...el.com>
Signed-off-by: Mike Rapoport (Microsoft) <rppt@...nel.org>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Acked-by: Dave Hansen <dave.hansen@...el.com>
Cc: Andy Shevchenko <andy@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>
Cc: Davide Ciminaghi <ciminaghi@...dd.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Matthew Wilcox <willy@...radead.org>
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Sean Christopherson <seanjc@...gle.com>
Cc: kvm@...r.kernel.org
Link: https://lore.kernel.org/r/20250413080858.743221-1-rppt@kernel.org
---
arch/x86/kernel/e820.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 9d8dd8d..de62388 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -1299,6 +1299,13 @@ void __init e820__memblock_setup(void)
memblock_add(entry->addr, entry->size);
}
+ /*
+ * Discard memory above 4GB because 32-bit systems are limited to 4GB
+ * of memory even with HIGHMEM.
+ */
+ if (IS_ENABLED(CONFIG_X86_32))
+ memblock_remove(PFN_PHYS(MAX_NONPAE_PFN), -1);
+
/* Throw away partial pages: */
memblock_trim_memory(PAGE_SIZE);
Powered by blists - more mailing lists