efi/libstub: arm/arm64: make debug prints dependent on efi=debug
PATCH 1/1 efi/libstub: arm/arm64: make debug prints dependent on efi=debug
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 only print them if 'efi=debug' is passed on the command line, or when CONFIG_DEBUG_EFI is set in the kernel build configuration.
--- drivers/firmware/efi/libstub/arm32-stub.c | 2 ++ drivers/firmware/efi/libstub/efi-stub-helper.c | 23 ++++++++++++++--------- drivers/firmware/efi/libstub/efistub.h | 9 +++++++++ drivers/firmware/efi/libstub/secureboot.c | 2 ++ include/linux/efi.h | 3 --- 5 files changed, 27 insertions(+), 12 deletions(-)
drivers/firmware/efi/libstub/arm32-stub.c +2 -0
@@ -9,6 +9,8 @@#include <linux/efi.h> #include <asm/efi.h> +#include "efistub.h" +efi_status_t check_platform_features (efi_system_table_t *sys_table_arg) {int block;
drivers/firmware/efi/libstub/efi-stub-helper.c +14 -9
@@ -32,6 +32,13 @@static unsigned long __chunk_size =EFI_READ_CHUNK_SIZE ; +static int __debug_enabled =IS_ENABLED (CONFIG_DEBUG_EFI ); + +int __pure debug_enabled (void ) +{ +return __debug_enabled; +} +#define EFI_MMAP_NR_SLACK_SLOTS 8struct file_info {
@@ -414,14 +421,6 @@ efi_status_t efi_parse_options(char *cmdline)char *str;/* -* Currently, the only efi= option we look for is 'nochunk', which -* is intended to work around known issues on certain x86 UEFI -* versions. So ignore for now on other architectures. -*/ -if (!IS_ENABLED (CONFIG_X86 )) -return EFI_SUCCESS ; - -/* * If no EFI parameters were specified on the cmdline we've got * nothing to do. */
@@ -437,13 +436,19 @@ efi_status_t efi_parse_options(char *cmdline)* skip over arguments we don't understand. */ while (*str) { +if (*str ==' ' ) +break ; +if (!strncmp (str,"nochunk" ,7 )) { str +=strlen ("nochunk" ); __chunk_size =-1UL ; + }else if (!strncmp (str,"debug" ,5 )) { + str +=strlen ("debug" ); + __debug_enabled =1 ; }/* Group words together, delimited by "," */ -while (*str && *str !=',' ) +while (*str && *str !=',' && *str !=' ' ) str++;if (*str ==',' )
drivers/firmware/efi/libstub/efistub.h +9 -0
@@ -24,6 +24,15 @@#define EFI_ALLOC_ALIGN EFI_PAGE_SIZE#endif +extern int __pure debug_enabled (void ); + +#define pr_efi (sys_table, msg) do { \ + if (debug_enabled()) efi_printk(sys_table, "EFI stub: "msg); \ +} while (0) + +#define pr_efi_err (sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) + +void efi_char16_printk (efi_system_table_t *,efi_char16_t *); efi_status_t efi_open_volume(efi_system_table_t *sys_table_arg, void *__image,
drivers/firmware/efi/libstub/secureboot.c +2 -0
@@ -12,6 +12,8 @@#include <linux/efi.h> #include <asm/efi.h> +#include "efistub.h" +/* BIOS variables */ static const efi_guid_t efi_variable_guid =EFI_GLOBAL_VARIABLE_GUID ;static const efi_char16_t const efi_SecureBoot_name[] = {
include/linux/efi.h +0 -3
@@ -1435,9 +1435,6 @@ static inline int efi_runtime_map_copy(void *buf, size_t bufsz)/* prototypes shared between arch specific and generic stub code */ -#define pr_efi (sys_table, msg) efi_printk(sys_table, "EFI stub: "msg) -#define pr_efi_err (sys_table, msg) efi_printk(sys_table, "EFI stub: ERROR: "msg) -void efi_printk (efi_system_table_t *sys_table_arg,char *str); void efi_free(efi_system_table_t *sys_table_arg, unsigned long size,
Signature · 1 line
2.7.4
PATCH 1/1 efi/libstub: arm/arm64: make debug prints dependent on efi=debug
Quoted 23 lines · Ard Biesheuvel
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 only print them if 'efi=debug' is passed on the command line, or when
CONFIG_DEBUG_EFIis set in the kernel build configuration.Signed-off-by Ard Biesheuvel <[email protected]>--- drivers/firmware/efi/libstub/arm32-stub.c | 2 ++ drivers/firmware/efi/libstub/efi-stub-helper.c | 23 ++++++++++++++--------- drivers/firmware/efi/libstub/efistub.h | 9 +++++++++ drivers/firmware/efi/libstub/secureboot.c | 2 ++ include/linux/efi.h | 3 --- 5 files changed, 27 insertions(+), 12 deletions(-)drivers/firmware/efi/libstub/efistub.h +0
-0
drivers/firmware/efi/libstub/efistub.h line 31
Quoted 8 lines
drivers/firmware/efi/libstub/efistub.h +5
-0@@ -24,6 +24,15 @@#define EFI_ALLOC_ALIGN EFI_PAGE_SIZE#endif +extern int __pure debug_enabled (void ); + +#define pr_efi (sys_table, msg) do { \ + if (debug_enabled()) efi_printk(sys_table, "EFI stub: "msg); \ +} while (0)
I was going to say that it's somewhat unfortunate to lose some of these messages by default, but I guess this only adds one additional round-trip when debugging a remote issue, and gives us the freedom to add more comprehensive debug messages in future.
Is the idea is to make the EFI stub completely silent in the successful case, or is the aim just to minimise the number of messages?
If it's only the latter, we could log a message regarding the existence of efi=debug in the default case, which might help with bug reports.
No strong feelings from me.
Thanks,
Mark.
PATCH 1/1 efi/libstub: arm/arm64: make debug prints dependent on efi=debug
Quoted 38 lines · Mark Rutland
Quoted 23 lines · Ard Biesheuvel
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 only print them if 'efi=debug' is passed on the command line, or when
CONFIG_DEBUG_EFIis set in the kernel build configuration.Signed-off-by Ard Biesheuvel <[email protected]>--- drivers/firmware/efi/libstub/arm32-stub.c | 2 ++ drivers/firmware/efi/libstub/efi-stub-helper.c | 23 ++++++++++++++--------- drivers/firmware/efi/libstub/efistub.h | 9 +++++++++ drivers/firmware/efi/libstub/secureboot.c | 2 ++ include/linux/efi.h | 3 --- 5 files changed, 27 insertions(+), 12 deletions(-)drivers/firmware/efi/libstub/efistub.h +0
-0drivers/firmware/efi/libstub/efistub.h line 31
Quoted 8 lines
drivers/firmware/efi/libstub/efistub.h +5
-0@@ -24,6 +24,15 @@#define EFI_ALLOC_ALIGN EFI_PAGE_SIZE#endif +extern int __pure debug_enabled (void ); + +#define pr_efi (sys_table, msg) do { \ + if (debug_enabled()) efi_printk(sys_table, "EFI stub: "msg); \ +} while (0)I was going to say that it's somewhat unfortunate to lose some of these messages by default, but I guess this only adds one additional round-trip when debugging a remote issue, and gives us the freedom to add more comprehensive debug messages in future.
Quoted 8 lines
Is the idea is to make the EFI stub completely silent in the successful case, or is the aim just to minimise the number of messages?
If it's only the latter, we could log a message regarding the existence of efi=debug in the default case, which might help with bug reports.
No strong feelings from me.
I guess we could simply look for 'quiet' instead, and invert the logic so we keep the current situation, but still allow for a pretty boot splash uncorrupted by meaningless printk's if we want to (and distros already use 'quiet' for exactly that purpose)