Skip to content

Commit a3ca27c

Browse files
Alexander GordeevVasily Gorbik
authored andcommitted
s390/mm: Prevent lowcore vs identity mapping overlap
The identity mapping position in virtual memory is randomized together with the kernel mapping. That position can never overlap with the lowcore even when the lowcore is relocated. Prevent overlapping with the lowcore to allow independent positioning of the identity mapping. With the current value of the alternative lowcore address of 0x70000 the overlap could happen in case the identity mapping is placed at zero. This is a prerequisite for uncoupling of randomization base of kernel image and identity mapping in virtual memory. Acked-by: Vasily Gorbik <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent de9c2c6 commit a3ca27c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

arch/s390/kernel/setup.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,23 @@ static void __init memblock_add_physmem_info(void)
734734
}
735735

736736
/*
737-
* Reserve memory used for lowcore/command line/kernel image.
737+
* Reserve memory used for lowcore.
738+
*/
739+
static void __init reserve_lowcore(void)
740+
{
741+
void *lowcore_start = get_lowcore();
742+
void *lowcore_end = lowcore_start + sizeof(struct lowcore);
743+
void *start, *end;
744+
745+
if ((void *)__identity_base < lowcore_end) {
746+
start = max(lowcore_start, (void *)__identity_base);
747+
end = min(lowcore_end, (void *)(__identity_base + ident_map_size));
748+
memblock_reserve(__pa(start), __pa(end));
749+
}
750+
}
751+
752+
/*
753+
* Reserve memory used for absolute lowcore/command line/kernel image.
738754
*/
739755
static void __init reserve_kernel(void)
740756
{
@@ -918,6 +934,7 @@ void __init setup_arch(char **cmdline_p)
918934

919935
/* Do some memory reservations *before* memory is added to memblock */
920936
reserve_pgtables();
937+
reserve_lowcore();
921938
reserve_kernel();
922939
reserve_initrd();
923940
reserve_certificate_list();

0 commit comments

Comments
 (0)