Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi/libstub/arm/arm64: Disable debug prints on 'quiet' cmdline arg

The EFI stub currently prints a number of diagnostic messages that do
not carry a lot of information. Since these prints are not controlled
by 'loglevel' or other command line parameters, and since they appear on
the EFI framebuffer as well (if enabled), it would be nice if we could
turn them off.

So let's add support for the 'quiet' command line parameter in the stub,
and disable the non-error prints if it is passed.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: bhe@redhat.com
Cc: bhsharma@redhat.com
Cc: bp@alien8.de
Cc: eugene@hp.com
Cc: evgeny.kalugin@intel.com
Cc: jhugo@codeaurora.org
Cc: leif.lindholm@linaro.org
Cc: linux-efi@vger.kernel.org
Cc: roy.franz@cavium.com
Cc: rruigrok@codeaurora.org
Link: http://lkml.kernel.org/r/20170404160910.28115-2-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Ard Biesheuvel and committed by
Ingo Molnar
eeff7d63 60f38de7

+30 -13
+10 -10
drivers/firmware/efi/libstub/arm-stub.c
··· 116 116 if (sys_table->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE) 117 117 goto fail; 118 118 119 - pr_efi(sys_table, "Booting Linux Kernel...\n"); 120 - 121 119 status = check_platform_features(sys_table); 122 120 if (status != EFI_SUCCESS) 123 121 goto fail; ··· 149 151 goto fail; 150 152 } 151 153 154 + if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || 155 + IS_ENABLED(CONFIG_CMDLINE_FORCE) || 156 + cmdline_size == 0) 157 + efi_parse_options(CONFIG_CMDLINE); 158 + 159 + if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0) 160 + efi_parse_options(cmdline_ptr); 161 + 162 + pr_efi(sys_table, "Booting Linux Kernel...\n"); 163 + 152 164 si = setup_graphics(sys_table); 153 165 154 166 status = handle_kernel_image(sys_table, image_addr, &image_size, ··· 169 161 pr_efi_err(sys_table, "Failed to relocate kernel\n"); 170 162 goto fail_free_cmdline; 171 163 } 172 - 173 - if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) || 174 - IS_ENABLED(CONFIG_CMDLINE_FORCE) || 175 - cmdline_size == 0) 176 - efi_parse_options(CONFIG_CMDLINE); 177 - 178 - if (!IS_ENABLED(CONFIG_CMDLINE_FORCE) && cmdline_size > 0) 179 - efi_parse_options(cmdline_ptr); 180 164 181 165 secure_boot = efi_get_secureboot(sys_table); 182 166
+2
drivers/firmware/efi/libstub/arm32-stub.c
··· 9 9 #include <linux/efi.h> 10 10 #include <asm/efi.h> 11 11 12 + #include "efistub.h" 13 + 12 14 efi_status_t check_platform_features(efi_system_table_t *sys_table_arg) 13 15 { 14 16 int block;
+9
drivers/firmware/efi/libstub/efi-stub-helper.c
··· 33 33 static unsigned long __chunk_size = EFI_READ_CHUNK_SIZE; 34 34 35 35 static int __section(.data) __nokaslr; 36 + static int __section(.data) __quiet; 36 37 37 38 int __pure nokaslr(void) 38 39 { 39 40 return __nokaslr; 41 + } 42 + int __pure is_quiet(void) 43 + { 44 + return __quiet; 40 45 } 41 46 42 47 #define EFI_MMAP_NR_SLACK_SLOTS 8 ··· 428 423 str = strstr(cmdline, "nokaslr"); 429 424 if (str == cmdline || (str && str > cmdline && *(str - 1) == ' ')) 430 425 __nokaslr = 1; 426 + 427 + str = strstr(cmdline, "quiet"); 428 + if (str == cmdline || (str && str > cmdline && *(str - 1) == ' ')) 429 + __quiet = 1; 431 430 432 431 /* 433 432 * If no EFI parameters were specified on the cmdline we've got
+7
drivers/firmware/efi/libstub/efistub.h
··· 25 25 #endif 26 26 27 27 extern int __pure nokaslr(void); 28 + extern int __pure is_quiet(void); 29 + 30 + #define pr_efi(sys_table, msg) do { \ 31 + if (!is_quiet()) efi_printk(sys_table, "EFI stub: "msg); \ 32 + } while (0) 33 + 34 + #define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) 28 35 29 36 void efi_char16_printk(efi_system_table_t *, efi_char16_t *); 30 37
+2
drivers/firmware/efi/libstub/secureboot.c
··· 12 12 #include <linux/efi.h> 13 13 #include <asm/efi.h> 14 14 15 + #include "efistub.h" 16 + 15 17 /* BIOS variables */ 16 18 static const efi_guid_t efi_variable_guid = EFI_GLOBAL_VARIABLE_GUID; 17 19 static const efi_char16_t const efi_SecureBoot_name[] = {
-3
include/linux/efi.h
··· 1435 1435 1436 1436 /* prototypes shared between arch specific and generic stub code */ 1437 1437 1438 - #define pr_efi(sys_table, msg) efi_printk(sys_table, "EFI stub: "msg) 1439 - #define pr_efi_err(sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) 1440 - 1441 1438 void efi_printk(efi_system_table_t *sys_table_arg, char *str); 1442 1439 1443 1440 void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,