Skip to contentSkip to conversation

efi_loader: console and network dependency improvements

PATCH Superseded Jan Kiszka 3 participants 17 messages Nov 4, 2022 – Nov 7, 2022

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
author
#12 lore raw

PATCH v3 2/3 efi_loader: Set default console colors on efi_cout_clear_screen if needed

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well.

---
 lib/efi_loader/efi_console.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/efi_loader/efi_console.c +6 -0
index 6ce0fcc168d..4228a509caf 100644
@@ -495,6 +495,12 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
 {
 	EFI_ENTRY("%p", this);
 
+	/* Set default colors if not done yet */
+	if (efi_con_mode.attribute == 0) {
+		efi_con_mode.attribute = 0x07;
+		printf(ESC "[0;37;40m");
+	}
+
 	efi_clear_screen();
 
 	return EFI_EXIT(EFI_SUCCESS);
Signature · 1 line
2.35.3

Jan Kiszka

author
#0 lore raw

v3 cover efi_loader: console and network dependency improvements

Update of previously sent patches

"efi_loader: Improve console screen clearing and reset" "efi_loader: Let networking support depend on NETDEVICES"

bundled into one series. Changes to earlier versions:

- rebased console reset improvements over master
- split up into overwrite protection and background color fix
- addressed missing efi_net_set_dhcp_ack symbol
- converted some #ifdefs to CONFIG_IS_ENABLED

Jan

Jan Kiszka (3):
efi_loader: Avoid overwriting previous outputs on console screen
clearing
efi_loader: Set default console colors on efi_cout_clear_screen if
needed
efi_loader: Let networking support depend on NETDEVICES

 include/efi_loader.h             | 10 +++++++---
 lib/efi_loader/Kconfig           |  1 -
 lib/efi_loader/Makefile          |  2 +-
 lib/efi_loader/efi_console.c     | 14 +++++++++++++-
 lib/efi_loader/efi_device_path.c |  8 +++-----
 lib/efi_loader/efi_setup.c       | 10 +++++-----
 lib/efi_selftest/Makefile        |  2 +-
 7 files changed, 30 insertions(+), 17 deletions(-)
Signature · 1 line
2.35.3
author
#1 lore raw

PATCH v3 1/3 efi_loader: Avoid overwriting previous outputs on console screen clearing

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
 lib/efi_loader/efi_console.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/efi_loader/efi_console.c +7 -1
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
 }
 
 /**
- * efi_cout_clear_screen() - clear screen
+ * efi_clear_screen() - clear screen
  */
 static void efi_clear_screen(void)
 {
+	unsigned int row;
+
+	/* Avoid overwriting previous outputs on streaming consoles */
+	for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+		printf("\n");
+
 	/*
 	 * The Linux console wants both a clear and a home command. The video
 	 * uclass does not support <ESC>[H without coordinates, yet.
Signature · 1 line
2.35.3
author
#16 lore raw

PATCH v3 3/3 efi_loader: Let networking support depend on NETDEVICES

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

CONFIG_NET does not imply that there are actually network devices available. Neither does CONFIG_NETDEVICES, but it is much closer, and changing to this dependency obsoletes the check in Kconfig because it means DM_ETH.

Along this change, make sure that efi_net_set_dhcp_ack is always defined, at least as stub.

---
 include/efi_loader.h             | 10 +++++++---
 lib/efi_loader/Kconfig           |  1 -
 lib/efi_loader/Makefile          |  2 +-
 lib/efi_loader/efi_device_path.c |  8 +++-----
 lib/efi_loader/efi_setup.c       | 10 +++++-----
 lib/efi_selftest/Makefile        |  2 +-
 6 files changed, 17 insertions(+), 16 deletions(-)
include/efi_loader.h +7 -3
index 0c6c95ba464..43816491a23 100644
@@ -94,8 +94,6 @@ void efi_restore_gd(void);
 /* Call this to set the current device name */
 void efi_set_bootdev(const char *dev, const char *devnr, const char *path,
 		     void *buffer, size_t buffer_size);
-/* Called by networking code to memorize the dhcp ack package */
-void efi_net_set_dhcp_ack(void *pkt, int len);
 /* Print information about all loaded images */
 void efi_print_image_infos(void *pc);
 
@@ -118,7 +116,6 @@ static inline void efi_restore_gd(void) { }
 static inline void efi_set_bootdev(const char *dev, const char *devnr,
 				   const char *path, void *buffer,
 				   size_t buffer_size) { }
-static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
 static inline void efi_print_image_infos(void *pc) { }
 static inline efi_status_t efi_launch_capsules(void)
 {
@@ -127,6 +124,13 @@ static inline efi_status_t efi_launch_capsules(void)
 
 #endif /* CONFIG_IS_ENABLED(EFI_LOADER) */
 
+#if CONFIG_IS_ENABLED(EFI_LOADER) && CONFIG_IS_ENABLED(NETDEVICES)
+/* Called by networking code to memorize the dhcp ack package */
+void efi_net_set_dhcp_ack(void *pkt, int len);
+#else
+static inline void efi_net_set_dhcp_ack(void *pkt, int len) { }
+#endif
+
 /* Maximum number of configuration tables */
 #define EFI_MAX_CONFIGURATION_TABLES 16
 
lib/efi_loader/Kconfig +0 -1
index 41756ea5396..68e6c2531e1 100644
@@ -11,7 +11,6 @@ config EFI_LOADER
 	# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
 	depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
 	depends on BLK
-	depends on DM_ETH || !NET
 	depends on !EFI_APP
 	default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
 	select CHARSET
lib/efi_loader/Makefile +1 -1
index f8e8afe1284..8738757dd2c 100644
@@ -68,7 +68,7 @@ obj-y += efi_watchdog.o
 obj-$(CONFIG_EFI_ESRT) += efi_esrt.o
 obj-$(CONFIG_VIDEO) += efi_gop.o
 obj-$(CONFIG_BLK) += efi_disk.o
-obj-$(CONFIG_NET) += efi_net.o
+obj-$(CONFIG_NETDEVICES) += efi_net.o
 obj-$(CONFIG_GENERATE_ACPI_TABLE) += efi_acpi.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += efi_smbios.o
 obj-$(CONFIG_EFI_RNG_PROTOCOL) += efi_rng.o
lib/efi_loader/efi_device_path.c +3 -5
index acae007f26f..171ee2b4679 100644
@@ -613,7 +613,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
 		*vdp = ROOT;
 		return &vdp[1];
 	}
-#ifdef CONFIG_NET
+#ifdef CONFIG_NETDEVICES
 	case UCLASS_ETH: {
 		struct efi_device_path_mac_addr *dp =
 			dp_fill(buf, dev->parent);
@@ -1052,7 +1052,7 @@ struct efi_device_path *efi_dp_from_uart(void)
 	return buf;
 }
 
-#ifdef CONFIG_NET
+#ifdef CONFIG_NETDEVICES
 struct efi_device_path *efi_dp_from_eth(void)
 {
 	void *buf, *start;
@@ -1169,10 +1169,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
 		return EFI_INVALID_PARAMETER;
 
 	if (!strcmp(dev, "Net")) {
-#ifdef CONFIG_NET
-		if (device)
+		if (CONFIG_IS_ENABLED(NETDEVICES) && device)
 			*device = efi_dp_from_eth();
-#endif
 	} else if (!strcmp(dev, "Uart")) {
 		if (device)
 			*device = efi_dp_from_uart();
lib/efi_loader/efi_setup.c +5 -5
index a340bc38806..cec799d93e2 100644
@@ -331,11 +331,11 @@ efi_status_t efi_init_obj_list(void)
 		if (ret != EFI_SUCCESS)
 			goto out;
 	}
-#ifdef CONFIG_NET
-	ret = efi_net_register();
-	if (ret != EFI_SUCCESS)
-		goto out;
-#endif
+	if (IS_ENABLED(CONFIG_NETDEVICES)) {
+		ret = efi_net_register();
+		if (ret != EFI_SUCCESS)
+			goto out;
+	}
 #ifdef CONFIG_GENERATE_ACPI_TABLE
 	ret = efi_acpi_register();
 	if (ret != EFI_SUCCESS)
lib/efi_selftest/Makefile +1 -1
index daac6c39682..e4d75420bff 100644
@@ -50,7 +50,7 @@ efi_selftest_variables_runtime.o \
 efi_selftest_watchdog.o
 
 obj-$(CONFIG_EFI_ECPT) += efi_selftest_ecpt.o
-obj-$(CONFIG_NET) += efi_selftest_snp.o
+obj-$(CONFIG_NETDEVICES) += efi_selftest_snp.o
 
 obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o
 obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \
Signature · 1 line
2.35.3
#2 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

In reply to Jan Kiszka

Hi,

Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Quoted 6 lines

Tested regarding multi-output against qemu-x86_defconfig.

---
 lib/efi_loader/efi_console.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Please see this thread...some things need to be improved in this area.

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 24 lines
lib/efi_loader/efi_console.c +7 -2
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
 }
 
 /**
- * efi_cout_clear_screen() - clear screen
+ * efi_clear_screen() - clear screen
  */
 static void efi_clear_screen(void)
 {
+       unsigned int row;
+
+       /* Avoid overwriting previous outputs on streaming consoles */
+       for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+               printf("\n");
+
        /*
         * The Linux console wants both a clear and a home command. The video
         * uclass does not support <ESC>[H without coordinates, yet.
--
Quoted 2 lines

2.35.3

Regards,
SImon

author
#3 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

Quoted 12 lines · Simon Glass

Hi,

Quoted 9 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

Quoted 9 lines
Quoted 4 lines
---
 lib/efi_loader/efi_console.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Please see this thread...some things need to be improved in this area.

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Is there a conclusion already? Is there something that I can attach to to resolve this issue here?

Jan

Quoted 29 lines
Quoted 24 lines
lib/efi_loader/efi_console.c +7 -2
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
 }
 
 /**
- * efi_cout_clear_screen() - clear screen
+ * efi_clear_screen() - clear screen
  */
 static void efi_clear_screen(void)
 {
+       unsigned int row;
+
+       /* Avoid overwriting previous outputs on streaming consoles */
+       for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+               printf("\n");
+
        /*
         * The Linux console wants both a clear and a home command. The video
         * uclass does not support <ESC>[H without coordinates, yet.
--
Quoted 2 lines

2.35.3

Regards,
SImon

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#4 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

Hi Jan,

Quoted 19 lines · Jan Kiszka
Quoted 17 lines · Simon Glass

Hi,

Quoted 13 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
 lib/efi_loader/efi_console.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 4 lines

Please see this thread...some things need to be improved in this area.

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Is there a conclusion already? Is there something that I can attach to to resolve this issue here?

So far as I am concerned, there is a conclusion :) I provided a lot of detail in the thread linked above.

We need to fix this properly (by suppressing ANSI output in logs) as these hacks (and others) are just annoying.

Regards,
SImon

#5 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

Quoted 24 lines · Simon Glass

Hi Jan,

Quoted 21 lines · Jan Kiszka
Quoted 19 lines · Simon Glass

Hi,

Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Quoted 6 lines

Tested regarding multi-output against qemu-x86_defconfig.

---
  lib/efi_loader/efi_console.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

Please see this thread...some things need to be improved in this area.

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Is there a conclusion already? Is there something that I can attach to to resolve this issue here?

So far as I am concerned, there is a conclusion :) I provided a lot of detail in the thread linked above.

Simon, if you want to filter output on the sandbox you may do so in the serial driver of the sandbox. It is not related to the UEFI code.

Best regards

Heinrich

Quoted 6 lines

We need to fix this properly (by suppressing ANSI output in logs) as these hacks (and others) are just annoying.

Regards,
SImon

#8 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

In reply to Jan Kiszka
Quoted 22 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
  lib/efi_loader/efi_console.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)
lib/efi_loader/efi_console.c +0 -1
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
  }
 
  /**
- * efi_cout_clear_screen() - clear screen

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_set_attribute( · line 473

Quoted 10 lines
lib/efi_loader/efi_console.c +7 -0
+ * efi_clear_screen() - clear screen
   */
  static void efi_clear_screen(void)
  {
+	unsigned int row;
+
+	/* Avoid overwriting previous outputs on streaming consoles */
+	for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+		printf("\n");
+

Scrolling on a framebuffer is a very expensive operations: For each of the 135 lines of an UHD display you have to copy 32 MiB. This would create a delay of multiple seconds on a slow device.

So keep the patch for your debugging purposed. But we cannot merge it into upstream.

Best regards

Heinrich

Quoted 3 lines
lib/efi_loader/efi_console.c +0 -0
  	/*
  	 * The Linux console wants both a clear and a home command. The video
  	 * uclass does not support <ESC>[H without coordinates, yet.
author
#9 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

Quoted 21 lines · Heinrich Schuchardt
Quoted 20 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
  lib/efi_loader/efi_console.c | 8 +++++++-

  1 file changed, 7 insertions(+), 1 deletion(-)
lib/efi_loader/efi_console.c +0 -0
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
   }
 
Quoted 16 lines

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_set_attribute( · line 473

Quoted 12 lines
lib/efi_loader/efi_console.c +7 -1
   /**
- * efi_cout_clear_screen() - clear screen
+ * efi_clear_screen() - clear screen
    */
   static void efi_clear_screen(void)
   {
+    unsigned int row;
+
+    /* Avoid overwriting previous outputs on streaming consoles */
+    for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+        printf("\n");
+

Scrolling on a framebuffer is a very expensive operations: For each of the 135 lines of an UHD display you have to copy 32 MiB. This would create a delay of multiple seconds on a slow device.

Thanks for explaining this - now. I didn't observe this delay in QEMU, but maybe that wasn't representative

Quoted 3 lines

So keep the patch for your debugging purposed. But we cannot merge it into upstream.

It's in production - we can't afford shipping without it.

To avoid that this will be the last patch between full upstream and our device one day: Do you see a way to confine overwrite protection to real streaming device, UARTs and such?

Thanks,
Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
author
#13 lore raw

Re: [PATCH v3 2/3] efi_loader: Set default console colors on efi_cout_clear_screen if needed

In reply to Jan Kiszka
Quoted 17 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well.

---
 lib/efi_loader/efi_console.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/efi_loader/efi_console.c +0 -0
index 6ce0fcc168d..4228a509caf 100644
@@ -495,6 +495,12 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
 {
 	EFI_ENTRY("%p", this);

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_clear_screen( · line 506

Quoted 10 lines
lib/efi_loader/efi_console.c +6 -0
 
+	/* Set default colors if not done yet */
+	if (efi_con_mode.attribute == 0) {
+		efi_con_mode.attribute = 0x07;
+		printf(ESC "[0;37;40m");
+	}
+
 	efi_clear_screen();
 
 	return EFI_EXIT(EFI_SUCCESS);

And what about this visual fix? It does not depend on patch 1.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
#14 lore raw

Re: [PATCH v3 2/3] efi_loader: Set default console colors on efi_cout_clear_screen if needed

In reply to Jan Kiszka
Quoted 4 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well.

To which sentence in the UEFI 2.10 spec are you relating?

Quoted 11 lines
---
  lib/efi_loader/efi_console.c | 6 ++++++
  1 file changed, 6 insertions(+)
lib/efi_loader/efi_console.c +0 -0
index 6ce0fcc168d..4228a509caf 100644

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_clear_screen( · line 501

Quoted 7 lines
lib/efi_loader/efi_console.c +4 -0
@@ -495,6 +495,12 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
  {
  	EFI_ENTRY("%p", this);
 
+	/* Set default colors if not done yet */
+	if (efi_con_mode.attribute == 0) {
+		efi_con_mode.attribute = 0x07;
+		printf(ESC "[0;37;40m");

These values are correct for CONFIG_SYS_WHITE_ON_BLACK=y. But for CONFIG_SYS_WHITE_ON_BLACK=n I would expect black letters on white as default.

This requires adding support background color values 100 - 107 (cf.
https://en.wikipedia.org/w/index.php?title=ANSI_escape_code&section=15#3-bit_and_4-bit)
in vidconsole_escape_char().

UEFI background color white should be translated to 107 if CONFIG_SYS_WHITE_ON_BLACK=n.

It seems this patch is trying to solve a problem caused by patch 1 of the series. Or do I miss something?

Best regards

Heinrich

Quoted 5 lines
lib/efi_loader/efi_console.c +2 -0
+	}
+
  	efi_clear_screen();
 
  	return EFI_EXIT(EFI_SUCCESS);
#10 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

In reply to Jan Kiszka
Quoted 39 lines · Jan Kiszka
Quoted 21 lines · Heinrich Schuchardt
Quoted 20 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
   lib/efi_loader/efi_console.c | 8 +++++++-
   1 file changed, 7 insertions(+), 1 deletion(-)
lib/efi_loader/efi_console.c +0 -0
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI efi_cout_set_attribute(
   }
 
Quoted 16 lines

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_set_attribute( · line 473

Quoted 12 lines
lib/efi_loader/efi_console.c +7 -1
   /**
- * efi_cout_clear_screen() - clear screen
+ * efi_clear_screen() - clear screen
    */
   static void efi_clear_screen(void)
   {
+    unsigned int row;
+
+    /* Avoid overwriting previous outputs on streaming consoles */
+    for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+        printf("\n");
+

Scrolling on a framebuffer is a very expensive operations: For each of the 135 lines of an UHD display you have to copy 32 MiB. This would create a delay of multiple seconds on a slow device.

Quoted 2 lines

Thanks for explaining this - now. I didn't observe this delay in QEMU, but maybe that wasn't representative

My BananaPi is really slow on it.

Quoted 10 lines
Quoted 4 lines

So keep the patch for your debugging purposed. But we cannot merge it into upstream.

It's in production - we can't afford shipping without it.

To avoid that this will be the last patch between full upstream and our device one day: Do you see a way to confine overwrite protection to real streaming device, UARTs and such?

How about putting this behind a Kconfig switch?

You probably should first move the cursor to the lower right corner before sending carriage returns and then place the cursor in the upper left corner. Otherwise you cannot be sure that you scrolled all of the text out of the visible area.

If you use scrolling, why would you still send an ANSI sequence for clear screen?

Best regards

Heinrich

Quoted 4 lines

Thanks,
Jan

#6 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

In reply to Heinrich Schuchardt

Hi Heinrich,

Quoted 29 lines · Heinrich Schuchardt
Quoted 27 lines · Simon Glass

Hi Jan,

Quoted 24 lines · Jan Kiszka
Quoted 21 lines · Simon Glass

Hi,

Quoted 7 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Quoted 6 lines

Tested regarding multi-output against qemu-x86_defconfig.

---
  lib/efi_loader/efi_console.c | 8 +++++++-
  1 file changed, 7 insertions(+), 1 deletion(-)

Please see this thread...some things need to be improved in this area.

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Is there a conclusion already? Is there something that I can attach to to resolve this issue here?

So far as I am concerned, there is a conclusion :) I provided a lot of detail in the thread linked above.

Simon, if you want to filter output on the sandbox you may do so in the serial driver of the sandbox. It is not related to the UEFI code.

From what I can tell this problem also affects the qemu CI tests. It seems that UEFI needs ANSI so this appears to be a UEFI thing. I haven't actually noticed any other use of ANSI sequences in some years of using U-Boot.

Regards,
Simon

#7 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

Quoted 38 lines · Simon Glass

Hi Heinrich,

Quoted 35 lines · Heinrich Schuchardt
Quoted 32 lines · Simon Glass

Hi Jan,

Quoted 19 lines · Jan Kiszka
Quoted 17 lines · Simon Glass

Hi,

Quoted 13 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
   lib/efi_loader/efi_console.c | 8 +++++++-
   1 file changed, 7 insertions(+), 1 deletion(-)
Quoted 7 lines
Quoted 4 lines

Please see this thread...some things need to be improved in this area.

https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

Is there a conclusion already? Is there something that I can attach to to resolve this issue here?

So far as I am concerned, there is a conclusion :) I provided a lot of detail in the thread linked above.

Quoted 7 lines
Quoted 4 lines

Simon, if you want to filter output on the sandbox you may do so in the serial driver of the sandbox. It is not related to the UEFI code.

From what I can tell this problem also affects the qemu CI tests. It

seems that UEFI needs ANSI so this appears to be a UEFI thing. I haven't actually noticed any other use of ANSI sequences in some years of using U-Boot.

Yes, you reviewed patch a085aa1f2737 ("dm: video: Add basic ANSI escape sequence support") exactly for this purpose.

Both CI tests on QEMU and sandbox pass. It is good that the CI sees exactly the same output as a productive system. We should not change that.

Best regards

Heinrich

author
#15 lore raw

Re: [PATCH v3 2/3] efi_loader: Set default console colors on efi_cout_clear_screen if needed

In reply to Heinrich Schuchardt
Quoted 8 lines · Heinrich Schuchardt
Quoted 4 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Ensures a consistent background color of the whole screen for succeeding outputs as both demanded by the spec and implemented in EDK2 as well.

To which sentence in the UEFI 2.10 spec are you relating?

12.4:

"EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.ClearScreen()

Clears the output device(s) display to the currently selected background color."

That generally works - except for this default case.

Quoted 23 lines
Quoted 11 lines

---
  lib/efi_loader/efi_console.c | 6 ++++++

  1 file changed, 6 insertions(+)
lib/efi_loader/efi_console.c +0 -0
index 6ce0fcc168d..4228a509caf 100644

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_clear_screen( · line 501

Quoted 7 lines
lib/efi_loader/efi_console.c +4 -0
@@ -495,6 +495,12 @@ static efi_status_t EFIAPI efi_cout_clear_screen(
   {
       EFI_ENTRY("%p", this);
 
+    /* Set default colors if not done yet */
+    if (efi_con_mode.attribute == 0) {
+        efi_con_mode.attribute = 0x07;
+        printf(ESC "[0;37;40m");

These values are correct for CONFIG_SYS_WHITE_ON_BLACK=y. But for CONFIG_SYS_WHITE_ON_BLACK=n I would expect black letters on white as default.

Quoted 6 lines

This requires adding support background color values 100 - 107 (cf.
https://en.wikipedia.org/w/index.php?title=ANSI_escape_code&section=15#3-bit_and_4-bit)
in vidconsole_escape_char().

UEFI background color white should be translated to 107 if CONFIG_SYS_WHITE_ON_BLACK=n.

I don't think we handle CONFIG_SYS_WHITE_ON_BLACK=n in UEFI so far. It likely requires translating all colors that apps so far select. Otherwise, you will end up with white-on-EFI_WHITE.

Quoted 3 lines

It seems this patch is trying to solve a problem caused by patch 1 of the series. Or do I miss something?

Not at all, problem persists if you drop that patch. I've accidentally accounted to "efi_loader: avoid EFI_CALL() for clearing screen", see
https://lore.kernel.org/u-boot/[email protected]/
for a screen shot.

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux
author
#11 lore raw

Re: [PATCH v3 1/3] efi_loader: Avoid overwriting previous outputs on console screen clearing

In reply to Heinrich Schuchardt
Quoted 52 lines · Heinrich Schuchardt
Quoted 41 lines · Jan Kiszka
Quoted 23 lines · Heinrich Schuchardt
Quoted 22 lines · Jan Kiszka

From: Jan Kiszka <[email protected]>

Before clearing the screen, ensure that no previous output of firmware or UEFI programs will be overwritten on serial devices or other streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig.

---
   lib/efi_loader/efi_console.c | 8 +++++++-

   1 file changed, 7 insertions(+), 1 deletion(-)
lib/efi_loader/efi_console.c +0 -0
index 4d08dd3763a..6ce0fcc168d 100644
@@ -461,10 +461,16 @@ static efi_status_t EFIAPI

efi_cout_set_attribute(
   }

Quoted 16 lines

lib/efi_loader/efi_console.c static efi_status_t EFIAPI efi_cout_set_attribute( · line 473

Quoted 12 lines

   /**
- * efi_cout_clear_screen() - clear screen
+ * efi_clear_screen() - clear screen
    */
   static void efi_clear_screen(void)
   {
+    unsigned int row;

lib/efi_loader/efi_console.c +5 -0
+
+    /* Avoid overwriting previous outputs on streaming consoles */
+    for (row = 1; row < efi_cout_modes[efi_con_mode.mode].rows; row++)
+        printf("\n");
+

Scrolling on a framebuffer is a very expensive operations: For each of the 135 lines of an UHD display you have to copy 32 MiB. This would create a delay of multiple seconds on a slow device.

Quoted 2 lines

Thanks for explaining this - now. I didn't observe this delay in QEMU, but maybe that wasn't representative

My BananaPi is really slow on it.

Quoted 5 lines
Quoted 4 lines

So keep the patch for your debugging purposed. But we cannot merge it into upstream.

Quoted 7 lines
Quoted 5 lines

It's in production - we can't afford shipping without it.

To avoid that this will be the last patch between full upstream and our device one day: Do you see a way to confine overwrite protection to real streaming device, UARTs and such?

How about putting this behind a Kconfig switch?

Sounds like a plan.

Quoted 5 lines

You probably should first move the cursor to the lower right corner before sending carriage returns and then place the cursor in the upper left corner. Otherwise you cannot be sure that you scrolled all of the text out of the visible area.

I'm scrolling based on the screen size so far. Not sure how moving the cursor should improve that.

Quoted 3 lines

If you use scrolling, why would you still send an ANSI sequence for clear screen?

Indeed, that should be unneeded. Or is there a cheaper way to scroll via ANSI sequences?

Jan

Signature · 2 lines
Siemens AG, Technology
Competence Center Embedded Linux