Merge branch 'master' into for-next
authorJiri Kosina <jkosina@suse.cz>
Tue, 1 Sep 2020 12:19:48 +0000 (14:19 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 1 Sep 2020 12:19:48 +0000 (14:19 +0200)
Sync with Linus' branch in order to be able to apply fixups
of more recent patches.

1  2 
kernel/printk/printk_safe.c
lib/bitmap.c

index 08a8bf77899068f9dce1313532a35046ab17f037,50aeae770434670aebb795dae31ce2edc3c5d89f..e95d2a5172443d4a06f9948ea5123dddbf76af4e
@@@ -6,10 -6,12 +6,12 @@@
  #include <linux/preempt.h>
  #include <linux/spinlock.h>
  #include <linux/debug_locks.h>
+ #include <linux/kdb.h>
  #include <linux/smp.h>
  #include <linux/cpumask.h>
  #include <linux/irq_work.h>
  #include <linux/printk.h>
+ #include <linux/kprobes.h>
  
  #include "internal.h"
  
   * is later flushed into the main ring buffer via IRQ work.
   *
   * The alternative implementation is chosen transparently
 - * by examinig current printk() context mask stored in @printk_context
 + * by examining current printk() context mask stored in @printk_context
   * per-CPU variable.
   *
   * The implementation allows to flush the strings also from another CPU.
   * There are situations when we want to make sure that all buffers
   * were handled or when IRQs are blocked.
   */
- static int printk_safe_irq_ready __read_mostly;
  
  #define SAFE_LOG_BUF_LEN ((1 << CONFIG_PRINTK_SAFE_LOG_BUF_SHIFT) -   \
                                sizeof(atomic_t) -                      \
@@@ -51,7 -52,7 +52,7 @@@ static DEFINE_PER_CPU(struct printk_saf
  /* Get flushed in a more safe context. */
  static void queue_flush_work(struct printk_safe_seq_buf *s)
  {
-       if (printk_safe_irq_ready)
+       if (printk_percpu_data_ready())
                irq_work_queue(&s->work);
  }
  
@@@ -294,14 -295,14 +295,14 @@@ static __printf(1, 0) int vprintk_nmi(c
        return printk_safe_log_store(s, fmt, args);
  }
  
- void notrace printk_nmi_enter(void)
+ void noinstr printk_nmi_enter(void)
  {
-       this_cpu_or(printk_context, PRINTK_NMI_CONTEXT_MASK);
+       this_cpu_add(printk_context, PRINTK_NMI_CONTEXT_OFFSET);
  }
  
- void notrace printk_nmi_exit(void)
+ void noinstr printk_nmi_exit(void)
  {
-       this_cpu_and(printk_context, ~PRINTK_NMI_CONTEXT_MASK);
+       this_cpu_sub(printk_context, PRINTK_NMI_CONTEXT_OFFSET);
  }
  
  /*
@@@ -360,6 -361,12 +361,12 @@@ void __printk_safe_exit(void
  
  __printf(1, 0) int vprintk_func(const char *fmt, va_list args)
  {
+ #ifdef CONFIG_KGDB_KDB
+       /* Allow to pass printk() to kdb but avoid a recursion. */
+       if (unlikely(kdb_trap_printk && kdb_printf_cpu < 0))
+               return vkdb_printf(KDB_MSGSRC_PRINTK, fmt, args);
+ #endif
        /*
         * Try to use the main logbuf even in NMI. But avoid calling console
         * drivers that might have their own locks.
@@@ -402,14 -409,6 +409,6 @@@ void __init printk_safe_init(void
  #endif
        }
  
-       /*
-        * In the highly unlikely event that a NMI were to trigger at
-        * this moment. Make sure IRQ work is set up before this
-        * variable is set.
-        */
-       barrier();
-       printk_safe_irq_ready = 1;
        /* Flush pending messages that did not have scheduled IRQ works. */
        printk_safe_flush();
  }
diff --combined lib/bitmap.c
index a801379e9354689092b136ea56e423522222e45b,c13d859bc7ab1451672124823f6f4af860a0de05..61394890788e449d58c5e871c59ed8e723089469
@@@ -182,21 -182,22 +182,22 @@@ EXPORT_SYMBOL(__bitmap_shift_left)
   *
   * In pictures, example for a big-endian 32-bit architecture:
   *
-  * @src:
-  * 31                                   63
-  * |                                    |
-  * 10000000 11000001 11110010 00010101  10000000 11000001 01110010 00010101
-  *                 |  |              |                                    |
-  *                16  14             0                                   32
+  * The @src bitmap is::
   *
-  * if @cut is 3, and @first is 14, bits 14-16 in @src are cut and @dst is:
+  *   31                                   63
+  *   |                                    |
+  *   10000000 11000001 11110010 00010101  10000000 11000001 01110010 00010101
+  *                   |  |              |                                    |
+  *                  16  14             0                                   32
   *
-  * 31                                   63
-  * |                                    |
-  * 10110000 00011000 00110010 00010101  00010000 00011000 00101110 01000010
-  *                    |              |                                    |
-  *                    14 (bit 17     0                                   32
-  *                        from @src)
+  * if @cut is 3, and @first is 14, bits 14-16 in @src are cut and @dst is::
+  *
+  *   31                                   63
+  *   |                                    |
+  *   10110000 00011000 00110010 00010101  00010000 00011000 00101110 01000010
+  *                      |              |                                    |
+  *                      14 (bit 17     0                                   32
+  *                          from @src)
   *
   * Note that @dst and @src might overlap partially or entirely.
   *
@@@ -211,13 -212,13 +212,13 @@@ void bitmap_cut(unsigned long *dst, con
        unsigned long keep = 0, carry;
        int i;
  
-       memmove(dst, src, len * sizeof(*dst));
        if (first % BITS_PER_LONG) {
                keep = src[first / BITS_PER_LONG] &
                       (~0UL >> (BITS_PER_LONG - first % BITS_PER_LONG));
        }
  
+       memmove(dst, src, len * sizeof(*dst));
        while (cut--) {
                for (i = first / BITS_PER_LONG; i < len; i++) {
                        if (i < len - 1)
@@@ -551,7 -552,7 +552,7 @@@ static inline bool end_of_region(char c
  }
  
  /*
 - * The format allows commas and whitespases at the beginning
 + * The format allows commas and whitespaces at the beginning
   * of the region.
   */
  static const char *bitmap_find_region(const char *str)
@@@ -740,8 -741,9 +741,9 @@@ int bitmap_parse(const char *start, uns
        int chunks = BITS_TO_U32(nmaskbits);
        u32 *bitmap = (u32 *)maskp;
        int unset_bit;
+       int chunk;
  
-       while (1) {
+       for (chunk = 0; ; chunk++) {
                end = bitmap_find_region_reverse(start, end);
                if (start > end)
                        break;
                if (!chunks--)
                        return -EOVERFLOW;
  
-               end = bitmap_get_x32_reverse(start, end, bitmap++);
+ #if defined(CONFIG_64BIT) && defined(__BIG_ENDIAN)
+               end = bitmap_get_x32_reverse(start, end, &bitmap[chunk ^ 1]);
+ #else
+               end = bitmap_get_x32_reverse(start, end, &bitmap[chunk]);
+ #endif
                if (IS_ERR(end))
                        return PTR_ERR(end);
        }