Skip to content

Commit f6c4fd5

Browse files
committed
x86/cpu_entry_area: Prevent wraparound in setup_cpu_entry_area_ptes() on 32bit
The loop which populates the CPU entry area PMDs can wrap around on 32bit machines when the number of CPUs is small. It worked wonderful for NR_CPUS=64 for whatever reason and the moron who wrote that code did not bother to test it with !SMP. Check for the wraparound to fix it. Fixes: 92a0f81 ("x86/cpu_entry_area: Move it out of the fixmap") Reported-by: kernel test robot <fengguang.wu@intel.com> Signed-off-by: Thomas "Feels stupid" Gleixner <tglx@linutronix.de> Tested-by: Borislav Petkov <bp@alien8.de>
1 parent 613e396 commit f6c4fd5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/mm/cpu_entry_area.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ static __init void setup_cpu_entry_area_ptes(void)
122122
start = CPU_ENTRY_AREA_BASE;
123123
end = start + CPU_ENTRY_AREA_MAP_SIZE;
124124

125-
for (; start < end; start += PMD_SIZE)
125+
/* Careful here: start + PMD_SIZE might wrap around */
126+
for (; start < end && start >= CPU_ENTRY_AREA_BASE; start += PMD_SIZE)
126127
populate_extra_pte(start);
127128
#endif
128129
}

0 commit comments

Comments
 (0)