Lines Matching +full:memory +full:- +full:region
1 // SPDX-License-Identifier: GPL-2.0
3 * This file implements KASLR memory randomization for x86_64. It randomizes
4 * the virtual address space of kernel memory regions (physical memory
11 * The physical memory mapping code was adapted to support P4D/PUD level
13 * 30,000 possible virtual addresses in average for each memory region.
14 * An additional low memory page is used to ensure each CPU can start with
17 * The order of each memory region is not changed. The feature looks at
20 * physical memory mapping is the available physical memory.
44 * Memory regions randomized by KASLR (except modules that use a separate logic
57 /* Get size in bytes used by the memory region */
58 static inline unsigned long get_padding(struct kaslr_memory_region *region) in get_padding() argument
60 return (region->size_tb << TB_SHIFT); in get_padding()
63 /* Initialize base and padding for each memory region randomized with KASLR */
77 * These BUILD_BUG_ON checks ensure the memory layout is consistent in kernel_randomize_memory()
88 kaslr_regions[0].size_tb = 1 << (MAX_PHYSMEM_BITS - TB_SHIFT); in kernel_randomize_memory()
92 * Update Physical memory mapping to available and in kernel_randomize_memory()
93 * add padding if needed (especially for memory hotplug support). in kernel_randomize_memory()
99 /* Adapt physical memory region size based on available memory */ in kernel_randomize_memory()
104 * Calculate the vmemmap region size in TBs, aligned to a TB in kernel_randomize_memory()
107 vmemmap_size = (kaslr_regions[0].size_tb << (TB_SHIFT - PAGE_SHIFT)) * in kernel_randomize_memory()
112 remain_entropy = vaddr_end - vaddr_start; in kernel_randomize_memory()
114 remain_entropy -= get_padding(&kaslr_regions[i]); in kernel_randomize_memory()
116 prandom_seed_state(&rand_state, kaslr_get_random_long("Memory")); in kernel_randomize_memory()
125 entropy = remain_entropy / (ARRAY_SIZE(kaslr_regions) - i); in kernel_randomize_memory()
132 * Jump the region and add a minimum padding based on in kernel_randomize_memory()
137 remain_entropy -= entropy; in kernel_randomize_memory()