linsysfs: expose SMBIOS DMI identification - #519
Conversation
Add /sys/class/dmi/id files backed by SMBIOS kernel environment values so Linux applications can use sysfs instead of falling back to /dev/mem. Add ATF coverage for file contents, permissions, and absent SMBIOS keys. AI-Assisted-by: Codex (GPT-5) Signed-off-by: Lucas Holt <luke@foolishgames.com>
Reviewer's GuideThe PR adds a Linux-compatible linsysfs DMI identification hierarchy backed by available SMBIOS kernel environment values, with dynamic read-only field files and ATF validation for contents, permissions, and missing-value behavior. Sequence diagram for reading a linsysfs DMI fieldsequenceDiagram
participant Tool as HardwareTool
participant Sysfs as linsysfs
participant Kenv as KernelEnvironment
Tool->>Sysfs: read /sys/class/dmi/id/sys_vendor
Sysfs->>Kenv: kern_getenv(smbios.system.maker)
Kenv-->>Sysfs: SMBIOS value
Sysfs-->>Tool: value plus newline
Flow diagram for optional DMI field creationflowchart TD
INIT[linsysfs_init] --> LIST[linsysfs_listdmi]
LIST --> CHECK[kern_getenv SMBIOS key]
CHECK -->|value exists| CREATE[Create read-only DMI file]
CHECK -->|value absent| OMIT[Omit DMI file]
CREATE --> READ[linsysfs_dmi_field]
READ --> OUTPUT[Return value plus newline]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Claude encountered an error after 2s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="sys/compat/linsysfs/linsysfs.c" line_range="65-73" />
<code_context>
+ const char *kenv;
+};
+
+static const struct linsysfs_dmi_field linsysfs_dmi_fields[] = {
+ { "sys_vendor", "smbios.system.maker" },
+ { "product_name", "smbios.system.product" },
+ { "board_vendor", "smbios.planar.maker" },
+ { "board_name", "smbios.planar.product" },
+ { "bios_vendor", "smbios.bios.vendor" },
+ { "bios_version", "smbios.bios.version" },
+ { "chassis_vendor", "smbios.chassis.maker" },
+};
+
+TAILQ_HEAD(scsi_host_list, scsi_host_queue) scsi_host_q;
</code_context>
<issue_to_address>
**issue (broader_impact):** The `/sys/class/dmi/id` interface exposes only seven DMI attributes and omits standard fields such as `product_uuid`, `product_serial`, `product_version`, `bios_date`, `board_version`, `board_serial`, `chassis_type`, and their related fields. Linux applications that probe any of those standard paths receive `ENOENT` and can still fall back to SMBIOS scanning through `/dev/mem`, so the new interface does not reliably prevent the fallback described in the PR.
**Triggers:** When a hardware-identification application requires a standard DMI attribute not included in this table.
**Suggested fix:** Add the supported non-sensitive standard DMI attributes to `linsysfs_dmi_fields`, or explicitly limit the interface and callers to the subset that is guaranteed to be available.
</issue_to_address>| static const struct linsysfs_dmi_field linsysfs_dmi_fields[] = { | ||
| { "sys_vendor", "smbios.system.maker" }, | ||
| { "product_name", "smbios.system.product" }, | ||
| { "board_vendor", "smbios.planar.maker" }, | ||
| { "board_name", "smbios.planar.product" }, | ||
| { "bios_vendor", "smbios.bios.vendor" }, | ||
| { "bios_version", "smbios.bios.version" }, | ||
| { "chassis_vendor", "smbios.chassis.maker" }, | ||
| }; |
There was a problem hiding this comment.
issue (broader_impact): The /sys/class/dmi/id interface exposes only seven DMI attributes and omits standard fields such as product_uuid, product_serial, product_version, bios_date, board_version, board_serial, chassis_type, and their related fields. Linux applications that probe any of those standard paths receive ENOENT and can still fall back to SMBIOS scanning through /dev/mem, so the new interface does not reliably prevent the fallback described in the PR.
Triggers: When a hardware-identification application requires a standard DMI attribute not included in this table.
Suggested fix: Add the supported non-sensitive standard DMI attributes to linsysfs_dmi_fields, or explicitly limit the interface and callers to the subset that is guaranteed to be available.
Summary
/sys/class/dmi/idfiles backed by MidnightBSD SMBIOS kernel environment valuesLinux applications such as Geekbench probe these sysfs files before falling back to SMBIOS scanning through
/dev/mem. Providing the normal Linux interface avoids the invalid fallback path reported in #518 without changing/dev/memmmap semantics.Fixes #518.
Validation
bmake -C sys/modules/linsysfsbmake -C tests/sys/fs/linsysfssh -n tests/sys/fs/linsysfs/dmi_id_test.shbmake buildkernel KERNCONF=GENERICincluding all modulesRuntime verification is pending on the Framework laptop that reproduces #518. After booting or loading the updated linsysfs module, confirm that
geekbench6 --sysinfosucceeds as root and no longer opens/dev/mem.AI contribution checklist
Summary by Sourcery
Expose SMBIOS-backed DMI identification through the linsysfs compatibility interface.
New Features:
/sys/class/dmi/idfor available system, board, BIOS, and chassis vendor information.Bug Fixes:
/dev/memSMBIOS scanning.Tests: