From: Greg Kroah-Hartman Date: Mon, 15 May 2023 12:57:14 +0000 (+0200) Subject: 5.10-stable patches X-Git-Tag: v4.14.315~18 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bb4cc1351bed48f0e01449e38f2a873e2a61a057;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: printk-declare-printk_deferred_-enter-safe-in-include-linux-printk.h.patch --- diff --git a/queue-5.10/printk-declare-printk_deferred_-enter-safe-in-include-linux-printk.h.patch b/queue-5.10/printk-declare-printk_deferred_-enter-safe-in-include-linux-printk.h.patch new file mode 100644 index 00000000000..fedfab4e6bb --- /dev/null +++ b/queue-5.10/printk-declare-printk_deferred_-enter-safe-in-include-linux-printk.h.patch @@ -0,0 +1,80 @@ +From stable-owner@vger.kernel.org Sun May 14 06:41:59 2023 +From: Tetsuo Handa +Date: Sun, 14 May 2023 13:41:27 +0900 +Subject: printk: declare printk_deferred_{enter,safe}() in include/linux/printk.h +To: stable@vger.kernel.org +Cc: John Ogness , Petr Mladek , Greg Kroah-Hartman +Message-ID: <767ab028-d946-98d5-4a13-d6ed6df77763@I-love.SAKURA.ne.jp> + +From: Tetsuo Handa + +commit 85e3e7fbbb720b9897fba9a99659e31cbd1c082e upstream. + +[This patch implements subset of original commit 85e3e7fbbb72 ("printk: +remove NMI tracking") where commit 1007843a9190 ("mm/page_alloc: fix +potential deadlock on zonelist_update_seq seqlock") depends on, for +commit 3d36424b3b58 ("mm/page_alloc: fix race condition between +build_all_zonelists and page allocation") was backported to stable.] + +All NMI contexts are handled the same as the safe context: store the +message and defer printing. There is no need to have special NMI +context tracking for this. Using in_nmi() is enough. + +There are several parts of the kernel that are manually calling into +the printk NMI context tracking in order to cause general printk +deferred printing: + + arch/arm/kernel/smp.c + arch/powerpc/kexec/crash.c + kernel/trace/trace.c + +For arm/kernel/smp.c and powerpc/kexec/crash.c, provide a new +function pair printk_deferred_enter/exit that explicitly achieves the +same objective. + +For ftrace, remove the printk context manipulation completely. It was +added in commit 03fc7f9c99c1 ("printk/nmi: Prevent deadlock when +accessing the main log buffer in NMI"). The purpose was to enforce +storing messages directly into the ring buffer even in NMI context. +It really should have only modified the behavior in NMI context. +There is no need for a special behavior any longer. All messages are +always stored directly now. The console deferring is handled +transparently in vprintk(). + +Signed-off-by: John Ogness +[pmladek@suse.com: Remove special handling in ftrace.c completely. +Signed-off-by: Petr Mladek +Link: https://lore.kernel.org/r/20210715193359.25946-5-john.ogness@linutronix.de +[penguin-kernel: Copy only printk_deferred_{enter,safe}() definition ] +Signed-off-by: Tetsuo Handa +Signed-off-by: Greg Kroah-Hartman +--- + include/linux/printk.h | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +--- a/include/linux/printk.h ++++ b/include/linux/printk.h +@@ -623,4 +623,23 @@ static inline void print_hex_dump_debug( + #define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \ + print_hex_dump_debug(prefix_str, prefix_type, 16, 1, buf, len, true) + ++#ifdef CONFIG_PRINTK ++extern void __printk_safe_enter(void); ++extern void __printk_safe_exit(void); ++/* ++ * The printk_deferred_enter/exit macros are available only as a hack for ++ * some code paths that need to defer all printk console printing. Interrupts ++ * must be disabled for the deferred duration. ++ */ ++#define printk_deferred_enter __printk_safe_enter ++#define printk_deferred_exit __printk_safe_exit ++#else ++static inline void printk_deferred_enter(void) ++{ ++} ++static inline void printk_deferred_exit(void) ++{ ++} ++#endif ++ + #endif diff --git a/queue-5.10/series b/queue-5.10/series index 5b0be21684a..7c70496714b 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -375,3 +375,4 @@ kvm-x86-do-not-set-st-preempted-when-going-back-to-user-space.patch kvm-x86-revalidate-steal-time-cache-if-msr-value-changes.patch kvm-x86-do-not-report-preemption-if-the-steal-time-cache-is-stale.patch kvm-x86-move-guest_pv_has-out-of-user_access-section.patch +printk-declare-printk_deferred_-enter-safe-in-include-linux-printk.h.patch