init.c (3daee2e4b3568f0ed88b0598df96547fcf21cb9b) | init.c (945302df3de156fc367d3b537cec76d4aea0b0d1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 * Copyright (C) 2019 Western Digital Corporation or its affiliates. 5 * Copyright (C) 2020 FORTH-ICS/CARV 6 * Nick Kossifidis <mick@ics.forth.gr> 7 */ 8 --- 236 unchanged lines hidden (view full) --- 245 /* 246 * In 64-bit, any use of __va/__pa before this point is wrong as we 247 * did not know the start of DRAM before. 248 */ 249 if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU)) 250 kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base; 251 252 /* | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 Regents of the University of California 4 * Copyright (C) 2019 Western Digital Corporation or its affiliates. 5 * Copyright (C) 2020 FORTH-ICS/CARV 6 * Nick Kossifidis <mick@ics.forth.gr> 7 */ 8 --- 236 unchanged lines hidden (view full) --- 245 /* 246 * In 64-bit, any use of __va/__pa before this point is wrong as we 247 * did not know the start of DRAM before. 248 */ 249 if (IS_ENABLED(CONFIG_64BIT) && IS_ENABLED(CONFIG_MMU)) 250 kernel_map.va_pa_offset = PAGE_OFFSET - phys_ram_base; 251 252 /* |
253 * Reserve physical address space that would be mapped to virtual 254 * addresses greater than (void *)(-PAGE_SIZE) because: 255 * - This memory would overlap with ERR_PTR 256 * - This memory belongs to high memory, which is not supported 257 * 258 * This is not applicable to 64-bit kernel, because virtual addresses 259 * after (void *)(-PAGE_SIZE) are not linearly mapped: they are 260 * occupied by kernel mapping. Also it is unrealistic for high memory 261 * to exist on 64-bit platforms. | 253 * memblock allocator is not aware of the fact that last 4K bytes of 254 * the addressable memory can not be mapped because of IS_ERR_VALUE 255 * macro. Make sure that last 4k bytes are not usable by memblock 256 * if end of dram is equal to maximum addressable memory. For 64-bit 257 * kernel, this problem can't happen here as the end of the virtual 258 * address space is occupied by the kernel mapping then this check must 259 * be done as soon as the kernel mapping base address is determined. |
262 */ 263 if (!IS_ENABLED(CONFIG_64BIT)) { | 260 */ 261 if (!IS_ENABLED(CONFIG_64BIT)) { |
264 max_mapped_addr = __va_to_pa_nodebug(-PAGE_SIZE); 265 memblock_reserve(max_mapped_addr, (phys_addr_t)-max_mapped_addr); | 262 max_mapped_addr = __pa(~(ulong)0); 263 if (max_mapped_addr == (phys_ram_end - 1)) 264 memblock_set_current_limit(max_mapped_addr - 4096); |
266 } 267 268 min_low_pfn = PFN_UP(phys_ram_base); 269 max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end); 270 high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); 271 272 dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn)); 273 set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET); --- 764 unchanged lines hidden (view full) --- 1038 pt_ops.alloc_p4d = alloc_p4d_late; 1039 pt_ops.get_p4d_virt = get_p4d_virt_late; 1040#endif 1041} 1042 1043#ifdef CONFIG_RANDOMIZE_BASE 1044extern bool __init __pi_set_nokaslr_from_cmdline(uintptr_t dtb_pa); 1045extern u64 __init __pi_get_kaslr_seed(uintptr_t dtb_pa); | 265 } 266 267 min_low_pfn = PFN_UP(phys_ram_base); 268 max_low_pfn = max_pfn = PFN_DOWN(phys_ram_end); 269 high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); 270 271 dma32_phys_limit = min(4UL * SZ_1G, (unsigned long)PFN_PHYS(max_low_pfn)); 272 set_max_mapnr(max_low_pfn - ARCH_PFN_OFFSET); --- 764 unchanged lines hidden (view full) --- 1037 pt_ops.alloc_p4d = alloc_p4d_late; 1038 pt_ops.get_p4d_virt = get_p4d_virt_late; 1039#endif 1040} 1041 1042#ifdef CONFIG_RANDOMIZE_BASE 1043extern bool __init __pi_set_nokaslr_from_cmdline(uintptr_t dtb_pa); 1044extern u64 __init __pi_get_kaslr_seed(uintptr_t dtb_pa); |
1045extern u64 __init __pi_get_kaslr_seed_zkr(const uintptr_t dtb_pa); |
|
1046 1047static int __init print_nokaslr(char *p) 1048{ 1049 pr_info("Disabled KASLR"); 1050 return 0; 1051} 1052early_param("nokaslr", print_nokaslr); 1053 --- 4 unchanged lines hidden (view full) --- 1058#endif 1059 1060asmlinkage void __init setup_vm(uintptr_t dtb_pa) 1061{ 1062 pmd_t __maybe_unused fix_bmap_spmd, fix_bmap_epmd; 1063 1064#ifdef CONFIG_RANDOMIZE_BASE 1065 if (!__pi_set_nokaslr_from_cmdline(dtb_pa)) { | 1046 1047static int __init print_nokaslr(char *p) 1048{ 1049 pr_info("Disabled KASLR"); 1050 return 0; 1051} 1052early_param("nokaslr", print_nokaslr); 1053 --- 4 unchanged lines hidden (view full) --- 1058#endif 1059 1060asmlinkage void __init setup_vm(uintptr_t dtb_pa) 1061{ 1062 pmd_t __maybe_unused fix_bmap_spmd, fix_bmap_epmd; 1063 1064#ifdef CONFIG_RANDOMIZE_BASE 1065 if (!__pi_set_nokaslr_from_cmdline(dtb_pa)) { |
1066 u64 kaslr_seed = __pi_get_kaslr_seed(dtb_pa); | 1066 u64 kaslr_seed = __pi_get_kaslr_seed_zkr(dtb_pa); |
1067 u32 kernel_size = (uintptr_t)(&_end) - (uintptr_t)(&_start); 1068 u32 nr_pos; 1069 | 1067 u32 kernel_size = (uintptr_t)(&_end) - (uintptr_t)(&_start); 1068 u32 nr_pos; 1069 |
1070 if (kaslr_seed == 0) 1071 kaslr_seed = __pi_get_kaslr_seed(dtb_pa); |
|
1070 /* 1071 * Compute the number of positions available: we are limited 1072 * by the early page table that only has one PUD and we must 1073 * be aligned on PMD_SIZE. 1074 */ 1075 nr_pos = (PUD_SIZE - kernel_size) / PMD_SIZE; 1076 1077 kernel_map.virt_offset = (kaslr_seed % nr_pos) * PMD_SIZE; --- 459 unchanged lines hidden --- | 1072 /* 1073 * Compute the number of positions available: we are limited 1074 * by the early page table that only has one PUD and we must 1075 * be aligned on PMD_SIZE. 1076 */ 1077 nr_pos = (PUD_SIZE - kernel_size) / PMD_SIZE; 1078 1079 kernel_map.virt_offset = (kaslr_seed % nr_pos) * PMD_SIZE; --- 459 unchanged lines hidden --- |