Skip to content

Commit

Permalink
arm64: idreg-override: use early FDT mapping in ID map
Browse files Browse the repository at this point in the history
Instead of calling into the kernel to map the FDT into the kernel page
tables before even calling start_kernel(), let's switch to the initial,
temporary mapping of the device tree that has been added to the ID map.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20220624150651.1358849-16-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
  • Loading branch information
Ard Biesheuvel authored and Will Deacon committed Jun 24, 2022
1 parent f70b3a2 commit a004393
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
1 change: 1 addition & 0 deletions arch/arm64/kernel/head.S
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ SYM_FUNC_START_LOCAL(__primary_switched)
#endif
mov x0, x21 // pass FDT address in x0
bl early_fdt_map // Try mapping the FDT early
mov x0, x22 // pass FDT address in x0
bl init_feature_override // Parse cpu feature overrides
#ifdef CONFIG_RANDOMIZE_BASE
tst x23, ~(MIN_KIMG_ALIGN - 1) // already running randomized?
Expand Down
17 changes: 6 additions & 11 deletions arch/arm64/kernel/idreg-override.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,11 @@ static __init void __parse_cmdline(const char *cmdline, bool parse_aliases)
} while (1);
}

static __init const u8 *get_bootargs_cmdline(void)
static __init const u8 *get_bootargs_cmdline(const void *fdt)
{
const u8 *prop;
void *fdt;
int node;

fdt = get_early_fdt_ptr();
if (!fdt)
return NULL;

node = fdt_path_offset(fdt, "/chosen");
if (node < 0)
return NULL;
Expand All @@ -222,9 +217,9 @@ static __init const u8 *get_bootargs_cmdline(void)
return strlen(prop) ? prop : NULL;
}

static __init void parse_cmdline(void)
static __init void parse_cmdline(const void *fdt)
{
const u8 *prop = get_bootargs_cmdline();
const u8 *prop = get_bootargs_cmdline(fdt);

if (IS_ENABLED(CONFIG_CMDLINE_FORCE) || !prop)
__parse_cmdline(CONFIG_CMDLINE, true);
Expand All @@ -234,9 +229,9 @@ static __init void parse_cmdline(void)
}

/* Keep checkers quiet */
void init_feature_override(void);
void init_feature_override(const void *fdt);

asmlinkage void __init init_feature_override(void)
asmlinkage void __init init_feature_override(const void *fdt)
{
int i;

Expand All @@ -247,7 +242,7 @@ asmlinkage void __init init_feature_override(void)
}
}

parse_cmdline();
parse_cmdline(fdt);

for (i = 0; i < ARRAY_SIZE(regs); i++) {
if (regs[i]->override)
Expand Down

0 comments on commit a004393

Please sign in to comment.