drivers/intel/fsp2_0: Fix string length handling in timestamp printing

The current implementation uses '%*s' which treats the calculated
str_len as a minimum field width. If the underlying string buffer is not
null-terminated, printk will continue reading past the buffer until it
encounters a null byte.

Switch to '%.*s' to correctly use the precision field, which specifies
the maximum number of characters to be printed from the string.

BUG=None
TEST=Able to dump FSP performance data with `DISPLAY_FSP_TIMESTAMPS`
Kconfig selected and meeting the FSP prerequisites. Verify that the
performance data table is printed correctly.

```
[INFO ]  +---------------------------------------------------+
[INFO ]  |------ FSP Performance Timestamp Table Dump -------|
[INFO ]  +---------------------------------------------------+
[INFO ]  | Perf-ID	Timestamp(us)		String/GUID |
[INFO ]  +---------------------------------------------------+
[INFO ]      0	         1242275		SEC/52c05b14-0b98-496c-bc3b04b50211d680
[INFO ]     50	         1242282		PEI/52c05b14-0b98-496c-bc3b04b50211d680
[INFO ]     40	         1242284		PreMem/52c05b14-0b98-496c-bc3b04b50211d680
```

Change-Id: Id95bd34b9c7d45d2c363339eb18adc5ac731c72b
Signed-off-by: Pranava Y N <pranavayn@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/90788
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Jérémy Compostella <jeremy.compostella@intel.com>
This commit is contained in:
Pranava Y N 2026-01-18 21:35:57 +05:30 committed by Jérémy Compostella
commit 4427a34b6b

View file

@ -51,7 +51,7 @@ static void print_guid_record(const struct generic_event_record *rec)
static void print_string_record(const struct generic_event_record *rec)
{
size_t str_len = rec->header.length - offsetof(struct generic_event_record, string);
printk(BIOS_INFO, "%5x\t%16llu\t\t%*s/",
printk(BIOS_INFO, "%5x\t%16llu\t\t%.*s/",
rec->progress_id, TIMESTAMP_TO_MICRO(rec->timestamp), (int)str_len, rec->string);
fsp_print_guid(BIOS_INFO, rec->guid);
printk(BIOS_INFO, "\n");