Page MenuHomeFreeBSD

smbios: support getting address from EFI
ClosedPublic

Authored by greg_unrelenting.technology on Mar 15 2021, 8:53 PM.

Details

Summary

On some systems (e.g. Lenovo ThinkPad X240, Apple MacBookPro12,1) the SMBIOS entry point is not found in the <0xFFFFF space.

Follow the SMBIOS spec and use the EFI Configuration Table for locating the entry point on EFI systems.


I'm not sure if I need any other conditionals to like, exclude kernels built without EFI support… (if anyone cares about that)

Test Plan

Boot on various systems that didn't attach smbios before, observe smbios attaching with fancy high addresses.

Thinkpad:

[17] smbios0: <System Management BIOS> at iomem 0xbcd3d000-0xbcd3d01e
[17] smbios0: Version: 2.7, BCD Revision: 2.7

MacBook:

[91] smbios0: <System Management BIOS> at iomem 0x8afad000-0x8afad01e
[91] smbios0: Version: 2.7

Diff Detail

Repository
rG FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

oops, forgot efi.h change

sys/sys/efi.h
41

These don't seem to be used anywhere in the tree.

This looks grossly correct to me, but it's been a long time since I've thought about this stuff. IIRC @ambrisko did some stuff with SMBIOS a ways back; Doug?

Has this been testing on systems without UEFI BIOS? I'm not sure what happens if efirt is loaded on a non-UEFI system? Please include testing on non UEFI system and UEFI system. QEMU can be used to test in legacy BIOS mode. Please include testing results from both environments. FYI, the loader should set hint.smbios.0.mem in UEFI mode so that can be used a quick check on the address. It is good to verify the address is not in the BIOS range when testing. Some UEFI systems have a combined legacy and UEFI env.

I'm not sure what happens if efirt is loaded on a non-UEFI system?

options EFIRT is in GENERIC.

sys/dev/smbios/smbios.c
36

It would be nice to spell this #if ARCH_MAY_USE_EFI so this condition doesn't proliferate. Every arch already has <machine/efi.h>, so it would be easy to add.

83

I would prefer to put this on the stack instead of permanently wasting 16 bytes.

89

This should go under the same #if as efi_smbios.

Looks pretty good. I would agree that it should be tested on a LEGACY (non-UEFI) BIOS.

sys/dev/smbios/smbios.c
36

+1

  • options EFIRT is not in MINIMAL, so now device smbios can't be either, so kldload smbios would be the way to go in MINIMAL
  • address feedback
vangyzen added inline comments.
sys/dev/smbios/smbios.c
49

<sys/efi.h> already includes <machine/efi.h>, so this is not needed.

This revision is now accepted and ready to land.Mar 31 2021, 10:11 PM

oops, thought I did remove that include, but somehow didn't

This revision now requires review to proceed.Apr 1 2021, 1:29 PM

@greg_unrelenting.technology Please look back over the comments from @ambrisko . In particular, I'd like to see testing on a non-UEFI system.

@rpokala or @ambrisko Would you like to take another look?

This revision is now accepted and ready to land.Apr 2 2021, 3:24 PM

Code LGTM. ==@ambrisko WRT testing on legacy BIOS platforms.

smbios still attaches on a bhyve VM running FreeBSD main plus this change, booting in Legacy BIOS mode. The device address did not change, of course.

smbios0: <System Management BIOS> at iomem 0xf1000-0xf101e
smbios0: Version: 2.6, BCD Revision: 2.6
This revision was automatically updated to reflect the committed changes.