Commit bb87190c authored by Heiko Carstens's avatar Heiko Carstens Committed by Vasily Gorbik

s390/kaslr: provide kaslr_enabled() function

Just like other architectures provide a kaslr_enabled() function, instead
of directly accessing a global variable.

Also pass the renamed __kaslr_enabled variable from the decompressor to the
kernel, so that kalsr_enabled() is available there too. This will be used
by a subsequent patch which randomizes the module base load address.
Reviewed-by: default avatarVasily Gorbik <gor@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent 11018ef9
...@@ -79,7 +79,6 @@ extern const char kernel_version[]; ...@@ -79,7 +79,6 @@ extern const char kernel_version[];
extern unsigned long memory_limit; extern unsigned long memory_limit;
extern unsigned long vmalloc_size; extern unsigned long vmalloc_size;
extern int vmalloc_size_set; extern int vmalloc_size_set;
extern int kaslr_enabled;
extern char __boot_data_start[], __boot_data_end[]; extern char __boot_data_start[], __boot_data_end[];
extern char __boot_data_preserved_start[], __boot_data_preserved_end[]; extern char __boot_data_preserved_start[], __boot_data_preserved_end[];
extern char _decompressor_syms_start[], _decompressor_syms_end[]; extern char _decompressor_syms_start[], _decompressor_syms_end[];
......
...@@ -24,11 +24,11 @@ int __bootdata(noexec_disabled); ...@@ -24,11 +24,11 @@ int __bootdata(noexec_disabled);
unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL; unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL;
struct ipl_parameter_block __bootdata_preserved(ipl_block); struct ipl_parameter_block __bootdata_preserved(ipl_block);
int __bootdata_preserved(ipl_block_valid); int __bootdata_preserved(ipl_block_valid);
int __bootdata_preserved(__kaslr_enabled);
unsigned long vmalloc_size = VMALLOC_DEFAULT_SIZE; unsigned long vmalloc_size = VMALLOC_DEFAULT_SIZE;
unsigned long memory_limit; unsigned long memory_limit;
int vmalloc_size_set; int vmalloc_size_set;
int kaslr_enabled;
static inline int __diag308(unsigned long subcode, void *addr) static inline int __diag308(unsigned long subcode, void *addr)
{ {
...@@ -264,7 +264,7 @@ void parse_boot_command_line(void) ...@@ -264,7 +264,7 @@ void parse_boot_command_line(void)
char *args; char *args;
int rc; int rc;
kaslr_enabled = IS_ENABLED(CONFIG_RANDOMIZE_BASE); __kaslr_enabled = IS_ENABLED(CONFIG_RANDOMIZE_BASE);
args = strcpy(command_line_buf, early_command_line); args = strcpy(command_line_buf, early_command_line);
while (*args) { while (*args) {
args = next_arg(args, &param, &val); args = next_arg(args, &param, &val);
...@@ -300,7 +300,7 @@ void parse_boot_command_line(void) ...@@ -300,7 +300,7 @@ void parse_boot_command_line(void)
modify_fac_list(val); modify_fac_list(val);
if (!strcmp(param, "nokaslr")) if (!strcmp(param, "nokaslr"))
kaslr_enabled = 0; __kaslr_enabled = 0;
#if IS_ENABLED(CONFIG_KVM) #if IS_ENABLED(CONFIG_KVM)
if (!strcmp(param, "prot_virt")) { if (!strcmp(param, "prot_virt")) {
......
...@@ -153,7 +153,7 @@ void print_pgm_check_info(void) ...@@ -153,7 +153,7 @@ void print_pgm_check_info(void)
decompressor_printk("Kernel command line: %s\n", early_command_line); decompressor_printk("Kernel command line: %s\n", early_command_line);
decompressor_printk("Kernel fault: interruption code %04x ilc:%x\n", decompressor_printk("Kernel fault: interruption code %04x ilc:%x\n",
S390_lowcore.pgm_code, S390_lowcore.pgm_ilc >> 1); S390_lowcore.pgm_code, S390_lowcore.pgm_ilc >> 1);
if (kaslr_enabled) if (kaslr_enabled())
decompressor_printk("Kernel random base: %lx\n", __kaslr_offset); decompressor_printk("Kernel random base: %lx\n", __kaslr_offset);
decompressor_printk("PSW : %016lx %016lx (%pS)\n", decompressor_printk("PSW : %016lx %016lx (%pS)\n",
S390_lowcore.psw_save_area.mask, S390_lowcore.psw_save_area.mask,
......
...@@ -160,10 +160,10 @@ static void setup_ident_map_size(unsigned long max_physmem_end) ...@@ -160,10 +160,10 @@ static void setup_ident_map_size(unsigned long max_physmem_end)
#ifdef CONFIG_CRASH_DUMP #ifdef CONFIG_CRASH_DUMP
if (oldmem_data.start) { if (oldmem_data.start) {
kaslr_enabled = 0; __kaslr_enabled = 0;
ident_map_size = min(ident_map_size, oldmem_data.size); ident_map_size = min(ident_map_size, oldmem_data.size);
} else if (ipl_block_valid && is_ipl_block_dump()) { } else if (ipl_block_valid && is_ipl_block_dump()) {
kaslr_enabled = 0; __kaslr_enabled = 0;
if (!sclp_early_get_hsa_size(&hsa_size) && hsa_size) if (!sclp_early_get_hsa_size(&hsa_size) && hsa_size)
ident_map_size = min(ident_map_size, hsa_size); ident_map_size = min(ident_map_size, hsa_size);
} }
...@@ -315,7 +315,7 @@ void startup_kernel(void) ...@@ -315,7 +315,7 @@ void startup_kernel(void)
save_ipl_cert_comp_list(); save_ipl_cert_comp_list();
rescue_initrd(safe_addr, ident_map_size); rescue_initrd(safe_addr, ident_map_size);
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_enabled) { if (kaslr_enabled()) {
random_lma = get_random_base(); random_lma = get_random_base();
if (random_lma) { if (random_lma) {
__kaslr_offset = random_lma - vmlinux.default_lma; __kaslr_offset = random_lma - vmlinux.default_lma;
......
...@@ -146,6 +146,13 @@ static inline unsigned long kaslr_offset(void) ...@@ -146,6 +146,13 @@ static inline unsigned long kaslr_offset(void)
return __kaslr_offset; return __kaslr_offset;
} }
extern int __kaslr_enabled;
static inline int kaslr_enabled(void)
{
if (IS_ENABLED(CONFIG_RANDOMIZE_BASE))
return __kaslr_enabled;
return 0;
}
struct oldmem_data { struct oldmem_data {
unsigned long start; unsigned long start;
......
...@@ -150,6 +150,7 @@ unsigned long __bootdata(ident_map_size); ...@@ -150,6 +150,7 @@ unsigned long __bootdata(ident_map_size);
struct physmem_info __bootdata(physmem_info); struct physmem_info __bootdata(physmem_info);
unsigned long __bootdata_preserved(__kaslr_offset); unsigned long __bootdata_preserved(__kaslr_offset);
int __bootdata_preserved(__kaslr_enabled);
unsigned int __bootdata_preserved(zlib_dfltcc_support); unsigned int __bootdata_preserved(zlib_dfltcc_support);
EXPORT_SYMBOL(zlib_dfltcc_support); EXPORT_SYMBOL(zlib_dfltcc_support);
u64 __bootdata_preserved(stfle_fac_list[16]); u64 __bootdata_preserved(stfle_fac_list[16]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment