Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

arm64: mm: Make map_fdt() return mapped pointer

Currently map_fdt() accepts a physical address and relies on the caller
to keep using the same value after mapping, since the implementation
happens to install an identity mapping. This obscures the fact that the
usable pointer is defined by the mapping, not by the input value. Since
the mapping determines pointer validity, it is more natural to produce
the pointer at mapping time.

Change map_fdt() to return a void * pointing to the mapped FDT. This
clarifies the data flow, removes the implicit identity assumption, and
prepares for making map_fdt() accept a phys_addr_t in a follow-up
change.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Signed-off-by: Will Deacon <will@kernel.org>

authored by

Sam Edwards and committed by
Will Deacon
c56aa9a6 030b3ffb

+7 -6
+7 -6
arch/arm64/kernel/pi/map_kernel.c
··· 191 191 memset(init_pg_dir, 0, (char *)init_pg_end - (char *)init_pg_dir); 192 192 } 193 193 194 - static void __init map_fdt(u64 fdt) 194 + static void *__init map_fdt(u64 fdt) 195 195 { 196 196 static u8 ptes[INIT_IDMAP_FDT_SIZE] __initdata __aligned(PAGE_SIZE); 197 197 u64 efdt = fdt + MAX_FDT_SIZE; ··· 205 205 fdt, PAGE_KERNEL, IDMAP_ROOT_LEVEL, 206 206 (pte_t *)init_idmap_pg_dir, false, 0); 207 207 dsb(ishst); 208 + 209 + return (void *)fdt; 208 210 } 209 211 210 212 /* ··· 240 238 int root_level = 4 - CONFIG_PGTABLE_LEVELS; 241 239 int va_bits = VA_BITS; 242 240 int chosen; 243 - 244 - map_fdt((u64)fdt); 241 + void *fdt_mapped = map_fdt((u64)fdt); 245 242 246 243 /* Clear BSS and the initial page tables */ 247 244 memset(__bss_start, 0, (char *)init_pg_end - (char *)__bss_start); 248 245 249 246 /* Parse the command line for CPU feature overrides */ 250 - chosen = fdt_path_offset(fdt, chosen_str); 251 - init_feature_override(boot_status, fdt, chosen); 247 + chosen = fdt_path_offset(fdt_mapped, chosen_str); 248 + init_feature_override(boot_status, fdt_mapped, chosen); 252 249 253 250 if (IS_ENABLED(CONFIG_ARM64_64K_PAGES) && !cpu_has_lva()) { 254 251 va_bits = VA_BITS_MIN; ··· 267 266 * fill in the high bits from the seed. 268 267 */ 269 268 if (IS_ENABLED(CONFIG_RANDOMIZE_BASE)) { 270 - u64 kaslr_seed = kaslr_early_init(fdt, chosen); 269 + u64 kaslr_seed = kaslr_early_init(fdt_mapped, chosen); 271 270 272 271 if (kaslr_seed && kaslr_requires_kpti()) 273 272 arm64_use_ng_mappings = ng_mappings_allowed();