From: Greg Kroah-Hartman Date: Wed, 15 Jan 2025 09:57:07 +0000 (+0100) Subject: 6.6-stable patches X-Git-Tag: v6.1.125~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed4c6d99bcc623f6700fc342f477875b9369c934;p=thirdparty%2Fkernel%2Fstable-queue.git 6.6-stable patches added patches: memblock-tests-fix-implicit-declaration-of-function-numa_valid_node.patch riscv-fix-early-ftrace-nop-patching.patch x86-mm-numa-use-numa_no_node-when-calling-memblock_set_node.patch --- diff --git a/queue-6.6/memblock-tests-fix-implicit-declaration-of-function-numa_valid_node.patch b/queue-6.6/memblock-tests-fix-implicit-declaration-of-function-numa_valid_node.patch new file mode 100644 index 0000000000..bc45e910a8 --- /dev/null +++ b/queue-6.6/memblock-tests-fix-implicit-declaration-of-function-numa_valid_node.patch @@ -0,0 +1,36 @@ +From 9364a7e40d54e6858479f0a96e1a04aa1204be16 Mon Sep 17 00:00:00 2001 +From: Wei Yang +Date: Mon, 24 Jun 2024 01:54:32 +0000 +Subject: memblock tests: fix implicit declaration of function 'numa_valid_node' + +From: Wei Yang + +commit 9364a7e40d54e6858479f0a96e1a04aa1204be16 upstream. + +commit 8043832e2a12 ("memblock: use numa_valid_node() helper to check +for invalid node ID") introduce a new helper numa_valid_node(), which is +not defined in memblock tests. + +Let's add it in the corresponding header file. + +Signed-off-by: Wei Yang +CC: Mike Rapoport (IBM) +Link: https://lore.kernel.org/r/20240624015432.31134-1-richard.weiyang@gmail.com +Signed-off-by: Mike Rapoport +Signed-off-by: Greg Kroah-Hartman +--- + tools/include/linux/numa.h | 5 +++++ + 1 file changed, 5 insertions(+) + +--- a/tools/include/linux/numa.h ++++ b/tools/include/linux/numa.h +@@ -13,4 +13,9 @@ + + #define NUMA_NO_NODE (-1) + ++static inline bool numa_valid_node(int nid) ++{ ++ return nid >= 0 && nid < MAX_NUMNODES; ++} ++ + #endif /* _LINUX_NUMA_H */ diff --git a/queue-6.6/riscv-fix-early-ftrace-nop-patching.patch b/queue-6.6/riscv-fix-early-ftrace-nop-patching.patch new file mode 100644 index 0000000000..4cd2f316cb --- /dev/null +++ b/queue-6.6/riscv-fix-early-ftrace-nop-patching.patch @@ -0,0 +1,67 @@ +From 6ca445d8af0ed5950ebf899415fd6bfcd7d9d7a3 Mon Sep 17 00:00:00 2001 +From: Alexandre Ghiti +Date: Thu, 23 May 2024 13:51:34 +0200 +Subject: riscv: Fix early ftrace nop patching +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Alexandre Ghiti + +commit 6ca445d8af0ed5950ebf899415fd6bfcd7d9d7a3 upstream. + +Commit c97bf629963e ("riscv: Fix text patching when IPI are used") +converted ftrace_make_nop() to use patch_insn_write() which does not +emit any icache flush relying entirely on __ftrace_modify_code() to do +that. + +But we missed that ftrace_make_nop() was called very early directly when +converting mcount calls into nops (actually on riscv it converts 2B nops +emitted by the compiler into 4B nops). + +This caused crashes on multiple HW as reported by Conor and Björn since +the booting core could have half-patched instructions in its icache +which would trigger an illegal instruction trap: fix this by emitting a +local flush icache when early patching nops. + +Fixes: c97bf629963e ("riscv: Fix text patching when IPI are used") +Signed-off-by: Alexandre Ghiti +Reported-by: Conor Dooley +Tested-by: Conor Dooley +Reviewed-by: Björn Töpel +Tested-by: Björn Töpel +Link: https://lore.kernel.org/r/20240523115134.70380-1-alexghiti@rivosinc.com +Signed-off-by: Palmer Dabbelt +Signed-off-by: Greg Kroah-Hartman +--- + arch/riscv/include/asm/cacheflush.h | 6 ++++++ + arch/riscv/kernel/ftrace.c | 3 +++ + 2 files changed, 9 insertions(+) + +--- a/arch/riscv/include/asm/cacheflush.h ++++ b/arch/riscv/include/asm/cacheflush.h +@@ -13,6 +13,12 @@ static inline void local_flush_icache_al + asm volatile ("fence.i" ::: "memory"); + } + ++static inline void local_flush_icache_range(unsigned long start, ++ unsigned long end) ++{ ++ local_flush_icache_all(); ++} ++ + #define PG_dcache_clean PG_arch_1 + + static inline void flush_dcache_folio(struct folio *folio) +--- a/arch/riscv/kernel/ftrace.c ++++ b/arch/riscv/kernel/ftrace.c +@@ -120,6 +120,9 @@ int ftrace_init_nop(struct module *mod, + out = ftrace_make_nop(mod, rec, MCOUNT_ADDR); + mutex_unlock(&text_mutex); + ++ if (!mod) ++ local_flush_icache_range(rec->ip, rec->ip + MCOUNT_INSN_SIZE); ++ + return out; + } + diff --git a/queue-6.6/series b/queue-6.6/series index a9828db812..12e0a1d543 100644 --- a/queue-6.6/series +++ b/queue-6.6/series @@ -35,6 +35,9 @@ bluetooth-hci_sync-fix-not-setting-random-address-wh.patch bluetooth-mgmt-fix-add-device-to-responding-before-c.patch bluetooth-btnxpuart-fix-driver-sending-truncated-dat.patch tcp-annotate-data-race-around-sk-sk_mark-in-tcp_v4_s.patch +riscv-fix-early-ftrace-nop-patching.patch +memblock-tests-fix-implicit-declaration-of-function-numa_valid_node.patch +x86-mm-numa-use-numa_no_node-when-calling-memblock_set_node.patch netfilter-nf_tables-imbalance-in-flowtable-binding.patch netfilter-conntrack-clamp-maximum-hashtable-size-to-.patch sched-sch_cake-add-bounds-checks-to-host-bulk-flow-f.patch diff --git a/queue-6.6/x86-mm-numa-use-numa_no_node-when-calling-memblock_set_node.patch b/queue-6.6/x86-mm-numa-use-numa_no_node-when-calling-memblock_set_node.patch new file mode 100644 index 0000000000..36e68170da --- /dev/null +++ b/queue-6.6/x86-mm-numa-use-numa_no_node-when-calling-memblock_set_node.patch @@ -0,0 +1,53 @@ +From 3ac36aa7307363b7247ccb6f6a804e11496b2b36 Mon Sep 17 00:00:00 2001 +From: Jan Beulich +Date: Wed, 29 May 2024 09:42:05 +0200 +Subject: x86/mm/numa: Use NUMA_NO_NODE when calling memblock_set_node() + +From: Jan Beulich + +commit 3ac36aa7307363b7247ccb6f6a804e11496b2b36 upstream. + +memblock_set_node() warns about using MAX_NUMNODES, see + + e0eec24e2e19 ("memblock: make memblock_set_node() also warn about use of MAX_NUMNODES") + +for details. + +Reported-by: Narasimhan V +Signed-off-by: Jan Beulich +Cc: stable@vger.kernel.org +[bp: commit message] +Signed-off-by: Borislav Petkov (AMD) +Reviewed-by: Mike Rapoport (IBM) +Tested-by: Paul E. McKenney +Link: https://lore.kernel.org/r/20240603141005.23261-1-bp@kernel.org +Link: https://lore.kernel.org/r/abadb736-a239-49e4-ab42-ace7acdd4278@suse.com +Signed-off-by: Mike Rapoport (IBM) +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/mm/numa.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/arch/x86/mm/numa.c ++++ b/arch/x86/mm/numa.c +@@ -492,7 +492,7 @@ static void __init numa_clear_kernel_nod + for_each_reserved_mem_region(mb_region) { + int nid = memblock_get_region_node(mb_region); + +- if (nid != MAX_NUMNODES) ++ if (nid != NUMA_NO_NODE) + node_set(nid, reserved_nodemask); + } + +@@ -613,9 +613,9 @@ static int __init numa_init(int (*init_f + nodes_clear(node_online_map); + memset(&numa_meminfo, 0, sizeof(numa_meminfo)); + WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.memory, +- MAX_NUMNODES)); ++ NUMA_NO_NODE)); + WARN_ON(memblock_set_node(0, ULLONG_MAX, &memblock.reserved, +- MAX_NUMNODES)); ++ NUMA_NO_NODE)); + /* In case that parsing SRAT failed. */ + WARN_ON(memblock_clear_hotplug(0, ULLONG_MAX)); + numa_reset_distance();