Skip to content

Commit 1758817

Browse files
committed
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. Note that the bit about binary coded decimals is bogus, and the minor revision lower decimal is simply the minor revision modulo 10, given the symbolic definitions provided by the spec itself: #define EFI_2_40_SYSTEM_TABLE_REVISION ((2<<16) | (40)) #define EFI_2_31_SYSTEM_TABLE_REVISION ((2<<16) | (31)) #define EFI_2_30_SYSTEM_TABLE_REVISION ((2<<16) | (30)) Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 234fa51 commit 1758817

File tree

1 file changed

+9
-4
lines changed
  • drivers/firmware/efi

1 file changed

+9
-4
lines changed

drivers/firmware/efi/efi.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,7 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
796796
char vendor[100] = "unknown";
797797
const efi_char16_t *c16;
798798
size_t i;
799+
u16 rev;
799800

800801
c16 = map_fw_vendor(fw_vendor, sizeof(vendor) * sizeof(efi_char16_t));
801802
if (c16) {
@@ -806,10 +807,14 @@ void __init efi_systab_report_header(const efi_table_hdr_t *systab_hdr,
806807
unmap_fw_vendor(c16, sizeof(vendor) * sizeof(efi_char16_t));
807808
}
808809

809-
pr_info("EFI v%u.%.02u by %s\n",
810-
systab_hdr->revision >> 16,
811-
systab_hdr->revision & 0xffff,
812-
vendor);
810+
rev = (u16)systab_hdr->revision;
811+
pr_info("EFI v%u.%u", systab_hdr->revision >> 16, rev / 10);
812+
813+
rev %= 10;
814+
if (rev)
815+
pr_cont(".%u", rev);
816+
817+
pr_cont(" by %s\n", vendor);
813818

814819
if (IS_ENABLED(CONFIG_X86_64) &&
815820
systab_hdr->revision > EFI_1_10_SYSTEM_TABLE_REVISION &&

0 commit comments

Comments
 (0)