Skip to contentSkip to conversation

efi: Use standard format for printing the EFI revision

PATCH New Ard Biesheuvel 1 participant 1 message Jan 31, 2023 EFI

lore
Share & tools
lore

Ard Biesheuvel

author maintainer
#0 lore raw

PATCH 1/1 efi: Use standard format for printing the EFI revision

The UEFI spec section 4.2.1 describes the way the human readable EFI revision should be constructed from the 32-bit revision field in the system table:

The upper 16 bits of this field contain the major revision value, and the lower 16 bits contain the minor revision value. The minor revision values are binary coded decimals and are limited to the range of 00..99.

When printed or displayed UEFI spec revision is referred as (Major revision).(Minor revision upper decimal).(Minor revision lower decimal) or (Major revision).(Minor revision upper decimal) in case Minor revision lower decimal is set to 0.

Let's adhere to this when logging the EFI revision to the kernel log.

---
 drivers/firmware/efi/efi.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/firmware/efi/efi.c +7 -4
index 14797a0332c60bed..6bbc8cc6dc0d4d45 100644
@@ -806,6 +806,7 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
 	char vendor[100] = "unknown";
 	const efi_char16_t *c16;
 	size_t i;
+	int rev;
 
 	c16 = map_fw_vendor(fw_vendor, sizeof(vendor) * sizeof(efi_char16_t));
 	if (c16) {
@@ -816,10 +817,12 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
 		unmap_fw_vendor(c16, sizeof(vendor) * sizeof(efi_char16_t));
 	}
 
-	pr_info("EFI v%u.%.02u by %s\n",
-		systab_hdr->revision >> 16,
-		systab_hdr->revision & 0xffff,
-		vendor);
+	pr_info("EFI v%u.%u", systab_hdr->revision >> 16,
+		(systab_hdr->revision & 0xffff) / 10);
+	rev = (systab_hdr->revision & 0xffff) % 10;
+	if (rev)
+		pr_cont(".%u", rev);
+	pr_cont(" by %s\n", vendor);
 
 	if (IS_ENABLED(CONFIG_X86_64) &&
 	    systab_hdr->revision > EFI_1_10_SYSTEM_TABLE_REVISION &&
Signature · 1 line
2.39.0