Skip to content

Commit 0fc59d3

Browse files
Yinghai LuIngo Molnar
authored andcommitted
x86: fix init_memory_mapping() to handle small ranges
Impact: fix failed EFI bootup in certain circumstances Ying Huang found init_memory_mapping() has problem with small ranges less than 2M when he tried to direct map the EFI runtime code out of max_low_pfn_mapped. It turns out we never considered that case and didn't check the range... Reported-by: Ying Huang <[email protected]> Signed-off-by: Yinghai Lu <[email protected]> Cc: Brian Maly <[email protected]> LKML-Reference: <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
1 parent 2450cf5 commit 0fc59d3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/x86/mm/init_64.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,8 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
714714
pos = start_pfn << PAGE_SHIFT;
715715
end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT)
716716
<< (PMD_SHIFT - PAGE_SHIFT);
717+
if (end_pfn > (end >> PAGE_SHIFT))
718+
end_pfn = end >> PAGE_SHIFT;
717719
if (start_pfn < end_pfn) {
718720
nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
719721
pos = end_pfn << PAGE_SHIFT;

0 commit comments

Comments
 (0)