Kyösti Mälkki has uploaded this change for review.

View Change

usbdebug: Fix reserve in CAR

We need sizeof(struct ehci_dbg_info) of 88 but only
reserved 64 bytes. If usbdebug_hw_init() was called
late in romstage, for some builds it would corrupt
CAR_GLOBALs like console_inited variable and stop
logging anything.

Also change pointer initialisation such that
glob_dbg_info will hit garbage collection for
PRE_RAM stages.

Change-Id: Ib49fca781e55619179aa8888e2d859560e050876
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
---
M src/arch/x86/car.ld
M src/drivers/usb/ehci_debug.c
2 files changed, 9 insertions(+), 8 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/74/31174/1
diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld
index 7b10f43..3f33702 100644
--- a/src/arch/x86/car.ld
+++ b/src/arch/x86/car.ld
@@ -67,7 +67,7 @@
_car_drivers_storage_end = .;
#endif
_car_ehci_dbg_info_start = .;
- . += 64;
+ . += 0x60;
_car_ehci_dbg_info_end = .;
/* _car_global_start and _car_global_end provide symbols to per-stage
* variables that are not shared like the timestamp and the pre-ram
diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c
index 18d0491..04272e6 100644
--- a/src/drivers/usb/ehci_debug.c
+++ b/src/drivers/usb/ehci_debug.c
@@ -66,13 +66,14 @@

static inline struct ehci_debug_info *dbgp_ehci_info(void)
{
- if (IS_ENABLED(CONFIG_USBDEBUG_IN_PRE_RAM)
- && (ENV_ROMSTAGE || ENV_BOOTBLOCK || ENV_VERSTAGE))
- glob_dbg_info_p =
- (struct ehci_debug_info *)_car_ehci_dbg_info_start;
- if (car_get_var(glob_dbg_info_p) == NULL)
- car_set_var(glob_dbg_info_p, &glob_dbg_info);
-
+ if (car_get_var(glob_dbg_info_p) == NULL) {
+ struct ehci_debug_info *info;
+ if (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE)
+ info = (void *)_car_ehci_dbg_info_start;
+ else
+ info = &glob_dbg_info;
+ car_set_var(glob_dbg_info_p, info);
+ }
return car_get_var(glob_dbg_info_p);
}


To view, visit change 31174. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Ib49fca781e55619179aa8888e2d859560e050876
Gerrit-Change-Number: 31174
Gerrit-PatchSet: 1
Gerrit-Owner: Kyösti Mälkki <kyosti.malkki@gmail.com>
Gerrit-MessageType: newchange