firmware: coreboot: Add CFR firmware attributes driver

coreboot can publish a CFR tree in its coreboot table to describe
firmware setup options. Add a firmware-attributes driver for that table
entry under the coreboot firmware driver directory.

The driver exposes runtime EFI variable-backed boolean, enum and integer
settings through the firmware-attributes ABI. It only registers settings
with readable runtime EFI variables, skips suppressed, volatile,
dependency-gated and non-runtime options, and keeps read-only or inactive
options read-only in sysfs.

For settings with an APM_CNT runtime-apply record, write the EFI
variable and ask firmware to apply the setting immediately with an I/O
port SMI command. If firmware reports a failure, restore the old EFI
variable value. Settings without a runtime apply hook keep the EFI
variable update and set pending_reboot. Depend on HAS_IOPORT because
APM_CNT uses legacy I/O ports.

Tested on a Star Labs Byte with firmware 26.07: runtime APM_CNT apply
was verified with power_led, and reboot-needed behavior was verified with
debug_level.

Link: https://doc.coreboot.org/drivers/cfr.html
Link: https://doc.coreboot.org/drivers/cfr_internal.html
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Link: https://lore.kernel.org/r/73204be94586622903da7fa90757fb091e8a7c2c.1788284852.git.sean@starlabs.systems
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
This commit is contained in:
Sean Rhodes 2026-09-01 18:48:05 +01:00 committed by Tzung-Bi Shih
parent 6f3adf358c
commit f2e05ce976
4 changed files with 1226 additions and 0 deletions

View File

@ -6716,6 +6716,12 @@ F: tools/testing/selftests/cgroup/test_hugetlb_memcg.c
F: tools/testing/selftests/cgroup/test_kmem.c
F: tools/testing/selftests/cgroup/test_memcontrol.c
COREBOOT CFR FIRMWARE ATTRIBUTES DRIVER
M: Sean Rhodes <sean@starlabs.systems>
L: chrome-platform@lists.linux.dev
S: Maintained
F: drivers/firmware/coreboot/coreboot-cfr.c
COREBOOT FIRMWARE DRIVERS
M: Tzung-Bi Shih <tzungbi@kernel.org>
R: Brian Norris <briannorris@chromium.org>

View File

@ -49,6 +49,21 @@ config COREBOOT_TABLE
device tree node /firmware/coreboot.
If unsure say N.
config COREBOOT_CFR
tristate "coreboot CFR firmware attributes"
depends on EFI
depends on COREBOOT_TABLE
depends on HAS_IOPORT
select CRC32
select FW_ATTR_CLASS
help
This driver parses the coreboot CFR table and exposes runtime EFI
variable-backed options through the firmware-attributes sysfs
interface.
If you have a system running coreboot with CFR runtime
configuration support, say Y or M here.
config COREBOOT_MEMCONSOLE_COMMON
tristate
depends on GOOGLE_MEMCONSOLE_X86_LEGACY || COREBOOT_MEMCONSOLE

View File

@ -2,6 +2,7 @@
obj-$(CONFIG_GOOGLE_SMI) += gsmi.o
obj-$(CONFIG_COREBOOT_TABLE) += coreboot_table.o
obj-$(CONFIG_COREBOOT_CFR) += coreboot-cfr.o
obj-$(CONFIG_COREBOOT_FRAMEBUFFER) += framebuffer-coreboot.o
obj-$(CONFIG_COREBOOT_MEMCONSOLE_COMMON) += memconsole.o
obj-$(CONFIG_COREBOOT_MEMCONSOLE) += memconsole-coreboot.o

File diff suppressed because it is too large Load Diff