[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220607193044.1063287-1-Jason@zx2c4.com>
Date: Tue, 7 Jun 2022 21:30:44 +0200
From: "Jason A. Donenfeld" <Jason@...c4.com>
To: linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>
Cc: "Jason A. Donenfeld" <Jason@...c4.com>,
Stephen Boyd <swboyd@...omium.org>,
Phil Elwell <phil@...pberrypi.com>,
Ard Biesheuvel <ardb@...nel.org>,
Russel King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>
Subject: [PATCH v3] ARM: initialize jump labels before setup_machine_fdt()
Stephen reported that a static key warning splat appears during early
boot on arm64 systems that credit randomness from device trees that
contain an "rng-seed" property, because setup_machine_fdt() is called
before jump_label_init() during setup_arch(), which was fixed by
73e2d827a501 ("arm64: Initialize jump labels before
setup_machine_fdt()").
The same basic issue applies to arm32 as well. So this commit adds a
call to jump_label_init() just before setup_machine_fdt(). Since the
page maps haven't been set yet, this also requires us to use the early
patching code in the jump label code.
Reported-by: Stephen Boyd <swboyd@...omium.org>
Reported-by: Phil Elwell <phil@...pberrypi.com>
Cc: Ard Biesheuvel <ardb@...nel.org>
Cc: Russel King <linux@...linux.org.uk>
Cc: Catalin Marinas <catalin.marinas@....com>
Fixes: f5bda35fba61 ("random: use static branch for crng_ready()")
Signed-off-by: Jason A. Donenfeld <Jason@...c4.com>
---
arch/arm/kernel/jump_label.c | 3 ++-
arch/arm/kernel/setup.c | 1 +
arch/arm/mm/mmu.c | 3 +++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/kernel/jump_label.c b/arch/arm/kernel/jump_label.c
index 303b3ab87f7e..8f8c5312f917 100644
--- a/arch/arm/kernel/jump_label.c
+++ b/arch/arm/kernel/jump_label.c
@@ -8,6 +8,7 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
enum jump_label_type type,
bool is_static)
{
+ extern bool early_mm_initialized;
void *addr = (void *)entry->code;
unsigned int insn;
@@ -16,7 +17,7 @@ static void __arch_jump_label_transform(struct jump_entry *entry,
else
insn = arm_gen_nop();
- if (is_static)
+ if (is_static || !early_mm_initialized)
__patch_text_early(addr, insn);
else
patch_text(addr, insn);
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 1e8a50a97edf..3ff80b1ee0b5 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -1101,6 +1101,7 @@ void __init setup_arch(char **cmdline_p)
atags_vaddr = FDT_VIRT_BASE(__atags_pointer);
setup_processor();
+ jump_label_init();
if (atags_vaddr) {
mdesc = setup_machine_fdt(atags_vaddr);
if (mdesc)
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 5e2be37a198e..3f63a5581966 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1754,10 +1754,13 @@ void __init paging_init(const struct machine_desc *mdesc)
__flush_dcache_page(NULL, empty_zero_page);
}
+bool early_mm_initialized;
+
void __init early_mm_init(const struct machine_desc *mdesc)
{
build_mem_type_table();
early_paging_init(mdesc);
+ early_mm_initialized = true;
}
void set_pte_at(struct mm_struct *mm, unsigned long addr,
--
2.35.1
Powered by blists - more mailing lists