Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
arm64/mm: Avoid ID mapping of kpti flag if it is no longer needed
Browse files Browse the repository at this point in the history
arm64_use_ng_mappings will be set to 'true' by the early boot code if it
decides to use non-global (nG) attributes for all kernel mappings,
typically when enabling KASLR on a system that does not implement E0PD.

In this case, the G-to-nG update routines are never called, and so there
is no reason to create the writable mapping of the associated status
flag in the ID map.

Signed-off-by: Ard Biesheuvel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Catalin Marinas <[email protected]>
  • Loading branch information
ardbiesheuvel authored and ctmarinas committed Mar 1, 2024
1 parent 3137db4 commit 27f2b9f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/arm64/mm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ static void __init create_idmap(void)
IDMAP_ROOT_LEVEL, (pte_t *)idmap_pg_dir, false,
__phys_to_virt(ptep) - ptep);

if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0)) {
if (IS_ENABLED(CONFIG_UNMAP_KERNEL_AT_EL0) && !arm64_use_ng_mappings) {
extern u32 __idmap_kpti_flag;
u64 pa = __pa_symbol(&__idmap_kpti_flag);

Expand Down

0 comments on commit 27f2b9f

Please sign in to comment.