Page MenuHomeFreeBSD

coreboot: Add coreboot firmware table driver
Needs ReviewPublic

Authored by guest-seuros on Wed, Mar 4, 2:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 9, 6:57 AM
Unknown Object (File)
Sun, Mar 8, 12:54 AM
Unknown Object (File)
Sat, Mar 7, 8:01 PM
Unknown Object (File)
Sat, Mar 7, 6:22 PM
Unknown Object (File)
Sat, Mar 7, 1:16 PM
Unknown Object (File)
Sat, Mar 7, 12:10 PM
Unknown Object (File)
Fri, Mar 6, 12:32 PM
Unknown Object (File)
Thu, Mar 5, 12:28 AM
Subscribers

Details

Summary

Nexus-attached driver that discovers and parses coreboot's LBIO tables
from physical memory. Exposes firmware metadata (version, build info,
mainboard, serial config, TSC frequency, CBMEM entries) via sysctl
hw.coreboot.*, the firmware console ring buffer via /dev/coreboot_console,
and structured CBMEM entry access via /dev/cbmem ioctl interface.

Tested on:

  • Qotom Q535G6 (Kabylake)
  • Intel NUC D54250WYK (Haswell)
  • Intel NUC D33217GKE (Ivy Bridge)
  • Dell 3100 2-in-1 (Gabbiter)
  • Dell 3100 (Fleex)
  • Lenovo IdeaPad 320s
  • Lenovo ThinkPad T480
Test Plan

This requires a machine with recent coreboot version, older version fall gracefully in the value that they don't expose.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 71179
Build 68062: arc lint + arc unit

Event Timeline

guest-seuros held this revision as a draft.

I tested this in multiple board as each hardware expose a different set of registry.

The Dells and the Thinkpad are standard coreboot machines, the others i corebooted them. (currently trying to pipeline them to get into coreboot mainline)

I also have a userland utility that use these sysctl instead of parsing the memory log.

Wow, this is interesting. I've been running FreeBSD coreboot for many years, I'll test this next week on my APU2.

share/man/man4/coreboot.4
3

please consider seeing style(9) for the preferred way to do this now

This is cool functionality. Are there any of the tagged data times that the boot loader should be looking at to pass into the kernel via its metadata interface that we get from other locations and coreboot doesn't provide those interfaces so we leave it blank?
Or are we already doing this, and this commit just exposes the data in a new way.
love 'dmesg for coreboot' parts especially.

@imp This initial driver is basic for now and expose activity/timing that happen since power-on. You can see the Dram training, and any delay on the EUFI/Bios

The userland utility is here, once the code is stable and this driver accepted, i could propose to coreboot to adopt the code for freebsd. Their code is linux only.

The coreboot's cbmem approach is just parsing memory.
the cbmem-freebsd leverage this driver to by using the sysctl.

Installing this driver lead me to discover i had a defective ram in one machine and also it exposed D55662.

The are some possible deduplication possible such as passing the framebuffer and cpu frequency directly from coreboot to the kernel but... the Lenovos expose it, the others don't.

This could be interesting for appliances that want to boot in seconds. (firewalls/NAS)

share/man/man4/coreboot.4
3

i update my template file snippet.

Thanks

share/man/man4/coreboot.4
61

IMO using some mdoc list or enumeration would be somewhat better WRT the structuring of the text.

68

I think it is better to say 'A character device that exposes the read-only access to the CBMEM firmware console ring buffer', or similar. cdevs cannot be read-only, but access they provide can.

329

I thought that BUGS/CAVEATS should come before HISTORY.

sys/dev/coreboot/coreboot.c
36

sys/param.h is not needed. sys/systm.h is guaranteed to provide it.

102

Could the signature placed at paddr 0?

1143

Why the re-check is needed? scan only returns non-zero if the signature is correct.

1163

Could it be that we find some random signature bytes, which are really not the signature, and lock on them? Then, of course, the sanity checking failing, and the driver does not attach.

I mean, if validation failed, should we continue to scan for signature and retry if found again?

1317

This code seems to be duplicated at least once. Could it be moved to a helper function instead of copy/pasting?

sys/dev/coreboot/coreboot.h
109

What do you mean by 'starts at physical address'?

201

What is the format for timestamp? Is it unix time in seconds?

608

You do not need 'extern'.

sys/dev/coreboot/coreboot_cbmem.c
182

I suggest to use make_dev_s(9). It avoids the race with si_drv1 being NULL some time after the devfs node is created. Also you could request an error instead of panic if the node name was somehow already used.