|
34 | 34 | #define TB_SHIFT 40
|
35 | 35 |
|
36 | 36 | /*
|
37 |
| - * Virtual address start and end range for randomization. The end changes base |
38 |
| - * on configuration to have the highest amount of space for randomization. |
39 |
| - * It increases the possible random position for each randomized region. |
| 37 | + * Virtual address start and end range for randomization. |
40 | 38 | *
|
41 |
| - * You need to add an if/def entry if you introduce a new memory region |
42 |
| - * compatible with KASLR. Your entry must be in logical order with memory |
43 |
| - * layout. For example, ESPFIX is before EFI because its virtual address is |
44 |
| - * before. You also need to add a BUILD_BUG_ON() in kernel_randomize_memory() to |
45 |
| - * ensure that this order is correct and won't be changed. |
| 39 | + * The end address could depend on more configuration options to make the |
| 40 | + * highest amount of space for randomization available, but that's too hard |
| 41 | + * to keep straight and caused issues already. |
46 | 42 | */
|
47 | 43 | static const unsigned long vaddr_start = __PAGE_OFFSET_BASE;
|
48 |
| - |
49 |
| -#if defined(CONFIG_X86_ESPFIX64) |
50 |
| -static const unsigned long vaddr_end = ESPFIX_BASE_ADDR; |
51 |
| -#elif defined(CONFIG_EFI) |
52 |
| -static const unsigned long vaddr_end = EFI_VA_END; |
53 |
| -#else |
54 |
| -static const unsigned long vaddr_end = __START_KERNEL_map; |
55 |
| -#endif |
| 44 | +static const unsigned long vaddr_end = CPU_ENTRY_AREA_BASE; |
56 | 45 |
|
57 | 46 | /* Default values */
|
58 | 47 | unsigned long page_offset_base = __PAGE_OFFSET_BASE;
|
@@ -101,15 +90,12 @@ void __init kernel_randomize_memory(void)
|
101 | 90 | unsigned long remain_entropy;
|
102 | 91 |
|
103 | 92 | /*
|
104 |
| - * All these BUILD_BUG_ON checks ensures the memory layout is |
105 |
| - * consistent with the vaddr_start/vaddr_end variables. |
| 93 | + * These BUILD_BUG_ON checks ensure the memory layout is consistent |
| 94 | + * with the vaddr_start/vaddr_end variables. These checks are very |
| 95 | + * limited.... |
106 | 96 | */
|
107 | 97 | BUILD_BUG_ON(vaddr_start >= vaddr_end);
|
108 |
| - BUILD_BUG_ON(IS_ENABLED(CONFIG_X86_ESPFIX64) && |
109 |
| - vaddr_end >= EFI_VA_END); |
110 |
| - BUILD_BUG_ON((IS_ENABLED(CONFIG_X86_ESPFIX64) || |
111 |
| - IS_ENABLED(CONFIG_EFI)) && |
112 |
| - vaddr_end >= __START_KERNEL_map); |
| 98 | + BUILD_BUG_ON(vaddr_end != CPU_ENTRY_AREA_BASE); |
113 | 99 | BUILD_BUG_ON(vaddr_end > __START_KERNEL_map);
|
114 | 100 |
|
115 | 101 | if (!kaslr_memory_enabled())
|
|
0 commit comments