]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
kernel/printk: use symbolic defines for console loglevels
authorBorislav Petkov <bp@suse.de>
Wed, 4 Jun 2014 23:11:46 +0000 (16:11 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 4 Jun 2014 23:54:17 +0000 (16:54 -0700)
... instead of naked numbers.

Stuff in sysrq.c used to set it to 8 which is supposed to mean above
default level so set it to DEBUG instead as we're terminating/killing all
tasks and we want to be verbose there.

Also, correct the check in x86_64_start_kernel which should be >= as
we're clearly issuing the string there for all debug levels, not only
the magical 10.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Kees Cook <keescook@chromium.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Joe Perches <joe@perches.com>
Cc: Valdis Kletnieks <Valdis.Kletnieks@vt.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/x86/kernel/head64.c
arch/x86/platform/uv/uv_nmi.c
drivers/nubus/nubus.c
drivers/tty/sysrq.c
include/linux/printk.h
init/main.c
kernel/debug/kdb/kdb_bt.c
kernel/debug/kdb/kdb_io.c
kernel/debug/kdb/kdb_main.c
kernel/printk/printk.c

index 068054f4bf20b75e124d4776ee9ffa889a6e1a0c..eda1a865641e2e86f01961265619ab0484b96631 100644 (file)
@@ -172,7 +172,7 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data)
         */
        load_ucode_bsp();
 
-       if (console_loglevel == 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                early_printk("Kernel alive\n");
 
        clear_page(init_level4_pgt);
index be27da60dc8f8d2613e4b003239ef4c3b05bbd32..c89c93320c12a4dfa21156e86937eea979af480d 100644 (file)
@@ -85,7 +85,7 @@ static cpumask_var_t uv_nmi_cpu_mask;
  * Default is all stack dumps go to the console and buffer.
  * Lower level to send to log buffer only.
  */
-static int uv_nmi_loglevel = 7;
+static int uv_nmi_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
 module_param_named(dump_loglevel, uv_nmi_loglevel, int, 0644);
 
 /*
index 43926cd25ae81fbef6ea0d72e10b95466621ee5b..5066a7ef7b6c38a2064c69003bff4f90b481293e 100644 (file)
@@ -473,7 +473,7 @@ static struct nubus_dev* __init
        if (slot == 0 && (unsigned long)dir.base % 2)
                dir.base += 1;
        
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_functional_resource: parent is 0x%p, dir is 0x%p\n",
                       parent->base, dir.base);
 
@@ -568,7 +568,7 @@ static int __init nubus_get_vidnames(struct nubus_board* board,
 
        printk(KERN_INFO "    video modes supported:\n");
        nubus_get_subdir(parent, &dir);
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_vidnames: parent is 0x%p, dir is 0x%p\n",
                       parent->base, dir.base);
 
@@ -629,7 +629,7 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board,
 
        printk(KERN_INFO "    vendor info:\n");
        nubus_get_subdir(parent, &dir);
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_vendorinfo: parent is 0x%p, dir is 0x%p\n",
                       parent->base, dir.base);
 
@@ -654,7 +654,7 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot,
        struct nubus_dirent ent;
        
        nubus_get_subdir(parent, &dir);
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_board_resource: parent is 0x%p, dir is 0x%p\n",
                       parent->base, dir.base);
 
@@ -753,19 +753,19 @@ static void __init nubus_find_rom_dir(struct nubus_board* board)
        if (nubus_readdir(&dir, &ent) == -1)
                goto badrom;
 
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_INFO "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
        /* This one takes us to where we want to go. */
        if (nubus_readdir(&dir, &ent) == -1) 
                goto badrom;
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
        nubus_get_subdir(&ent, &dir);
 
        /* Resource ID 01, also an "Unknown Macintosh" */
        if (nubus_readdir(&dir, &ent) == -1) 
                goto badrom;
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
 
        /* FIXME: the first one is *not* always the right one.  We
@@ -780,7 +780,7 @@ static void __init nubus_find_rom_dir(struct nubus_board* board)
           path to that address... */
        if (nubus_readdir(&dir, &ent) == -1)
                goto badrom;
-       if (console_loglevel >= 10)
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG)
                printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data);
        
        /* Bwahahahaha... */
@@ -816,7 +816,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes)
        board->fblock = rp;
 
        /* Dump the format block for debugging purposes */
-       if (console_loglevel >= 10) {
+       if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) {
                int i;
                printk(KERN_DEBUG "Slot %X, format block at 0x%p\n",
                       slot, rp);
index ce396ecdf41268b5de64a7ac3f820438c3bdfffb..b767a64e49d9402cc792b1719d7e6fd87e877b3f 100644 (file)
@@ -88,7 +88,7 @@ static void sysrq_handle_loglevel(int key)
        int i;
 
        i = key - '0';
-       console_loglevel = 7;
+       console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
        printk("Loglevel set to %d\n", i);
        console_loglevel = i;
 }
@@ -343,7 +343,7 @@ static void send_sig_all(int sig)
 static void sysrq_handle_term(int key)
 {
        send_sig_all(SIGTERM);
-       console_loglevel = 8;
+       console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
 }
 static struct sysrq_key_op sysrq_term_op = {
        .handler        = sysrq_handle_term,
@@ -387,7 +387,7 @@ static struct sysrq_key_op sysrq_thaw_op = {
 static void sysrq_handle_kill(int key)
 {
        send_sig_all(SIGKILL);
-       console_loglevel = 8;
+       console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
 }
 static struct sysrq_key_op sysrq_kill_op = {
        .handler        = sysrq_handle_kill,
@@ -520,7 +520,7 @@ void __handle_sysrq(int key, bool check_mask)
         * routing in the consumers of /proc/kmsg.
         */
        orig_log_level = console_loglevel;
-       console_loglevel = 7;
+       console_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
        printk(KERN_INFO "SysRq : ");
 
         op_p = __sysrq_get_key_op(key);
index 37f3a6589c1cabf5f121a91f1250a4fc516c0808..319ff7e53efbc1f0bd551125bd70951c2a8c83ea 100644 (file)
@@ -30,6 +30,17 @@ static inline const char *printk_skip_level(const char *buffer)
        return buffer;
 }
 
+/* printk's without a loglevel use this.. */
+#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
+
+/* We show everything that is MORE important than this.. */
+#define CONSOLE_LOGLEVEL_SILENT  0 /* Mum's the word */
+#define CONSOLE_LOGLEVEL_MIN    1 /* Minimum loglevel we let people use */
+#define CONSOLE_LOGLEVEL_QUIET  4 /* Shhh ..., when booted with "quiet" */
+#define CONSOLE_LOGLEVEL_DEFAULT 7 /* anything MORE serious than KERN_DEBUG */
+#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
+#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
+
 extern int console_printk[];
 
 #define console_loglevel (console_printk[0])
@@ -39,13 +50,13 @@ extern int console_printk[];
 
 static inline void console_silent(void)
 {
-       console_loglevel = 0;
+       console_loglevel = CONSOLE_LOGLEVEL_SILENT;
 }
 
 static inline void console_verbose(void)
 {
        if (console_loglevel)
-               console_loglevel = 15;
+               console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
 }
 
 struct va_format {
index e08c0b2065a13805e2af8145188b7a95e6076b84..04fab8d74c89ba9c3a3f212d64546991d95c6b65 100644 (file)
@@ -203,13 +203,13 @@ EXPORT_SYMBOL(loops_per_jiffy);
 
 static int __init debug_kernel(char *str)
 {
-       console_loglevel = 10;
+       console_loglevel = CONSOLE_LOGLEVEL_DEBUG;
        return 0;
 }
 
 static int __init quiet_kernel(char *str)
 {
-       console_loglevel = 4;
+       console_loglevel = CONSOLE_LOGLEVEL_QUIET;
        return 0;
 }
 
index b03e0e814e43b9f05f598f14f5f9a06618f3f21a..fe15fff5df5340aeb6234b52a7828f7505b4ec9f 100644 (file)
@@ -21,7 +21,7 @@
 static void kdb_show_stack(struct task_struct *p, void *addr)
 {
        int old_lvl = console_loglevel;
-       console_loglevel = 15;
+       console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
        kdb_trap_printk++;
        kdb_set_current_task(p);
        if (addr) {
index 14ff4849262c0c6ecb275ba30da19724819b548c..7c70812caea5b3223fe1a9b7d9252980f90a02fe 100644 (file)
@@ -710,7 +710,7 @@ kdb_printit:
        }
        if (logging) {
                saved_loglevel = console_loglevel;
-               console_loglevel = 0;
+               console_loglevel = CONSOLE_LOGLEVEL_SILENT;
                printk(KERN_INFO "%s", kdb_buffer);
        }
 
index 0b097c8a1e50e0b0a0a299f6c1df240f15468b3f..2f7c760305cac120195f43913abe811095ac258f 100644 (file)
@@ -1091,7 +1091,7 @@ static int kdb_reboot(int argc, const char **argv)
 static void kdb_dumpregs(struct pt_regs *regs)
 {
        int old_lvl = console_loglevel;
-       console_loglevel = 15;
+       console_loglevel = CONSOLE_LOGLEVEL_MOTORMOUTH;
        kdb_trap_printk++;
        show_regs(regs);
        kdb_trap_printk--;
index 923c5d4e42021237d404c7dbdf281eb1067ca885..ea2d5f6962edd7d7530c0e5766ea3517d5515e25 100644 (file)
 #include "console_cmdline.h"
 #include "braille.h"
 
-/* printk's without a loglevel use this.. */
-#define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL
-
-/* We show everything that is MORE important than this.. */
-#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
-#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
-
 int console_printk[4] = {
-       DEFAULT_CONSOLE_LOGLEVEL,       /* console_loglevel */
+       CONSOLE_LOGLEVEL_DEFAULT,       /* console_loglevel */
        DEFAULT_MESSAGE_LOGLEVEL,       /* default_message_loglevel */
-       MINIMUM_CONSOLE_LOGLEVEL,       /* minimum_console_loglevel */
-       DEFAULT_CONSOLE_LOGLEVEL,       /* default_console_loglevel */
+       CONSOLE_LOGLEVEL_MIN,           /* minimum_console_loglevel */
+       CONSOLE_LOGLEVEL_DEFAULT,       /* default_console_loglevel */
 };
 
 /* Deferred messaged from sched code are marked by this special level */