From: Felix Fu fuzhen5@huawei.com
Felix Fu (7): kaslr: add nokaslr memory region Kconfig support efi/libstub: arm64: Add kaslr skip memmap kconfig support efi/libstub: arm64: support strchr function for EFI stub efi/libstub: add arm64 kaslr memory region avoid support efi/libstub: arm64: Add macro isolation memmap detection code efi/libstub: add arm64 nokaslr memory regions x86/boot: add x86 nokaslr memory regions
arch/arm64/Kconfig | 12 ++ arch/x86/boot/compressed/kaslr.c | 41 +++++ drivers/firmware/efi/libstub/arm64-stub.c | 173 ++++++++++++++++++ .../firmware/efi/libstub/efi-stub-helper.c | 11 +- drivers/firmware/efi/libstub/efistub.h | 14 ++ drivers/firmware/efi/libstub/randomalloc.c | 11 +- drivers/firmware/efi/libstub/string.c | 19 ++ init/Kconfig | 8 + 8 files changed, 286 insertions(+), 3 deletions(-)
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
add Kconfig NOKASLR_MEM_RANGE support. allow users to mark at most 4 memory regions as unavailable for kaslr
Signed-off-by: Felix Fu fuzhen5@huawei.com --- init/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/init/Kconfig b/init/Kconfig index 9209fc5b39b9..732f2a32cc08 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -2037,3 +2037,11 @@ config ARCH_HAS_SYNC_CORE_BEFORE_USERMODE # <asm/syscall_wrapper.h>. config ARCH_HAS_SYSCALL_WRAPPER def_bool n + +config NOKASLR_MEM_RANGE + bool "Allow users to mark at most 4 memory regions as unavailable for kaslr" + depends on RANDOMIZE_BASE + default n + help + Say y here and add kernel parameters as nokaslr=nn[KMG]-ss[KMG] to avoid kaslr + place kernel image in such memory regions \ No newline at end of file
From: Felix Fu fuzhen5@huawei.com
Offering: HULK hulk inclusion category: feature bugzilla: 187985
--------------------------------
Kaslr will randomizes the physical address at which the kernel image is loaded, we will check and skip the memmap reserved memory, add config CONFIG_UEFI_KASLR_SKIP_MEMMAP to isolation memmap detection code.
Signed-off-by: Gaosheng Cui cuigaosheng1@huawei.com Signed-off-by: Felix Fu fuzhen5@huawei.com --- arch/arm64/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 2aca373a7038..c7985826c51b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2246,6 +2246,18 @@ config RANDOMIZE_MODULE_REGION_FULL the region is exhausted. In this particular case of region exhaustion, modules might be able to fall back to a larger 2GB area.
+config UEFI_KASLR_SKIP_MEMMAP + bool "Skip the memmap address when randomize the kernel image" + depends on RANDOMIZE_BASE + default n + help + Memmap kernel parameter are described by the memmap=nn[KMG]$ss[KMG], + Region of memory to be reserved is from ss to ss+nn, the region must + be in the range of existed memory, otherwise will be ignored. Teach + KASLR to not insert the kernel in memmap defined regions. We support + up to 32 memmap regions: any additional regions will cause KASLR to + disable. + config CC_HAVE_STACKPROTECTOR_SYSREG def_bool $(cc-option,-mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=0)
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
Kaslr will randomizes the physical address at which the kernel image is loaded, we will check and skip the memmap reserved memory, add config CONFIG_UEFI_KASLR_SKIP_MEMMAP to isolation memmap detection code.
Signed-off-by: Gaosheng Cui cuigaosheng1@huawei.com Signed-off-by: Felix Fu fuzhen5@huawei.com --- arch/arm64/Kconfig | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 2aca373a7038..c7985826c51b 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -2246,6 +2246,18 @@ config RANDOMIZE_MODULE_REGION_FULL the region is exhausted. In this particular case of region exhaustion, modules might be able to fall back to a larger 2GB area.
+config UEFI_KASLR_SKIP_MEMMAP + bool "Skip the memmap address when randomize the kernel image" + depends on RANDOMIZE_BASE + default n + help + Memmap kernel parameter are described by the memmap=nn[KMG]$ss[KMG], + Region of memory to be reserved is from ss to ss+nn, the region must + be in the range of existed memory, otherwise will be ignored. Teach + KASLR to not insert the kernel in memmap defined regions. We support + up to 32 memmap regions: any additional regions will cause KASLR to + disable. + config CC_HAVE_STACKPROTECTOR_SYSREG def_bool $(cc-option,-mstack-protector-guard=sysreg -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=0)
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
support strchr function for EFI stub, it will be used to parse cmdline args.
Signed-off-by: Gaosheng Cui cuigaosheng1@huawei.com Signed-off-by: Felix Fu fuzhen5@huawei.com --- drivers/firmware/efi/libstub/string.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
diff --git a/drivers/firmware/efi/libstub/string.c b/drivers/firmware/efi/libstub/string.c index 168fe8e79abc..c7b996297826 100644 --- a/drivers/firmware/efi/libstub/string.c +++ b/drivers/firmware/efi/libstub/string.c @@ -202,3 +202,22 @@ void *memchr(const void *s, int c, size_t n) } #endif #endif +#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE) +#ifndef EFI_HAVE_STRCHR +/** + * strchr - Find the first occurrence of a character in a string + * @s: The string to be searched + * @c: The character to search for + * + * Note that the %NUL-terminator is considered part of the string, and can + * be searched for. + */ +char *strchr(const char *s, int c) +{ + for (; *s != (char)c; ++s) + if (*s == '\0') + return NULL; + return (char *)s; +} +#endif +#endif \ No newline at end of file
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
Add arm64 kaslr memory region avoid support code, this patch refer to the kaslr avoid mem region code structure of x86.
Signed-off-by: Felix Fu fuzhen5@huawei.com --- drivers/firmware/efi/libstub/arm64-stub.c | 89 ++++++++++++++++++++++ drivers/firmware/efi/libstub/efistub.h | 8 ++ drivers/firmware/efi/libstub/randomalloc.c | 11 ++- 3 files changed, 106 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c index 452b7ccd330e..d3caecd874b2 100644 --- a/drivers/firmware/efi/libstub/arm64-stub.c +++ b/drivers/firmware/efi/libstub/arm64-stub.c @@ -14,6 +14,95 @@
#include "efistub.h"
+#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE) +enum mem_avoid_index { + MEM_AVOID_MAX, +}; + +struct mem_vector { + unsigned long long start; + unsigned long long size; +}; + +static struct mem_vector mem_avoid[MEM_AVOID_MAX]; + +static bool mem_overlaps(struct mem_vector *one, struct mem_vector *two) +{ + if (one->start + one->size <= two->start) + return false; + if (one->start >= two->start + two->size) + return false; + return true; +} + +static bool mem_avoid_overlap(struct mem_vector *region, struct mem_vector *overlap) +{ + int i; + u64 earliest = region->start + region->size; + bool is_overlapping = false; + + for (i = 0; i < MEM_AVOID_MAX; i++) { + if (mem_overlaps(region, &mem_avoid[i]) && + mem_avoid[i].start < earliest) { + *overlap = mem_avoid[i]; + earliest = overlap->start; + is_overlapping = true; + } + } + return is_overlapping; +} + +unsigned long cal_slots_avoid_overlap(efi_memory_desc_t *md, unsigned long size, u8 cal_type, + unsigned long align_shift, unsigned long target) +{ + struct mem_vector region, overlap; + unsigned long region_end, first, last; + unsigned long align = 1UL << align_shift; + unsigned long total_slots = 0, slots; + + region.start = md->phys_addr; + region_end = min(md->phys_addr + md->num_pages * EFI_PAGE_SIZE - 1, (u64)ULONG_MAX); + + while (region.start < region_end) { + first = round_up(region.start, align); + last = round_down(region_end - size + 1, align); + + if (first > last) + break; + + region.size = region_end - region.start + 1; + + if (!mem_avoid_overlap(®ion, &overlap)) { + slots = ((last - first) >> align_shift) + 1; + total_slots += slots; + + if (cal_type == CAL_SLOTS_PHYADDR) + return first + target * align; + + break; + } + + if (overlap.start >= region.start + size) { + slots = ((round_up(overlap.start - size + 1, align) - first) >> + align_shift) + 1; + total_slots += slots; + + if (cal_type == CAL_SLOTS_PHYADDR) { + if (target > slots) + target -= slots; + else + return first + target * align; + } + } + + /* Clip off the overlapping region and start over. */ + region.start = overlap.start + overlap.size; + } + + return total_slots; +} +#endif + efi_status_t handle_kernel_image(unsigned long *image_addr, unsigned long *image_size, unsigned long *reserve_addr, diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 212687c30d79..33cf4ab1faed 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -1000,6 +1000,14 @@ efi_status_t efi_parse_options(char const *cmdline);
void efi_parse_option_graphics(char *option);
+#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE) +#define CAL_SLOTS_NUMBER 0 +#define CAL_SLOTS_PHYADDR 1 + +unsigned long cal_slots_avoid_overlap(efi_memory_desc_t *md, unsigned long size, u8 cal_type, + unsigned long align_shift, unsigned long target); +#endif + efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, unsigned long size);
diff --git a/drivers/firmware/efi/libstub/randomalloc.c b/drivers/firmware/efi/libstub/randomalloc.c index 674a064b8f7a..48bf6903017f 100644 --- a/drivers/firmware/efi/libstub/randomalloc.c +++ b/drivers/firmware/efi/libstub/randomalloc.c @@ -39,8 +39,11 @@ static unsigned long get_entry_num_slots(efi_memory_desc_t *md,
if (first_slot > last_slot) return 0; - +#if defined(CONFIG_ARM64) && (defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE)) + return cal_slots_avoid_overlap(md, size, CAL_SLOTS_NUMBER, align_shift, 0); +#else return ((unsigned long)(last_slot - first_slot) >> align_shift) + 1; +#endif }
/* @@ -117,8 +120,12 @@ efi_status_t efi_random_alloc(unsigned long size, target_slot -= MD_NUM_SLOTS(md); continue; } - +#if defined(CONFIG_ARM64) && (defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE)) + target = cal_slots_avoid_overlap(md, size, CAL_SLOTS_PHYADDR, ilog2(align), + target_slot); +#else target = round_up(md->phys_addr, align) + target_slot * align; +#endif pages = size / EFI_PAGE_SIZE;
status = efi_bs_call(allocate_pages, EFI_ALLOCATE_ADDRESS,
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
Kaslr will randomizes the physical address at which the kernel image is loaded, we will check and skip the memmap reserved memory.
Signed-off-by: Gaosheng Cui cuigaosheng1@huawei.com Signed-off-by: Felix Fu fuzhen5@huawei.com --- drivers/firmware/efi/libstub/arm64-stub.c | 42 +++++++++++++++++++ .../firmware/efi/libstub/efi-stub-helper.c | 4 ++ drivers/firmware/efi/libstub/efistub.h | 3 ++ 3 files changed, 49 insertions(+)
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c index d3caecd874b2..ca54333ece32 100644 --- a/drivers/firmware/efi/libstub/arm64-stub.c +++ b/drivers/firmware/efi/libstub/arm64-stub.c @@ -14,8 +14,16 @@
#include "efistub.h"
+#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP +#define MAX_MEMMAP_REGIONS 32 +#endif + #if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE) enum mem_avoid_index { +#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP + MAX_MEMMAP_REGIONS_BEGIN = 0, + MAX_MEMMAP_REGIONS_END = MAX_MEMMAP_REGIONS_BEGIN + MAX_MEMMAP_REGIONS - 1, +#endif MEM_AVOID_MAX, };
@@ -103,6 +111,40 @@ unsigned long cal_slots_avoid_overlap(efi_memory_desc_t *md, unsigned long size, } #endif
+#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP +void mem_avoid_memmap(char *str) +{ + static int i; + + while (str && (i < MAX_MEMMAP_REGIONS)) { + char *oldstr; + u64 start, size; + char *k = strchr(str, ','); + + if (k) + *k++ = 0; + + oldstr = str; + size = memparse(str, &str); + if (str == oldstr || *str != '$') { + efi_warn("memap values error.\n"); + break; + } + + start = memparse(str + 1, &str); + if (size <= 0) { + efi_warn("memap values error, size should be more than 0.\n"); + break; + } + + mem_avoid[MAX_MEMMAP_REGIONS_BEGIN + i].start = start; + mem_avoid[MAX_MEMMAP_REGIONS_BEGIN + i].size = size; + str = k; + i++; + } +} +#endif + efi_status_t handle_kernel_image(unsigned long *image_addr, unsigned long *image_size, unsigned long *reserve_addr, diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index bfa30625f5d0..70ae49aefbee 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -91,6 +91,10 @@ efi_status_t efi_parse_options(char const *cmdline) } else if (!strcmp(param, "video") && val && strstarts(val, "efifb:")) { efi_parse_option_graphics(val + strlen("efifb:")); +#ifdef CONFIG_UEFI_KASLR_SKIP_MEMMAP + } else if (!strcmp(param, "memmap") && val) { + mem_avoid_memmap(val); +#endif } } efi_bs_call(free_pool, buf); diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 33cf4ab1faed..344b38b0cee8 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -1007,6 +1007,9 @@ void efi_parse_option_graphics(char *option); unsigned long cal_slots_avoid_overlap(efi_memory_desc_t *md, unsigned long size, u8 cal_type, unsigned long align_shift, unsigned long target); #endif +#if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP +void mem_avoid_memmap(char *str); +#endif
efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, unsigned long size);
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
allow users to mark at most 4 regions as not available for kaslr
Signed-off-by: Felix Fu fuzhen5@huawei.com --- drivers/firmware/efi/libstub/arm64-stub.c | 44 ++++++++++++++++++- .../firmware/efi/libstub/efi-stub-helper.c | 7 ++- drivers/firmware/efi/libstub/efistub.h | 3 ++ 3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/drivers/firmware/efi/libstub/arm64-stub.c b/drivers/firmware/efi/libstub/arm64-stub.c index ca54333ece32..e71dc57daa99 100644 --- a/drivers/firmware/efi/libstub/arm64-stub.c +++ b/drivers/firmware/efi/libstub/arm64-stub.c @@ -18,11 +18,19 @@ #define MAX_MEMMAP_REGIONS 32 #endif
+#ifdef CONFIG_NOKASLR_MEM_RANGE +#define MAX_MEM_NOKASLR_REGIONS 4 +#endif + #if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP || defined(CONFIG_NOKASLR_MEM_RANGE) enum mem_avoid_index { #if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP MAX_MEMMAP_REGIONS_BEGIN = 0, MAX_MEMMAP_REGIONS_END = MAX_MEMMAP_REGIONS_BEGIN + MAX_MEMMAP_REGIONS - 1, +#endif +#ifdef CONFIG_NOKASLR_MEM_RANGE + MEM_AVOID_MEM_NOKASLR_BEGIN, + MEM_AVOID_MEM_NOKASLR_END = MEM_AVOID_MEM_NOKASLR_BEGIN + MAX_MEM_NOKASLR_REGIONS - 1, #endif MEM_AVOID_MAX, }; @@ -103,7 +111,7 @@ unsigned long cal_slots_avoid_overlap(efi_memory_desc_t *md, unsigned long size, } }
- /* Clip off the overlapping region and start over. */ + /* Clip off the overlapping region and start over.*/ region.start = overlap.start + overlap.size; }
@@ -145,6 +153,40 @@ void mem_avoid_memmap(char *str) } #endif
+#if defined CONFIG_NOKASLR_MEM_RANGE +void mem_avoid_mem_nokaslr(char *str) +{ + int i = 0; + + while (str && (i < MAX_MEM_NOKASLR_REGIONS)) { + char *oldstr; + u64 start, end; + char *k = strchr(str, ','); + + if (k) + *k++ = 0; + + oldstr = str; + start = memparse(str, &str); + if (str == oldstr || *str != '-') { + efi_warn("nokaslr values error.\n"); + break; + } + + end = memparse(str + 1, &str); + if (start >= end) { + efi_warn("nokaslr values error, start should be less than end.\n"); + break; + } + + mem_avoid[MEM_AVOID_MEM_NOKASLR_BEGIN + i].start = start; + mem_avoid[MEM_AVOID_MEM_NOKASLR_BEGIN + i].size = end - start; + str = k; + i++; + } +} +#endif + efi_status_t handle_kernel_image(unsigned long *image_addr, unsigned long *image_size, unsigned long *reserve_addr, diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 70ae49aefbee..37c80be133f6 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -68,7 +68,12 @@ efi_status_t efi_parse_options(char const *cmdline) break;
if (!strcmp(param, "nokaslr")) { - efi_nokaslr = true; +#if defined(CONFIG_NOKASLR_MEM_RANGE) && defined(CONFIG_ARM64) + if (val) + mem_avoid_mem_nokaslr(val); + else +#endif + efi_nokaslr = true; } else if (!strcmp(param, "quiet")) { efi_loglevel = CONSOLE_LOGLEVEL_QUIET; } else if (!strcmp(param, "noinitrd")) { diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 344b38b0cee8..ff79a01d145c 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -1010,6 +1010,9 @@ unsigned long cal_slots_avoid_overlap(efi_memory_desc_t *md, unsigned long size, #if defined CONFIG_UEFI_KASLR_SKIP_MEMMAP void mem_avoid_memmap(char *str); #endif +#if defined CONFIG_NOKASLR_MEM_RANGE && defined(CONFIG_ARM64) +void mem_avoid_mem_nokaslr(char *str); +#endif
efi_status_t efi_setup_gop(struct screen_info *si, efi_guid_t *proto, unsigned long size);
From: Felix Fu fuzhen5@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8RJ1I CVE: NA
--------------------------------
allow users to mark at most 4 regions as not available for kaslr
Signed-off-by: Felix Fu fuzhen5@huawei.com --- arch/x86/boot/compressed/kaslr.c | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c index 9193acf0e9cd..eb4d9c5cbcac 100644 --- a/arch/x86/boot/compressed/kaslr.c +++ b/arch/x86/boot/compressed/kaslr.c @@ -94,6 +94,10 @@ enum mem_avoid_index { MEM_AVOID_BOOTPARAMS, MEM_AVOID_MEMMAP_BEGIN, MEM_AVOID_MEMMAP_END = MEM_AVOID_MEMMAP_BEGIN + MAX_MEMMAP_REGIONS - 1, +#ifdef CONFIG_NOKASLR_MEM_RANGE + MEM_AVOID_MEM_NOKASLR_BEGIN, + MEM_AVOID_MEM_NOKASLR_END = MEM_AVOID_MEM_NOKASLR_BEGIN + MAX_MEM_NOKASLR_REGIONS - 1, +#endif MEM_AVOID_MAX, };
@@ -223,6 +227,39 @@ static void mem_avoid_memmap(enum parse_mode mode, char *str) memmap_too_large = true; }
+#ifdef CONFIG_NOKASLR_MEM_RANGE +static void mem_avoid_mem_nokaslr(char *str) +{ + int i = 0; + + while (str && (i < MAX_MEM_NOKASLR_REGIONS)) { + char *oldstr; + u64 start, end; + char *k = strchr(str, ','); + + if (k) + *k++ = 0; + + oldstr = str; + start = memparse(str, &str); + if (str == oldstr || *str != '-') { + warn("Nokaslr values error.\n"); + break; + } + + end = memparse(str + 1, &str); + if (start >= end) { + warn("Nokaslr values error, start should be less than end.\n"); + break; + } + + mem_avoid[MEM_AVOID_MEM_NOKASLR_BEGIN + i].start = start; + mem_avoid[MEM_AVOID_MEM_NOKASLR_BEGIN + i].size = end - start; + str = k; + i++; + } +} +#endif /* Store the number of 1GB huge pages which users specified: */ static unsigned long max_gb_huge_pages;
@@ -298,6 +335,10 @@ static void handle_mem_options(void) } else if (!strcmp(param, "efi_fake_mem")) { mem_avoid_memmap(PARSE_EFI, val); } +#ifdef CONFIG_NOKASLR_MEM_RANGE + else if (!strcmp(param, "nokaslr") && val) + mem_avoid_mem_nokaslr(val); +#endif }
free(tmp_cmdline);