diff --git a/patch/kernel/archive/sunxi-6.1/arm-patch-call-patch_unmap-after-flushing-dcache-and-icache.patch b/patch/kernel/archive/sunxi-6.1/arm-patch-call-patch_unmap-after-flushing-dcache-and-icache.patch new file mode 100644 index 0000000000..9fe4232dad --- /dev/null +++ b/patch/kernel/archive/sunxi-6.1/arm-patch-call-patch_unmap-after-flushing-dcache-and-icache.patch @@ -0,0 +1,52 @@ +From 3d499ba2dce4ac8716f2c9bb07f66f45d0555a19 Mon Sep 17 00:00:00 2001 +From: The-going <48602507+The-going@users.noreply.github.com> +Date: Fri, 12 Jul 2024 14:20:15 +0300 +Subject: arm: patch: call 'patch_unmap' after flushing dcache and icache + +Problem: Linux kernel hangs in early boot on 32-bit ARM platform, +when ftrace 4-byte "mcount" function call location for +"_raw_spin_unlock_irqrestore" function straddles icache lines. + +1. The ftrace location for "_raw_spin_unlock_irqrestore" is NOT + 4-byte aligned and 4 bytes at this location straddle the instruction + cache line (0x20) boundaries. + +The problem is present for (cross-compiler) GCC 10, 11, 12. +It does not happen when the kernel is compiled with GCC 9, +even when condition (1) is satisfied. + +Detailed description: +https://forum.armbian.com/topic/41339-linux-image-legacy-sunxi2451-kernel-6192-is-broken-stuck-at-starting-kernel/?do=findComment&comment=196528 + +Author: @mikhailai +--- + arch/arm/kernel/patch.c | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c +index e9e828b6bb30..ce0fd3aeb575 100644 +--- a/arch/arm/kernel/patch.c ++++ b/arch/arm/kernel/patch.c +@@ -101,11 +101,18 @@ void __kprobes __patch_text_real(void *addr, unsigned int insn, bool remap) + + if (waddr != addr) { + flush_kernel_vmap_range(waddr, twopage ? size / 2 : size); +- patch_unmap(FIX_TEXT_POKE0, &flags); + } + + flush_icache_range((uintptr_t)(addr), + (uintptr_t)(addr) + size); ++ ++ /* Can only call 'patch_unmap' after flushing dcache and icache, ++ * because it calls 'raw_spin_unlock_irqrestore', but that may ++ * happen to be the very function we're currently patching ++ * (as it happens during the ftrace init). ++ */ ++ if (waddr != addr) ++ patch_unmap(FIX_TEXT_POKE0, &flags); + } + + static int __kprobes patch_text_stop_machine(void *data) +-- +2.35.3 + diff --git a/patch/kernel/archive/sunxi-6.1/patches.armbian/random-Revert-handle-entropy-from-atomic-process-con.patch b/patch/kernel/archive/sunxi-6.1/patches.armbian/random-Revert-handle-entropy-from-atomic-process-con.patch deleted file mode 100644 index 93ab62cc81..0000000000 --- a/patch/kernel/archive/sunxi-6.1/patches.armbian/random-Revert-handle-entropy-from-atomic-process-con.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 25ba88c95e844f900f5603890eaab8d19792a6a8 Mon Sep 17 00:00:00 2001 -From: The-going <48602507+The-going@users.noreply.github.com> -Date: Sun, 7 Jul 2024 10:39:48 +0300 -Subject: [PATCH] random: Revert: handle entropy from atomic process context - -Revert 07b37f227c8daa27e68f57b1c691fab34a06731e commit -For the sunxi architecture, this commit results in -an inability to load the kernel. It's actually a crutch -that can break everything tomorrow. -Therefore, freeze the kernel version for better times. ---- - drivers/char/random.c | 10 +++++----- - 1 file changed, 5 insertions(+), 5 deletions(-) - -diff --git a/drivers/char/random.c b/drivers/char/random.c -index fd57eb372..5d1c8e1c9 100644 ---- a/drivers/char/random.c -+++ b/drivers/char/random.c -@@ -683,7 +683,7 @@ static void extract_entropy(void *buf, size_t len) - - static void __cold _credit_init_bits(size_t bits) - { -- static DECLARE_WORK(set_ready, crng_set_ready); -+ static struct execute_work set_ready; - unsigned int new, orig, add; - unsigned long flags; - -@@ -699,8 +699,8 @@ static void __cold _credit_init_bits(size_t bits) - - if (orig < POOL_READY_BITS && new >= POOL_READY_BITS) { - crng_reseed(); /* Sets crng_init to CRNG_READY under base_crng.lock. */ -- if (static_key_initialized && system_unbound_wq) -- queue_work(system_unbound_wq, &set_ready); -+ if (static_key_initialized) -+ execute_in_process_context(crng_set_ready, &set_ready); - wake_up_interruptible(&crng_init_wait); - kill_fasync(&fasync, SIGIO, POLL_IN); - pr_notice("crng init done\n"); -@@ -870,8 +870,8 @@ void __init random_init(void) - - /* - * If we were initialized by the cpu or bootloader before jump labels -- * or workqueues are initialized, then we should enable the static -- * branch here, where it's guaranteed that these have been initialized. -+ * are initialized, then we should enable the static branch here, where -+ * it's guaranteed that jump labels have been initialized. - */ - if (!static_branch_likely(&crng_is_ready) && crng_init >= CRNG_READY) - crng_set_ready(NULL); --- -2.35.3 - diff --git a/patch/kernel/archive/sunxi-6.1/series.armbian b/patch/kernel/archive/sunxi-6.1/series.armbian index 941e72a8b4..004395d76b 100644 --- a/patch/kernel/archive/sunxi-6.1/series.armbian +++ b/patch/kernel/archive/sunxi-6.1/series.armbian @@ -190,4 +190,3 @@ patches.armbian/drivers-hack-for-h616-hdmi-video-output.patch patches.armbian/arm64-dts-h616-add-hdmi-support-for-zero2.patch patches.armbian/arm64-dts-sun50i-h616-Add-dma-node.patch - patches.armbian/random-Revert-handle-entropy-from-atomic-process-con.patch diff --git a/patch/kernel/archive/sunxi-6.1/series.conf b/patch/kernel/archive/sunxi-6.1/series.conf index 57ec9987df..091ea5d54a 100644 --- a/patch/kernel/archive/sunxi-6.1/series.conf +++ b/patch/kernel/archive/sunxi-6.1/series.conf @@ -595,4 +595,3 @@ patches.armbian/drivers-hack-for-h616-hdmi-video-output.patch patches.armbian/arm64-dts-h616-add-hdmi-support-for-zero2.patch patches.armbian/arm64-dts-sun50i-h616-Add-dma-node.patch - patches.armbian/random-Revert-handle-entropy-from-atomic-process-con.patch