]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - lib/vsprintf.c
khugepaged: collapse_pte_mapped_thp() protect the pmd lock
[mirror_ubuntu-focal-kernel.git] / lib / vsprintf.c
index e78017a3e1bd235621574f5f4dd5acc050bb26d7..2e048ee8622f8d6802e4558bd2f2ed76bcb90550 100644 (file)
@@ -746,6 +746,13 @@ static char *ptr_to_id(char *buf, char *end, const void *ptr,
        const char *str = sizeof(ptr) == 8 ? "(____ptrval____)" : "(ptrval)";
        unsigned long hashval;
 
+       /*
+        * Print the real pointer value for NULL and error pointers,
+        * as they are not actual addresses.
+        */
+       if (IS_ERR_OR_NULL(ptr))
+               return pointer_string(buf, end, ptr, spec);
+
        /* When debugging early boot use non-cryptographically secure hash. */
        if (unlikely(debug_boot_weak_hash)) {
                hashval = hash_long((unsigned long)ptr, 32);
@@ -2004,6 +2011,29 @@ static char *kobject_string(char *buf, char *end, void *ptr,
        return error_string(buf, end, "(%pO?)", spec);
 }
 
+#ifdef CONFIG_KMSG_IDS
+
+unsigned long long __jhash_string(const char *str);
+
+static noinline_for_stack
+char *jhash_string(char *buf, char *end, const char *str, const char *fmt)
+{
+       struct printf_spec spec;
+       unsigned long long num;
+
+       num = __jhash_string(str);
+
+       spec.type = FORMAT_TYPE_PTR;
+       spec.field_width = 6;
+       spec.flags = SMALL | ZEROPAD;
+       spec.base = 16;
+       spec.precision = -1;
+
+       return number(buf, end, num, spec);
+}
+
+#endif
+
 /*
  * Show a '%p' thing.  A kernel extension is that the '%p' is followed
  * by an extra set of alphanumeric characters that are extended format
@@ -2108,6 +2138,7 @@ static char *kobject_string(char *buf, char *end, void *ptr,
  *                  F device node flags
  *                  c major compatible string
  *                  C full compatible string
+ * - 'j' Kernel message catalog jhash for System z
  * - 'x' For printing the address. Equivalent to "%lx".
  *
  * ** When making changes please also update:
@@ -2187,6 +2218,10 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
                return kobject_string(buf, end, ptr, spec, fmt);
        case 'x':
                return pointer_string(buf, end, ptr, spec);
+#ifdef CONFIG_KMSG_IDS
+       case 'j':
+               return jhash_string(buf, end, ptr, fmt);
+#endif
        }
 
        /* default is to _not_ leak addresses, hash before printing */