coreboot CFR firmware attributes
Subsystems (14)
Sean Rhodes
maintainerv10 cover coreboot CFR firmware attributes
This series moves the firmware attributes class helper out of platform/x86, renames the coreboot table firmware directory, and adds a coreboot CFR firmware-attributes driver.
Changes in v10:
- Rename the generic firmware Kconfig symbols from GOOGLE_* to COREBOOT_* and keep the old names as transitional symbols, as suggested by Julius.
- Update the arm64 defconfig, DRM coreboot framebuffer dependency, and coreboot Makefile users to the new symbols.
- Keep the v9 driver fixes and helper include-order split.
GOOGLE_SMI, GOOGLE_MEMCONSOLE_X86_LEGACY and GOOGLE_VPD keep their existing names because those drivers remain Google-specific.
Sean Rhodes (4):
platform/x86: Sort firmware attributes class includes
firmware: Move firmware attributes class helper
firmware: Rename google firmware directory to coreboot
firmware: coreboot: Add CFR firmware attributes driver
MAINTAINERS | 18 +-
arch/arm64/configs/defconfig | 6 +-
drivers/firmware/Kconfig | 5 +-
drivers/firmware/Makefile | 3 +-
drivers/firmware/{google => coreboot}/Kconfig | 88 +-
drivers/firmware/coreboot/Makefile | 15 +
drivers/firmware/{google => coreboot}/cbmem.c | 0
drivers/firmware/coreboot/coreboot-cfr.c | 1193 +++++++++++++++++
.../{google => coreboot}/coreboot_table.c | 0
.../{google => coreboot}/coreboot_table.h | 0
.../framebuffer-coreboot.c | 0
drivers/firmware/{google => coreboot}/gsmi.c | 0
.../memconsole-coreboot.c | 0
.../memconsole-x86-legacy.c | 0
.../{google => coreboot}/memconsole.c | 0
.../{google => coreboot}/memconsole.h | 6 +-
drivers/firmware/{google => coreboot}/vpd.c | 0
.../{google => coreboot}/vpd_decode.c | 0
.../{google => coreboot}/vpd_decode.h | 0
.../firmware_attributes_class.c | 2 +-
drivers/firmware/google/Makefile | 14 -
drivers/gpu/drm/sysfb/Kconfig | 2 +-
drivers/platform/x86/Kconfig | 3 -
drivers/platform/x86/Makefile | 2 -
drivers/platform/x86/asus-armoury.c | 2 +-
.../x86/dell/dell-wmi-sysman/sysman.c | 9 +-
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 9 +-
drivers/platform/x86/lenovo/think-lmi.c | 5 +-
drivers/platform/x86/lenovo/wmi-other.c | 2 +-
drivers/platform/x86/samsung-galaxybook.c | 3 +-
.../linux/firmware_attributes.h | 6 +-
31 files changed, 1328 insertions(+), 65 deletions(-)
rename drivers/firmware/{google => coreboot}/Kconfig (57%)
create mode 100644 drivers/firmware/coreboot/Makefile
rename drivers/firmware/{google => coreboot}/cbmem.c (100%)
create mode 100644 drivers/firmware/coreboot/coreboot-cfr.c
rename drivers/firmware/{google => coreboot}/coreboot_table.c (100%)
rename drivers/firmware/{google => coreboot}/coreboot_table.h (100%)
rename drivers/firmware/{google => coreboot}/framebuffer-coreboot.c (100%)
rename drivers/firmware/{google => coreboot}/gsmi.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole-coreboot.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole-x86-legacy.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole.h (82%)
rename drivers/firmware/{google => coreboot}/vpd.c (100%)
rename drivers/firmware/{google => coreboot}/vpd_decode.c (100%)
rename drivers/firmware/{google => coreboot}/vpd_decode.h (100%)
rename drivers/{platform/x86 => firmware}/firmware_attributes_class.c (94%)
delete mode 100644 drivers/firmware/google/Makefile
rename drivers/platform/x86/firmware_attributes_class.h => include/linux/firmware_attributes.h (60%)Sean Rhodes
maintainerPATCH v10 1/4 platform/x86: Sort firmware attributes class includes
Move firmware_attributes_class.h into the main include block and sort the affected includes. This lets the header move replace each include in place.
--- drivers/platform/x86/asus-armoury.c | 2 +- drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 9 +++++---- drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 9 +++++---- drivers/platform/x86/lenovo/think-lmi.c | 5 +++-- drivers/platform/x86/lenovo/wmi-other.c | 2 +- drivers/platform/x86/samsung-galaxybook.c | 3 ++- 6 files changed, 17 insertions(+), 13 deletions(-)
drivers/platform/x86/asus-armoury.c +1 -1
@@ -20,6 +20,7 @@#include <linux/dmi.h> #include <linux/err.h> #include <linux/errno.h> +#include "firmware_attributes_class.h" #include <linux/fs.h> #include <linux/kernel.h> #include <linux/kmod.h>
@@ -34,7 +35,6 @@#include <linux/sysfs.h> #include "asus-armoury.h" -#include "firmware_attributes_class.h" #define ASUS_NB_WMI_EVENT_GUID "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +5 -4
@@ -8,18 +8,19 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/align.h> -#include <linux/fs.h> #include <linux/dmi.h> -#include <linux/module.h> +#include "../../firmware_attributes_class.h" +#include <linux/fs.h> #include <linux/kernel.h> +#include <linux/module.h> +#include <linux/nls.h> #include <linux/string.h> #include <linux/sysfs.h> #include <linux/wmi.h> +#include "dell-wmi-sysman.h" -#include "../../firmware_attributes_class.h" #define MAX_TYPES 4 -#include <linux/nls.h> struct wmi_sysman_priv wmi_priv = { .mutex =__MUTEX_INITIALIZER (wmi_priv.mutex),
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +5 -4
@@ -7,16 +7,17 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt +#include <linux/errno.h> +#include "../../firmware_attributes_class.h" #include <linux/fs.h> -#include <linux/module.h> #include <linux/kernel.h> +#include <linux/module.h> +#include <linux/nls.h> #include <linux/printk.h> #include <linux/string.h> #include <linux/wmi.h> +#include "bioscfg.h" -#include "../../firmware_attributes_class.h" -#include <linux/nls.h> -#include <linux/errno.h> MODULE_AUTHOR ("Jorge Lopez <[email protected]>" );MODULE_DESCRIPTION ("HP BIOS Configuration Driver" );
drivers/platform/x86/lenovo/think-lmi.c +3 -2
@@ -13,14 +13,15 @@#include <linux/acpi.h> #include <linux/array_size.h> +#include <linux/dmi.h> #include <linux/errno.h> +#include "../firmware_attributes_class.h" #include <linux/fs.h> #include <linux/mutex.h> #include <linux/string_helpers.h> #include <linux/types.h> -#include <linux/dmi.h> #include <linux/wmi.h> -#include "../firmware_attributes_class.h" +#include "think-lmi.h" static bool debug_support;
drivers/platform/x86/lenovo/wmi-other.c +1 -1
@@ -33,6 +33,7 @@#include <linux/container_of.h> #include <linux/device.h> #include <linux/export.h> +#include "../firmware_attributes_class.h" #include <linux/gfp_types.h> #include <linux/hwmon.h> #include <linux/idr.h>
@@ -50,7 +51,6 @@#include "wmi-capdata.h" #include "wmi-events.h" #include "wmi-helpers.h" -#include "../firmware_attributes_class.h" #define LENOVO_OTHER_MODE_GUID "DC2A8805-3A8C-41BA-A6F7-092E0089CD3B"
drivers/platform/x86/samsung-galaxybook.c +2 -1
@@ -14,6 +14,7 @@#include <linux/acpi.h> #include <linux/bits.h> #include <linux/err.h> +#include "firmware_attributes_class.h" #include <linux/i8042.h> #include <linux/init.h> #include <linux/input.h>
@@ -27,8 +28,8 @@#include <linux/sysfs.h> #include <linux/uuid.h> #include <linux/workqueue.h> +#include <acpi/battery.h> -#include "firmware_attributes_class.h" #define DRIVER_NAME "samsung-galaxybook"
Sean Rhodes
maintainerPATCH v10 2/4 firmware: Move firmware attributes class helper
In reply to Sean RhodesMove the firmware attributes class helper from drivers/platform/x86 to drivers/firmware and expose its class declaration through a public Linux header.
The helper is not x86-specific. Keeping it in firmware lets coreboot firmware drivers use the standard firmware-attributes ABI without living under platform/x86.
---
MAINTAINERS | 8 ++++++++
drivers/firmware/Kconfig | 3 +++
drivers/firmware/Makefile | 1 +
.../x86 => firmware}/firmware_attributes_class.c | 2 +-
drivers/platform/x86/Kconfig | 3 ---
drivers/platform/x86/Makefile | 2 --
drivers/platform/x86/asus-armoury.c | 2 +-
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c | 2 +-
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 2 +-
drivers/platform/x86/lenovo/think-lmi.c | 2 +-
drivers/platform/x86/lenovo/wmi-other.c | 2 +-
drivers/platform/x86/samsung-galaxybook.c | 2 +-
.../linux/firmware_attributes.h | 6 +++---
13 files changed, 22 insertions(+), 15 deletions(-)
rename drivers/{platform/x86 => firmware}/firmware_attributes_class.c (94%)
rename drivers/platform/x86/firmware_attributes_class.h => include/linux/firmware_attributes.h (60%)MAINTAINERS +8 -0
@@ -10115,6 +10115,14 @@ F: include/linux/firewire.h F: include/uapi/linux/firewire*.h F: tools/firewire/ +FIRMWARE ATTRIBUTES CLASS +M: Hans de Goede <[email protected]> +M: Ilpo Järvinen <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/firmware_attributes_class.c +F: include/linux/firmware_attributes.h + FIRMWARE FRAMEWORK FOR ARMV8-A M: Sudeep Holla <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/firmware/Kconfig +3 -0
@@ -8,6 +8,9 @@ menu "Firmware Drivers" source "drivers/firmware/arm_scmi/Kconfig" +config FW_ATTR_CLASS + tristate + config ARM_SCPI_PROTOCOL tristate "ARM System Control and Power Interface (SCPI) Message Protocol" depends on ARM || ARM64 || COMPILE_TEST
drivers/firmware/Makefile +1 -0
@@ -16,6 +16,7 @@ obj-$(CONFIG_FIRMWARE_MEMMAP) += memmap.o obj-$(CONFIG_MTK_ADSP_IPC) += mtk-adsp-ipc.o obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o +obj-$(CONFIG_FW_ATTR_CLASS) += firmware_attributes_class.o obj-$(CONFIG_SYSFB) += sysfb.o obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o obj-$(CONFIG_TH1520_AON_PROTOCOL) += thead,th1520-aon.o
drivers/firmware/firmware_attributes_class.c renamed from drivers/platform/x86/firmware_attributes_class.c +1 -1
@@ -3,7 +3,7 @@/* Firmware attributes class helper module */ #include <linux/module.h> -#include "firmware_attributes_class.h" +#include <linux/firmware_attributes.h> const struct class firmware_attributes_class = { .name ="firmware-attributes" ,
drivers/platform/x86/Kconfig +0 -3
@@ -926,9 +926,6 @@ config DASHARO_ACPI source "drivers/platform/x86/x86-android-tablets/Kconfig" -config FW_ATTR_CLASS - tristate - config INTEL_IMR bool "Intel Isolated Memory Region support" depends on X86_INTEL_QUARK && IOSF_MBI
drivers/platform/x86/Makefile +0 -2
@@ -63,8 +63,6 @@ obj-$(CONFIG_X86_PLATFORM_DRIVERS_HP) += hp/ # Hewlett Packard Enterprise obj-$(CONFIG_UV_SYSFS) += uv_sysfs.o -obj-$(CONFIG_FW_ATTR_CLASS) += firmware_attributes_class.o - # IBM Thinkpad (before 2005) obj-$(CONFIG_IBM_RTL) += ibm_rtl.o obj-$(CONFIG_SENSORS_HDAPS) += hdaps.o
drivers/platform/x86/asus-armoury.c +1 -1
@@ -20,7 +20,7 @@#include <linux/dmi.h> #include <linux/err.h> #include <linux/errno.h> -#include "firmware_attributes_class.h" +#include <linux/firmware_attributes.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/kmod.h>
drivers/platform/x86/dell/dell-wmi-sysman/sysman.c +1 -1
@@ -9,7 +9,7 @@#include <linux/align.h> #include <linux/dmi.h> -#include "../../firmware_attributes_class.h" +#include <linux/firmware_attributes.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/module.h>
drivers/platform/x86/hp/hp-bioscfg/bioscfg.c +1 -1
@@ -8,7 +8,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/errno.h> -#include "../../firmware_attributes_class.h" +#include <linux/firmware_attributes.h> #include <linux/fs.h> #include <linux/kernel.h> #include <linux/module.h>
drivers/platform/x86/lenovo/think-lmi.c +1 -1
@@ -15,7 +15,7 @@#include <linux/array_size.h> #include <linux/dmi.h> #include <linux/errno.h> -#include "../firmware_attributes_class.h" +#include <linux/firmware_attributes.h> #include <linux/fs.h> #include <linux/mutex.h> #include <linux/string_helpers.h>
drivers/platform/x86/lenovo/wmi-other.c +1 -1
@@ -33,7 +33,7 @@#include <linux/container_of.h> #include <linux/device.h> #include <linux/export.h> -#include "../firmware_attributes_class.h" +#include <linux/firmware_attributes.h> #include <linux/gfp_types.h> #include <linux/hwmon.h> #include <linux/idr.h>
drivers/platform/x86/samsung-galaxybook.c +1 -1
@@ -14,7 +14,7 @@#include <linux/acpi.h> #include <linux/bits.h> #include <linux/err.h> -#include "firmware_attributes_class.h" +#include <linux/firmware_attributes.h> #include <linux/i8042.h> #include <linux/init.h> #include <linux/input.h>
include/linux/firmware_attributes.h renamed from drivers/platform/x86/firmware_attributes_class.h +3 -3
@@ -2,11 +2,11 @@/* Firmware attributes class helper module */ -#ifndef FW_ATTR_CLASS_H -#define FW_ATTR_CLASS_H +#ifndef _LINUX_FIRMWARE_ATTRIBUTES_H +#define _LINUX_FIRMWARE_ATTRIBUTES_H#include <linux/device/class.h> extern const struct class firmware_attributes_class; -#endif /* FW_ATTR_CLASS_H */ +#endif /* _LINUX_FIRMWARE_ATTRIBUTES_H */
[email protected]
AI reviewRe: [PATCH v10 2/4] firmware: Move firmware attributes class helper
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The asus-armoury driver incorrectly uses device_destroy() with MKDEV(0,0), which can destroy other drivers' firmware attribute devices. --
--- Patch [2]: [PATCH v10 2/4] firmware: Move firmware attributes class helper --- commit 054683b4de0166df7f1b8f201cf00b84efd05b62
Author: Sean Rhodes <[email protected]>
firmware: Move firmware attributes class helper
Move the firmware attributes class helper from drivers/platform/x86 to drivers/firmware and expose its class declaration through a public Linux header. The helper is not x86-specific, allowing coreboot firmware drivers to use the standard ABI without living under platform/x86.
[ ... ]
drivers/platform/x86/asus-armoury.c line 23
Quoted 10 lines
drivers/platform/x86/asus-armoury.c +1
-1@@ -20,7 +20,7 @@#include <linux/dmi.h> #include <linux/err.h> #include <linux/errno.h> -#include "firmware_attributes_class.h" +#include <linux/firmware_attributes.h>
[Severity: High]
This is a pre-existing issue, but I noticed a potential problem with how this class is used in this driver.
In asus_fw_attr_add() (on the error path) and asus_fw_exit(), the driver calls:
device_destroy(&firmware_attributes_class, MKDEV(0, 0));
device_destroy() uses class_find_device_by_devt() to find the first device matching the devt (which is MKDEV(0,0)).
Multiple drivers in this class (like dell-wmi-sysman or think-lmi) create devices with devt=0.
Will this indiscriminately destroy another driver's device instead of the one belonging to asus-armoury?
If another firmware attributes driver is active, could this leave the victim driver with a dangling device pointer, leading to a crash when it unloads and calls device_unregister(), while leaking the actual asus-armoury device?
Quoted 3 lines
drivers/platform/x86/asus-armoury.c +0
-0#include <linux/fs.h> #include <linux/kernel.h> #include <linux/kmod.h>
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
Sean Rhodes
maintainerPATCH v10 3/4 firmware: Rename google firmware directory to coreboot
In reply to Sean RhodesMost drivers in drivers/firmware/google are coreboot table drivers rather than Google-specific firmware drivers. Rename the directory to coreboot and update the Kconfig prompt, build path and maintainer entry.
Rename the generic coreboot Kconfig symbols at the same time. Keep the old CONFIG_GOOGLE_* names as transitional symbols so existing configurations migrate to the new names.
---
MAINTAINERS | 4 +-
arch/arm64/configs/defconfig | 6 +-
drivers/firmware/Kconfig | 2 +-
drivers/firmware/Makefile | 2 +-
drivers/firmware/{google => coreboot}/Kconfig | 74 ++++++++++++++-----
.../firmware/{google => coreboot}/Makefile | 10 +--
drivers/firmware/{google => coreboot}/cbmem.c | 0
.../{google => coreboot}/coreboot_table.c | 0
.../{google => coreboot}/coreboot_table.h | 0
.../framebuffer-coreboot.c | 0
drivers/firmware/{google => coreboot}/gsmi.c | 0
.../memconsole-coreboot.c | 0
.../memconsole-x86-legacy.c | 0
.../{google => coreboot}/memconsole.c | 0
.../{google => coreboot}/memconsole.h | 6 +-
drivers/firmware/{google => coreboot}/vpd.c | 0
.../{google => coreboot}/vpd_decode.c | 0
.../{google => coreboot}/vpd_decode.h | 0
drivers/gpu/drm/sysfb/Kconfig | 2 +-
19 files changed, 72 insertions(+), 34 deletions(-)
rename drivers/firmware/{google => coreboot}/Kconfig (64%)
rename drivers/firmware/{google => coreboot}/Makefile (51%)
rename drivers/firmware/{google => coreboot}/cbmem.c (100%)
rename drivers/firmware/{google => coreboot}/coreboot_table.c (100%)
rename drivers/firmware/{google => coreboot}/coreboot_table.h (100%)
rename drivers/firmware/{google => coreboot}/framebuffer-coreboot.c (100%)
rename drivers/firmware/{google => coreboot}/gsmi.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole-coreboot.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole-x86-legacy.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole.c (100%)
rename drivers/firmware/{google => coreboot}/memconsole.h (82%)
rename drivers/firmware/{google => coreboot}/vpd.c (100%)
rename drivers/firmware/{google => coreboot}/vpd_decode.c (100%)
rename drivers/firmware/{google => coreboot}/vpd_decode.h (100%)MAINTAINERS +2 -2
@@ -11069,14 +11069,14 @@ S: Maintained F: Documentation/networking/device_drivers/ethernet/google/gve.rst F: drivers/net/ethernet/google -GOOGLE FIRMWARE DRIVERS +COREBOOT FIRMWARE DRIVERS M: Tzung-Bi Shih <[email protected]> R: Brian Norris <[email protected]> R: Julius Werner <[email protected]> L: [email protected] S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/chrome-platform/linux.git -F: drivers/firmware/google/ +F: drivers/firmware/coreboot/ F: include/linux/coreboot.h GOOGLE TENSOR SoC SUPPORT
arch/arm64/configs/defconfig +3 -3
@@ -267,9 +267,9 @@ CONFIG_RASPBERRYPI_FIRMWARE=y CONFIG_INTEL_STRATIX10_SERVICE=y CONFIG_INTEL_STRATIX10_RSU=m CONFIG_MTK_ADSP_IPC=m -CONFIG_GOOGLE_FIRMWARE=y -CONFIG_GOOGLE_CBMEM=m -CONFIG_GOOGLE_COREBOOT_TABLE=m +CONFIG_COREBOOT_FIRMWARE=y +CONFIG_COREBOOT_CBMEM=m +CONFIG_COREBOOT_TABLE=m CONFIG_EFI_CAPSULE_LOADER=y CONFIG_IMX_SCU=y CONFIG_QCOM_TZMEM_MODE_SHMBRIDGE=y
drivers/firmware/Kconfig +1 -1
@@ -293,7 +293,7 @@ endif # TURRIS_MOX_RWTM source "drivers/firmware/arm_ffa/Kconfig" source "drivers/firmware/broadcom/Kconfig" source "drivers/firmware/cirrus/Kconfig" -source "drivers/firmware/google/Kconfig" +source "drivers/firmware/coreboot/Kconfig" source "drivers/firmware/efi/Kconfig" source "drivers/firmware/imx/Kconfig" source "drivers/firmware/meson/Kconfig"
drivers/firmware/Makefile +1 -1
@@ -30,7 +30,7 @@ obj-y += broadcom/ obj-y += cirrus/ obj-y += meson/ obj-y += microchip/ -obj-$(CONFIG_GOOGLE_FIRMWARE) += google/ +obj-$(CONFIG_COREBOOT_FIRMWARE) += coreboot/ obj-y += efi/ obj-y += imx/ obj-y += psci/
drivers/firmware/coreboot/Kconfig renamed from drivers/firmware/google/Kconfig +56 -18
129 lines not on this page · raw message
drivers/firmware/coreboot/Makefile renamed from drivers/firmware/google/Makefile +5 -5
@@ -1,14 +1,14 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_GOOGLE_SMI) += gsmi.o -obj-$(CONFIG_GOOGLE_COREBOOT_TABLE) += coreboot_table.o -obj-$(CONFIG_GOOGLE_FRAMEBUFFER_COREBOOT) += framebuffer-coreboot.o -obj-$(CONFIG_GOOGLE_MEMCONSOLE) += memconsole.o -obj-$(CONFIG_GOOGLE_MEMCONSOLE_COREBOOT) += memconsole-coreboot.o +obj-$(CONFIG_COREBOOT_TABLE) += coreboot_table.o +obj-$(CONFIG_COREBOOT_FRAMEBUFFER) += framebuffer-coreboot.o +obj-$(CONFIG_COREBOOT_MEMCONSOLE_COMMON) += memconsole.o +obj-$(CONFIG_COREBOOT_MEMCONSOLE) += memconsole-coreboot.o obj-$(CONFIG_GOOGLE_MEMCONSOLE_X86_LEGACY) += memconsole-x86-legacy.o # Must come after coreboot_table.o, as this driver depends on that bus type. -obj-$(CONFIG_GOOGLE_CBMEM) += cbmem.o +obj-$(CONFIG_COREBOOT_CBMEM) += cbmem.o vpd-sysfs-y := vpd.o vpd_decode.o obj-$(CONFIG_GOOGLE_VPD) += vpd-sysfs.o
drivers/firmware/coreboot/cbmem.c renamed from drivers/firmware/google/cbmem.c +0 -0
drivers/firmware/coreboot/coreboot_table.c renamed from drivers/firmware/google/coreboot_table.c +0 -0
drivers/firmware/coreboot/coreboot_table.h renamed from drivers/firmware/google/coreboot_table.h +0 -0
drivers/firmware/coreboot/framebuffer-coreboot.c renamed from drivers/firmware/google/framebuffer-coreboot.c +0 -0
drivers/firmware/coreboot/gsmi.c renamed from drivers/firmware/google/gsmi.c +0 -0
drivers/firmware/coreboot/memconsole-coreboot.c renamed from drivers/firmware/google/memconsole-coreboot.c +0 -0
drivers/firmware/coreboot/memconsole-x86-legacy.c renamed from drivers/firmware/google/memconsole-x86-legacy.c +0 -0
drivers/firmware/coreboot/memconsole.c renamed from drivers/firmware/google/memconsole.c +0 -0
drivers/firmware/coreboot/memconsole.h renamed from drivers/firmware/google/memconsole.h +3 -3
@@ -7,8 +7,8 @@* Copyright 2017 Google Inc. */ -#ifndef __FIRMWARE_GOOGLE_MEMCONSOLE_H -#define __FIRMWARE_GOOGLE_MEMCONSOLE_H +#ifndef __FIRMWARE_COREBOOT_MEMCONSOLE_H +#define __FIRMWARE_COREBOOT_MEMCONSOLE_H#include <linux/types.h>
@@ -33,4 +33,4 @@ int memconsole_sysfs_init(void);*/ void memconsole_exit (void ); -#endif /* __FIRMWARE_GOOGLE_MEMCONSOLE_H */ +#endif /* __FIRMWARE_COREBOOT_MEMCONSOLE_H */
drivers/firmware/coreboot/vpd.c renamed from drivers/firmware/google/vpd.c +0 -0
drivers/firmware/coreboot/vpd_decode.c renamed from drivers/firmware/google/vpd_decode.c +0 -0
drivers/firmware/coreboot/vpd_decode.h renamed from drivers/firmware/google/vpd_decode.h +0 -0
drivers/gpu/drm/sysfb/Kconfig +1 -1
@@ -10,7 +10,7 @@ config DRM_SYSFB_HELPER config DRM_COREBOOTDRM tristate "Coreboot framebuffer driver" depends on DRM && MMU - depends on GOOGLE_FRAMEBUFFER_COREBOOT + depends on COREBOOT_FRAMEBUFFER select APERTURE_HELPERS select DRM_CLIENT_SELECTION select DRM_GEM_SHMEM_HELPER
Sean Rhodes
maintainerPATCH v10 4/4 firmware: coreboot: Add CFR firmware attributes driver
In reply to Sean Rhodescoreboot 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 on x86. If firmware reports a failure, restore the old EFI variable value. Settings without a runtime apply hook, or non-x86 builds, keep the EFI variable update and set pending_reboot.
Tested on a Star Labs Byte with firmware 26.07 and the driver built as a module against Linux 6.17: runtime APM_CNT apply was verified with power_led, and reboot-needed behavior was verified with debug_level.
--- MAINTAINERS | 6 + drivers/firmware/coreboot/Kconfig | 14 + drivers/firmware/coreboot/Makefile | 1 + drivers/firmware/coreboot/coreboot-cfr.c | 1193 ++++++++++++++++++++++ 4 files changed, 1214 insertions(+) create mode 100644 drivers/firmware/coreboot/coreboot-cfr.c
MAINTAINERS +6 -0
@@ -6666,6 +6666,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 <[email protected]> +L: [email protected] +S: Maintained +F: drivers/firmware/coreboot/coreboot-cfr.c + CORETEMP HARDWARE MONITORING DRIVER L: [email protected] S: Orphan
drivers/firmware/coreboot/Kconfig +14 -0
@@ -49,6 +49,20 @@ 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 + 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
drivers/firmware/coreboot/Makefile +1 -0
@@ -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
drivers/firmware/coreboot/coreboot-cfr.c new file +1193 -0
1,193 lines not on this page · raw message
[email protected]
AI reviewRe: [PATCH v10 4/4] firmware: coreboot: Add CFR firmware attributes driver
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Mixing goto-based error handling with scope-based cleanup helpers (`__free` and `guard`) in the…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Mixing goto-based error handling with scope-based cleanup helpers (__free and guard) in the same function. --
--- Patch [4]: [PATCH v10 4/4] firmware: coreboot: Add CFR firmware attributes driver --- commit f075e88024f4dbd198791a1dc20f657a026b2206
Author: Sean Rhodes <[email protected]>
firmware: coreboot: Add CFR firmware attributes driver
This commit adds a firmware-attributes driver for coreboot CFR settings. It exposes runtime EFI variable-backed configuration options to userspace via sysfs, allowing modification and handling of runtime-apply mechanisms.
Quoted 5 lines
drivers/firmware/coreboot/coreboot-cfr.c new file +0
-0
[ ... ]
Quoted 25 lines
drivers/firmware/coreboot/coreboot-cfr.c new file +25
-0+static int coreboot_cfr_write_value (struct coreboot_cfr_setting *setting, +u32 value) +{ + efi_char16_t *efi_name __free(kfree) = NULL; +u32 attrs; +u32 old; +int restore_ret; +int ret; + +if (setting->read_only) +return -EACCES ; + + efi_name =coreboot_cfr_efi_name (setting->name); +if (IS_ERR (efi_name)) +return PTR_ERR (no_free_ptr (efi_name)); + +guard (mutex)(&setting->drvdata->lock); + + ret =efivar_lock (); +if (ret) +return ret; + + ret =coreboot_cfr_read_efi_value (efi_name, &old, &attrs); +if (ret) + goto out_unlock_efi;
[ ... ]
drivers/firmware/coreboot/coreboot-cfr.c line 449
Quoted 5 lines
drivers/firmware/coreboot/coreboot-cfr.c new file +5
-0+ +out_unlock_efi: +efivar_unlock (); +return ret; +}
[Severity: Medium]
Does this mix goto-based error handling with scope-based cleanups in the same function?
According to include/linux/cleanup.h, the expectation is that usage of goto and cleanup helpers (like __free and guard) should never be mixed in the same routine. Mixing them creates confusing resource ownership semantics and increases the risk of future resource leaks.
Could this be unified to exclusively use either traditional goto labels or scope-based cleanups? For instance, efivar_lock() could potentially use a cleanup helper to avoid the goto out_unlock_efi labels entirely.
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4