summaryrefslogtreecommitdiff
path: root/arch/s390/boot/boot.h
diff options
context:
space:
mode:
authorVasily Gorbik <gor@linux.ibm.com>2023-02-22 01:08:42 +0300
committerVasily Gorbik <gor@linux.ibm.com>2023-04-13 18:36:27 +0300
commit6e259bc5a15ec49693fa3d19fdd4511f7679a20d (patch)
tree26adb36a3f3907aa179194e67ff95fa3992a7d76 /arch/s390/boot/boot.h
parent898435203c115b164b96f30be7d9c790bbb50338 (diff)
downloadlinux-6e259bc5a15ec49693fa3d19fdd4511f7679a20d.tar.xz
s390/kaslr: generalize and improve random base distribution
Improve the distribution algorithm of random base address to ensure a uniformity among all suitable addresses. To generate a random value once, and to build a continuous range in which every value is suitable, count all the suitable addresses (referred to as positions) that can be used as a base address. The positions are counted by iterating over the usable memory ranges. For each range that is big enough to accommodate the image, count all the suitable addresses where the image can be placed, while taking reserved memory ranges into consideration. A new function "iterate_valid_positions()" has dual purpose. Firstly, it is called to count the positions in a given memory range, and secondly, to convert a random position back to an address. "get_random_base()" has been replaced with more generic "randomize_within_range()" which now could be called for randomizing base addresses not just for the kernel image. Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch/s390/boot/boot.h')
-rw-r--r--arch/s390/boot/boot.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/s390/boot/boot.h b/arch/s390/boot/boot.h
index 5baa855c21cb..222c6886acf6 100644
--- a/arch/s390/boot/boot.h
+++ b/arch/s390/boot/boot.h
@@ -54,6 +54,7 @@ unsigned long physmem_alloc_top_down(enum reserved_range_type type, unsigned lon
unsigned long physmem_alloc_range(enum reserved_range_type type, unsigned long size,
unsigned long align, unsigned long min, unsigned long max,
bool die_on_oom);
+unsigned long get_physmem_alloc_pos(void);
bool ipl_report_certs_intersects(unsigned long addr, unsigned long size,
unsigned long *intersection_start);
bool is_ipl_block_dump(void);
@@ -66,7 +67,8 @@ void verify_facilities(void);
void print_missing_facilities(void);
void sclp_early_setup_buffer(void);
void print_pgm_check_info(void);
-unsigned long get_random_base(void);
+unsigned long randomize_within_range(unsigned long size, unsigned long align,
+ unsigned long min, unsigned long max);
void setup_vmem(unsigned long asce_limit);
void __printf(1, 2) decompressor_printk(const char *fmt, ...);
void print_stacktrace(unsigned long sp);