Commit 59793c5a authored by Vasily Gorbik's avatar Vasily Gorbik

s390: move vmalloc option parsing to startup code

Few other crucial memory setup options are already handled in
the startup code. Those values are needed by kaslr and kasan
implementations. "vmalloc" is the last piece required for future
improvements such as early decision on kernel page levels depth required
for actual memory setup, as well as vmalloc memory area access monitoring
in kasan.
Reviewed-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
parent f62f7dcb
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/boot_data.h> #include <asm/boot_data.h>
#include <asm/facility.h> #include <asm/facility.h>
#include <asm/pgtable.h>
#include <asm/uv.h> #include <asm/uv.h>
#include "boot.h" #include "boot.h"
...@@ -14,6 +15,7 @@ char __bootdata(early_command_line)[COMMAND_LINE_SIZE]; ...@@ -14,6 +15,7 @@ char __bootdata(early_command_line)[COMMAND_LINE_SIZE];
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);
unsigned long __bootdata(vmalloc_size) = VMALLOC_DEFAULT_SIZE;
unsigned long __bootdata(memory_end); unsigned long __bootdata(memory_end);
int __bootdata(memory_end_set); int __bootdata(memory_end_set);
int __bootdata(noexec_disabled); int __bootdata(noexec_disabled);
...@@ -226,6 +228,9 @@ void parse_boot_command_line(void) ...@@ -226,6 +228,9 @@ void parse_boot_command_line(void)
memory_end_set = 1; memory_end_set = 1;
} }
if (!strcmp(param, "vmalloc"))
vmalloc_size = round_up(memparse(val, NULL), PAGE_SIZE);
if (!strcmp(param, "noexec")) { if (!strcmp(param, "noexec")) {
rc = kstrtobool(val, &enabled); rc = kstrtobool(val, &enabled);
if (!rc && !enabled) if (!rc && !enabled)
......
...@@ -86,6 +86,7 @@ extern unsigned long zero_page_mask; ...@@ -86,6 +86,7 @@ extern unsigned long zero_page_mask;
*/ */
extern unsigned long VMALLOC_START; extern unsigned long VMALLOC_START;
extern unsigned long VMALLOC_END; extern unsigned long VMALLOC_END;
#define VMALLOC_DEFAULT_SIZE ((128UL << 30) - MODULES_LEN)
extern struct page *vmemmap; extern struct page *vmemmap;
#define VMEM_MAX_PHYS ((unsigned long) vmemmap) #define VMEM_MAX_PHYS ((unsigned long) vmemmap)
......
...@@ -83,6 +83,7 @@ struct parmarea { ...@@ -83,6 +83,7 @@ struct parmarea {
extern int noexec_disabled; extern int noexec_disabled;
extern int memory_end_set; extern int memory_end_set;
extern unsigned long memory_end; extern unsigned long memory_end;
extern unsigned long vmalloc_size;
extern unsigned long max_physmem_end; extern unsigned long max_physmem_end;
#define MACHINE_IS_VM (S390_lowcore.machine_flags & MACHINE_FLAG_VM) #define MACHINE_IS_VM (S390_lowcore.machine_flags & MACHINE_FLAG_VM)
......
...@@ -99,6 +99,7 @@ int __bootdata_preserved(prot_virt_guest); ...@@ -99,6 +99,7 @@ int __bootdata_preserved(prot_virt_guest);
int __bootdata(noexec_disabled); int __bootdata(noexec_disabled);
int __bootdata(memory_end_set); int __bootdata(memory_end_set);
unsigned long __bootdata(memory_end); unsigned long __bootdata(memory_end);
unsigned long __bootdata(vmalloc_size);
unsigned long __bootdata(max_physmem_end); unsigned long __bootdata(max_physmem_end);
struct mem_detect_info __bootdata(mem_detect); struct mem_detect_info __bootdata(mem_detect);
...@@ -302,15 +303,6 @@ void machine_power_off(void) ...@@ -302,15 +303,6 @@ void machine_power_off(void)
void (*pm_power_off)(void) = machine_power_off; void (*pm_power_off)(void) = machine_power_off;
EXPORT_SYMBOL_GPL(pm_power_off); EXPORT_SYMBOL_GPL(pm_power_off);
static int __init parse_vmalloc(char *arg)
{
if (!arg)
return -EINVAL;
VMALLOC_END = (memparse(arg, &arg) + PAGE_SIZE - 1) & PAGE_MASK;
return 0;
}
early_param("vmalloc", parse_vmalloc);
void *restart_stack __section(.data); void *restart_stack __section(.data);
unsigned long stack_alloc(void) unsigned long stack_alloc(void)
...@@ -563,10 +555,9 @@ static void __init setup_resources(void) ...@@ -563,10 +555,9 @@ static void __init setup_resources(void)
static void __init setup_memory_end(void) static void __init setup_memory_end(void)
{ {
unsigned long vmax, vmalloc_size, tmp; unsigned long vmax, tmp;
/* Choose kernel address space layout: 3 or 4 levels. */ /* Choose kernel address space layout: 3 or 4 levels. */
vmalloc_size = VMALLOC_END ?: (128UL << 30) - MODULES_LEN;
if (IS_ENABLED(CONFIG_KASAN)) { if (IS_ENABLED(CONFIG_KASAN)) {
vmax = IS_ENABLED(CONFIG_KASAN_S390_4_LEVEL_PAGING) vmax = IS_ENABLED(CONFIG_KASAN_S390_4_LEVEL_PAGING)
? _REGION1_SIZE ? _REGION1_SIZE
......
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