From f7d1e901d31137d6c2dac205949f9e2d6cfd988b Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 31 Aug 2018 12:55:42 -0700 Subject: [PATCH] 4.18-stable patches added patches: printk-create-helper-function-to-queue-deferred-console-handling.patch printk-split-the-code-for-storing-a-message-into-the-log-buffer.patch --- ...n-to-queue-deferred-console-handling.patch | 55 +++++++++++ ...toring-a-message-into-the-log-buffer.patch | 93 +++++++++++++++++++ queue-4.18/series | 2 + 3 files changed, 150 insertions(+) create mode 100644 queue-4.18/printk-create-helper-function-to-queue-deferred-console-handling.patch create mode 100644 queue-4.18/printk-split-the-code-for-storing-a-message-into-the-log-buffer.patch diff --git a/queue-4.18/printk-create-helper-function-to-queue-deferred-console-handling.patch b/queue-4.18/printk-create-helper-function-to-queue-deferred-console-handling.patch new file mode 100644 index 00000000000..95fda5837dd --- /dev/null +++ b/queue-4.18/printk-create-helper-function-to-queue-deferred-console-handling.patch @@ -0,0 +1,55 @@ +From a338f84dc196f44b63ba0863d2f34fd9b1613572 Mon Sep 17 00:00:00 2001 +From: Petr Mladek +Date: Wed, 27 Jun 2018 16:08:16 +0200 +Subject: printk: Create helper function to queue deferred console handling + +From: Petr Mladek + +commit a338f84dc196f44b63ba0863d2f34fd9b1613572 upstream. + +It is just a preparation step. The patch does not change +the existing behavior. + +Link: http://lkml.kernel.org/r/20180627140817.27764-3-pmladek@suse.com +To: Steven Rostedt +Cc: Peter Zijlstra +Cc: Tetsuo Handa +Cc: Sergey Senozhatsky +Cc: linux-kernel@vger.kernel.org +Cc: stable@vger.kernel.org +Acked-by: Sergey Senozhatsky +Signed-off-by: Petr Mladek +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/printk/printk.c | 14 +++++++++----- + 1 file changed, 9 insertions(+), 5 deletions(-) + +--- a/kernel/printk/printk.c ++++ b/kernel/printk/printk.c +@@ -2887,16 +2887,20 @@ void wake_up_klogd(void) + preempt_enable(); + } + +-int vprintk_deferred(const char *fmt, va_list args) ++void defer_console_output(void) + { +- int r; +- +- r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, 0, fmt, args); +- + preempt_disable(); + __this_cpu_or(printk_pending, PRINTK_PENDING_OUTPUT); + irq_work_queue(this_cpu_ptr(&wake_up_klogd_work)); + preempt_enable(); ++} ++ ++int vprintk_deferred(const char *fmt, va_list args) ++{ ++ int r; ++ ++ r = vprintk_emit(0, LOGLEVEL_SCHED, NULL, 0, fmt, args); ++ defer_console_output(); + + return r; + } diff --git a/queue-4.18/printk-split-the-code-for-storing-a-message-into-the-log-buffer.patch b/queue-4.18/printk-split-the-code-for-storing-a-message-into-the-log-buffer.patch new file mode 100644 index 00000000000..c10e3173554 --- /dev/null +++ b/queue-4.18/printk-split-the-code-for-storing-a-message-into-the-log-buffer.patch @@ -0,0 +1,93 @@ +From ba552399954dde1b388f7749fecad5c349216981 Mon Sep 17 00:00:00 2001 +From: Petr Mladek +Date: Wed, 27 Jun 2018 16:08:15 +0200 +Subject: printk: Split the code for storing a message into the log buffer + +From: Petr Mladek + +commit ba552399954dde1b388f7749fecad5c349216981 upstream. + +It is just a preparation step. The patch does not change +the existing behavior. + +Link: http://lkml.kernel.org/r/20180627140817.27764-2-pmladek@suse.com +To: Steven Rostedt +Cc: Peter Zijlstra +Cc: Tetsuo Handa +Cc: Sergey Senozhatsky +Cc: linux-kernel@vger.kernel.org +Cc: stable@vger.kernel.org +Acked-by: Sergey Senozhatsky +Signed-off-by: Petr Mladek +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/printk/printk.c | 43 ++++++++++++++++++++++++++----------------- + 1 file changed, 26 insertions(+), 17 deletions(-) + +--- a/kernel/printk/printk.c ++++ b/kernel/printk/printk.c +@@ -1824,28 +1824,16 @@ static size_t log_output(int facility, i + return log_store(facility, level, lflags, 0, dict, dictlen, text, text_len); + } + +-asmlinkage int vprintk_emit(int facility, int level, +- const char *dict, size_t dictlen, +- const char *fmt, va_list args) ++/* Must be called under logbuf_lock. */ ++int vprintk_store(int facility, int level, ++ const char *dict, size_t dictlen, ++ const char *fmt, va_list args) + { + static char textbuf[LOG_LINE_MAX]; + char *text = textbuf; + size_t text_len; + enum log_flags lflags = 0; +- unsigned long flags; +- int printed_len; +- bool in_sched = false; +- +- if (level == LOGLEVEL_SCHED) { +- level = LOGLEVEL_DEFAULT; +- in_sched = true; +- } +- +- boot_delay_msec(level); +- printk_delay(); + +- /* This stops the holder of console_sem just where we want him */ +- logbuf_lock_irqsave(flags); + /* + * The printf needs to come first; we need the syslog + * prefix which might be passed-in as a parameter. +@@ -1886,8 +1874,29 @@ asmlinkage int vprintk_emit(int facility + if (dict) + lflags |= LOG_PREFIX|LOG_NEWLINE; + +- printed_len = log_output(facility, level, lflags, dict, dictlen, text, text_len); ++ return log_output(facility, level, lflags, ++ dict, dictlen, text, text_len); ++} + ++asmlinkage int vprintk_emit(int facility, int level, ++ const char *dict, size_t dictlen, ++ const char *fmt, va_list args) ++{ ++ int printed_len; ++ bool in_sched = false; ++ unsigned long flags; ++ ++ if (level == LOGLEVEL_SCHED) { ++ level = LOGLEVEL_DEFAULT; ++ in_sched = true; ++ } ++ ++ boot_delay_msec(level); ++ printk_delay(); ++ ++ /* This stops the holder of console_sem just where we want him */ ++ logbuf_lock_irqsave(flags); ++ printed_len = vprintk_store(facility, level, dict, dictlen, fmt, args); + logbuf_unlock_irqrestore(flags); + + /* If called from the scheduler, we can not call up(). */ diff --git a/queue-4.18/series b/queue-4.18/series index 99e5db285e1..9e21877f7ad 100644 --- a/queue-4.18/series +++ b/queue-4.18/series @@ -22,6 +22,8 @@ hwmon-k10temp-27c-offset-needed-for-threadripper2.patch bpf-arm32-fix-stack-var-offset-in-jit.patch regulator-arizona-ldo1-use-correct-device-to-get-enable-gpio.patch iommu-arm-smmu-error-out-only-if-not-enough-context-interrupts.patch +printk-split-the-code-for-storing-a-message-into-the-log-buffer.patch +printk-create-helper-function-to-queue-deferred-console-handling.patch printk-nmi-prevent-deadlock-when-accessing-the-main-log-buffer-in-nmi.patch kprobes-arm64-fix-p-uses-in-error-messages.patch arm64-fix-mismatched-cache-line-size-detection.patch -- 2.47.3