linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
@ 2025-01-17  2:44 Hendrik 'T4cC0re' Meyer
  2025-01-19 17:11 ` Ard Biesheuvel
  0 siblings, 1 reply; 7+ messages in thread
From: Hendrik 'T4cC0re' Meyer @ 2025-01-17  2:44 UTC (permalink / raw)
  To: ardb; +Cc: linux-doc, linux-kernel, linux-efi,
	Hendrik 'T4cC0re' Meyer

While the general `quiet` kernel parameter is available to silence
output from the efistub, setting this comes with side-effects.
This patch adds a parameter efi=quiet to selectively set the loglevel
for the stub alone to quiet, as the polar oppoosite to efi=debug.

Signed-off-by: Hendrik 'T4cC0re' Meyer <linux@t4c.dev>
---
 Documentation/admin-guide/kernel-parameters.txt | 3 ++-
 drivers/firmware/efi/libstub/efi-stub-helper.c  | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 3872bc6ec..94a2f6ae7 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1454,7 +1454,7 @@
 	efi=		[EFI,EARLY]
 			Format: { "debug", "disable_early_pci_dma",
 				  "nochunk", "noruntime", "nosoftreserve",
-				  "novamap", "no_disable_early_pci_dma" }
+				  "novamap", "no_disable_early_pci_dma", "quiet" }
 			debug: enable misc debug output.
 			disable_early_pci_dma: disable the busmaster bit on all
 			PCI bridges while in the EFI boot stub.
@@ -1471,6 +1471,7 @@
 			novamap: do not call SetVirtualAddressMap().
 			no_disable_early_pci_dma: Leave the busmaster bit set
 			on all PCI bridges while in the EFI boot stub
+			quiet: disable most log messages.
 
 	efi_no_storage_paranoia [EFI,X86,EARLY]
 			Using this parameter you can use more than 50% of
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index c0c81ca42..b8ad629cc 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -97,6 +97,8 @@ efi_status_t efi_parse_options(char const *cmdline)
 				efi_disable_pci_dma = false;
 			if (parse_option_str(val, "debug"))
 				efi_loglevel = CONSOLE_LOGLEVEL_DEBUG;
+			if (parse_option_str(val, "quiet"))
+				efi_loglevel = CONSOLE_LOGLEVEL_QUIET;
 		} else if (!strcmp(param, "video") &&
 			   val && strstarts(val, "efifb:")) {
 			efi_parse_option_graphics(val + strlen("efifb:"));
-- 
2.47.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
  2025-01-17  2:44 [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone Hendrik 'T4cC0re' Meyer
@ 2025-01-19 17:11 ` Ard Biesheuvel
  2025-01-19 17:32   ` Hendrik 'T4cC0re' Meyer
  0 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2025-01-19 17:11 UTC (permalink / raw)
  To: linux; +Cc: linux-doc, linux-kernel, linux-efi

On Fri, 17 Jan 2025 at 03:46, Hendrik 'T4cC0re' Meyer <linux@t4c.dev> wrote:
>
> While the general `quiet` kernel parameter is available to silence
> output from the efistub, setting this comes with side-effects.
> This patch adds a parameter efi=quiet to selectively set the loglevel
> for the stub alone to quiet, as the polar oppoosite to efi=debug.
>
> Signed-off-by: Hendrik 'T4cC0re' Meyer <linux@t4c.dev>
> ---
>  Documentation/admin-guide/kernel-parameters.txt | 3 ++-
>  drivers/firmware/efi/libstub/efi-stub-helper.c  | 2 ++
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 3872bc6ec..94a2f6ae7 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -1454,7 +1454,7 @@
>         efi=            [EFI,EARLY]
>                         Format: { "debug", "disable_early_pci_dma",
>                                   "nochunk", "noruntime", "nosoftreserve",
> -                                 "novamap", "no_disable_early_pci_dma" }
> +                                 "novamap", "no_disable_early_pci_dma", "quiet" }
>                         debug: enable misc debug output.
>                         disable_early_pci_dma: disable the busmaster bit on all
>                         PCI bridges while in the EFI boot stub.
> @@ -1471,6 +1471,7 @@
>                         novamap: do not call SetVirtualAddressMap().
>                         no_disable_early_pci_dma: Leave the busmaster bit set
>                         on all PCI bridges while in the EFI boot stub
> +                       quiet: disable most log messages.
>
>         efi_no_storage_paranoia [EFI,X86,EARLY]
>                         Using this parameter you can use more than 50% of
> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index c0c81ca42..b8ad629cc 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
> @@ -97,6 +97,8 @@ efi_status_t efi_parse_options(char const *cmdline)
>                                 efi_disable_pci_dma = false;
>                         if (parse_option_str(val, "debug"))
>                                 efi_loglevel = CONSOLE_LOGLEVEL_DEBUG;
> +                       if (parse_option_str(val, "quiet"))
> +                               efi_loglevel = CONSOLE_LOGLEVEL_QUIET;
>                 } else if (!strcmp(param, "video") &&
>                            val && strstarts(val, "efifb:")) {
>                         efi_parse_option_graphics(val + strlen("efifb:"));

Hello Hendrik,

Could you explain the use case please? Your concern is that removing
'quiet' from the command line is producing a few additional lines of
output from the EFI stub at boot? How is that a problem compared to
the fact that you get the entire kernel log printed to the console? Is
every single line printed there relevant to you, and only the ones
emitted by the EFI stub are not?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
  2025-01-19 17:11 ` Ard Biesheuvel
@ 2025-01-19 17:32   ` Hendrik 'T4cC0re' Meyer
  2025-01-20  8:45     ` Ard Biesheuvel
  0 siblings, 1 reply; 7+ messages in thread
From: Hendrik 'T4cC0re' Meyer @ 2025-01-19 17:32 UTC (permalink / raw)
  To: ardb; +Cc: linux-doc, linux-efi, linux-kernel, linux

Hello!

> Could you explain the use case please? Your concern is that removing
'quiet' from the command line is producing a few additional lines of
output from the EFI stub at boot?

Sure :) I boot a UKI (with Secure Boot and TPM measurements)  with an
embedded splash image, and the cmdline
'memtest=2 earlyprintk=serial,ttyS0,115200 console=ttyS0,115200n8'

The stub by default (without 'quiet') will print messages regarding
the UKI and it being measured into the TPM on the efifb (I assume)
rendering on top of the displayed splash image.

"EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path"
 and "EFI stub: Measured initrd data into PCR 9" to be specific.

> How is that a problem compared to
the fact that you get the entire kernel log printed to the console?

Very relevant question. Because of the 'memtest=2' flag, there is a
delay during boot, which should be logged (with memtest progress) to
the serial console. 'quiet' will silence these logs.

> Is every single line printed there relevant to you, and only the ones
emitted by the EFI stub are not?

Basically, yes. I want the kernel's printk's, but not have the output
of the efistub dipsplayed on top of the splash screen of the UKI.

I did not find a way to redirect this output, and adding a 'efi=quiet'
option seemed like a low hanging fruit.

Hendrik


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
  2025-01-19 17:32   ` Hendrik 'T4cC0re' Meyer
@ 2025-01-20  8:45     ` Ard Biesheuvel
  2025-01-20  8:52       ` Hendrik 'T4cC0re' Meyer
  0 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2025-01-20  8:45 UTC (permalink / raw)
  To: Hendrik 'T4cC0re' Meyer; +Cc: linux-doc, linux-efi, linux-kernel

On Sun, 19 Jan 2025 at 18:32, Hendrik 'T4cC0re' Meyer <linux@t4c.dev> wrote:
>
> Hello!
>
> > Could you explain the use case please? Your concern is that removing
> 'quiet' from the command line is producing a few additional lines of
> output from the EFI stub at boot?
>
> Sure :) I boot a UKI (with Secure Boot and TPM measurements)  with an
> embedded splash image, and the cmdline
> 'memtest=2 earlyprintk=serial,ttyS0,115200 console=ttyS0,115200n8'
>
> The stub by default (without 'quiet') will print messages regarding
> the UKI and it being measured into the TPM on the efifb (I assume)
> rendering on top of the displayed splash image.
>
> "EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path"
>  and "EFI stub: Measured initrd data into PCR 9" to be specific.
>
> > How is that a problem compared to
> the fact that you get the entire kernel log printed to the console?
>
> Very relevant question. Because of the 'memtest=2' flag, there is a
> delay during boot, which should be logged (with memtest progress) to
> the serial console. 'quiet' will silence these logs.
>
> > Is every single line printed there relevant to you, and only the ones
> emitted by the EFI stub are not?
>
> Basically, yes. I want the kernel's printk's, but not have the output
> of the efistub dipsplayed on top of the splash screen of the UKI.
>
> I did not find a way to redirect this output, and adding a 'efi=quiet'
> option seemed like a low hanging fruit.
>

I'd prefer to just raise the verbosity level of those messages instead.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
  2025-01-20  8:45     ` Ard Biesheuvel
@ 2025-01-20  8:52       ` Hendrik 'T4cC0re' Meyer
  2025-01-20  8:54         ` Ard Biesheuvel
  0 siblings, 1 reply; 7+ messages in thread
From: Hendrik 'T4cC0re' Meyer @ 2025-01-20  8:52 UTC (permalink / raw)
  To: ardb; +Cc: linux-doc, linux-efi, linux-kernel, linux

> I'd prefer to just raise the verbosity level of those messages instead.

Agreed. I'll send in a new patch setting the verbosity of those messages one
above the default.

Hendrik

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
  2025-01-20  8:52       ` Hendrik 'T4cC0re' Meyer
@ 2025-01-20  8:54         ` Ard Biesheuvel
  2025-01-20  9:13           ` Hendrik 'T4cC0re' Meyer
  0 siblings, 1 reply; 7+ messages in thread
From: Ard Biesheuvel @ 2025-01-20  8:54 UTC (permalink / raw)
  To: Hendrik 'T4cC0re' Meyer; +Cc: linux-doc, linux-efi, linux-kernel

On Mon, 20 Jan 2025 at 09:53, Hendrik 'T4cC0re' Meyer <linux@t4c.dev> wrote:
>
> > I'd prefer to just raise the verbosity level of those messages instead.
>
> Agreed. I'll send in a new patch setting the verbosity of those messages one
> above the default.
>

Actually, let's do it the other way around. Does the below work for you?



--- a/drivers/firmware/efi/libstub/printk.c
+++ b/drivers/firmware/efi/libstub/printk.c
@@ -5,13 +5,13 @@
 #include <linux/ctype.h>
 #include <linux/efi.h>
 #include <linux/kernel.h>
-#include <linux/printk.h> /* For CONSOLE_LOGLEVEL_* */
+#include <linux/kern_levels.h>
 #include <asm/efi.h>
 #include <asm/setup.h>

 #include "efistub.h"

-int efi_loglevel = CONSOLE_LOGLEVEL_DEFAULT;
+int efi_loglevel = LOGLEVEL_NOTICE;

 /**
  * efi_char16_puts() - Write a UCS-2 encoded string to the console

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone
  2025-01-20  8:54         ` Ard Biesheuvel
@ 2025-01-20  9:13           ` Hendrik 'T4cC0re' Meyer
  0 siblings, 0 replies; 7+ messages in thread
From: Hendrik 'T4cC0re' Meyer @ 2025-01-20  9:13 UTC (permalink / raw)
  To: ardb; +Cc: linux-doc, linux-efi, linux-kernel, linux

> Does the below work for you?

Assuming 'efi_puts' logs as INFO level, yes. That should do the trick as well.

Thanks!

Hendrik

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-01-20  9:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17  2:44 [PATCH] efistub: add efi=quiet parameter to selectively silence efistub alone Hendrik 'T4cC0re' Meyer
2025-01-19 17:11 ` Ard Biesheuvel
2025-01-19 17:32   ` Hendrik 'T4cC0re' Meyer
2025-01-20  8:45     ` Ard Biesheuvel
2025-01-20  8:52       ` Hendrik 'T4cC0re' Meyer
2025-01-20  8:54         ` Ard Biesheuvel
2025-01-20  9:13           ` Hendrik 'T4cC0re' Meyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).