]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/boot: Do not assume the decompressor range is reserved
authorAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 17 Jul 2024 19:43:22 +0000 (21:43 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 23 Jul 2024 14:02:30 +0000 (16:02 +0200)
When allocating a random memory range for .amode31 sections
the minimal randomization address is 0. That does not lead
to a possible overlap with the decompressor image (which also
starts from 0) since by that time the image range is already
reserved.

Do not assume the decompressor range is reserved and always
provide the minimal randomization address for .amode31
sections beyond the decompressor. That is a prerequisite
for moving the lowcore memory address from NULL elsewhere.

Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/boot/startup.c

index c59014945af0507f3b6b3c2888da6bc900edffc3..cc8753c0c1216214a96d7099698d2b71f41cfc91 100644 (file)
@@ -478,8 +478,12 @@ void startup_kernel(void)
         * before the kernel started. Therefore, in case the two sections
         * overlap there is no risk of corrupting any data.
         */
-       if (kaslr_enabled())
-               amode31_lma = randomize_within_range(vmlinux.amode31_size, PAGE_SIZE, 0, SZ_2G);
+       if (kaslr_enabled()) {
+               unsigned long amode31_min;
+
+               amode31_min = (unsigned long)_decompressor_end;
+               amode31_lma = randomize_within_range(vmlinux.amode31_size, PAGE_SIZE, amode31_min, SZ_2G);
+       }
        if (!amode31_lma)
                amode31_lma = __kaslr_offset_phys - vmlinux.amode31_size;
        physmem_reserve(RR_AMODE31, amode31_lma, vmlinux.amode31_size);