diff options
author | Vasily Gorbik <gor@linux.ibm.com> | 2023-01-27 17:08:29 +0100 |
---|---|---|
committer | Heiko Carstens <hca@linux.ibm.com> | 2023-02-06 11:13:55 +0100 |
commit | 8382c963249dafcbe809dea307c2de16d5645579 (patch) | |
tree | 688302288abea53f10fdf777f7510a31b4d70ea2 /arch/s390/boot/vmem.c | |
parent | s390/mem_detect: add get_mem_detect_online_total() (diff) | |
download | linux-8382c963249dafcbe809dea307c2de16d5645579.tar.xz linux-8382c963249dafcbe809dea307c2de16d5645579.zip |
s390/boot: avoid page tables memory in kaslr
If kernel is build without KASAN support there is a chance that kernel
image is going to be positioned by KASLR code to overlap with identity
mapping page tables.
When kernel is build with KASAN support enabled memory which
is potentially going to be used for page tables and KASAN
shadow mapping is accounted for in KASLR with the use of
kasan_estimate_memory_needs(). Split this function and introduce
vmem_estimate_memory_needs() to cover decompressor's vmem identity
mapping page tables.
Fixes: bb1520d581a3 ("s390/mm: start kernel with DAT enabled")
Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Diffstat (limited to 'arch/s390/boot/vmem.c')
-rw-r--r-- | arch/s390/boot/vmem.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/s390/boot/vmem.c b/arch/s390/boot/vmem.c index 82ef57827042..4e54357ccd00 100644 --- a/arch/s390/boot/vmem.c +++ b/arch/s390/boot/vmem.c @@ -269,3 +269,10 @@ void setup_vmem(unsigned long asce_limit) init_mm.context.asce = S390_lowcore.kernel_asce; } + +unsigned long vmem_estimate_memory_needs(unsigned long online_mem_total) +{ + unsigned long pages = DIV_ROUND_UP(online_mem_total, PAGE_SIZE); + + return DIV_ROUND_UP(pages, _PAGE_ENTRIES) * _PAGE_TABLE_SIZE * 2; +} |