efi: Use standard format for printing the EFI revision
authorArd Biesheuvel <ardb@kernel.org>
Mon, 30 Jan 2023 18:50:55 +0000 (19:50 +0100)
committerArd Biesheuvel <ardb@kernel.org>
Fri, 3 Feb 2023 17:09:00 +0000 (18:09 +0100)
commit1758817e7ea822b1a7d1b95f0c35dd80d120805b
tree56c555177859af4b16bbe6d8f9fbecd1687fa6de
parent234fa51db95f3236a049557db735606908747f38
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 <ardb@kernel.org>
drivers/firmware/efi/efi.c