From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH 3/6] lib: smbios: add support for setting product UUID
Date: Thu, 15 Jan 2026 13:06:11 +0100 [thread overview]
Message-ID: <20260115120748.3433463-4-a.fatoum@barebox.org> (raw)
In-Reply-To: <20260115120748.3433463-1-a.fatoum@barebox.org>
SMBIOS describes how firmware can report a product UUID to the OS.
Currently, we derive one from the machine ID, which should ensure
uniqueness, but for easier identification, it would be good if board
code could explicitly set a UUID that's reported as-is to the OS.
Add global.product.uuid to allow for this.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
common/misc.c | 14 ++++++++++++++
include/barebox-info.h | 4 ++++
lib/smbios.c | 18 ++++++++++++------
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/common/misc.c b/common/misc.c
index 0af5a9cf30cd..b99a1b4ad8e7 100644
--- a/common/misc.c
+++ b/common/misc.c
@@ -142,6 +142,7 @@ BAREBOX_MAGICVAR(global.model, "Product name of this hardware");
static char *hostname;
static char *serial_number;
+static uuid_t product_uuid;
/* Note that HOST_NAME_MAX is 64 on Linux */
#define BAREBOX_HOST_NAME_MAX 64
@@ -252,6 +253,19 @@ const char *barebox_get_serial_number(void)
BAREBOX_MAGICVAR(global.serial_number, "Board serial number");
+void barebox_set_product_uuid(const uuid_t *__product_uuid)
+{
+ globalvar_add_simple_uuid("product.uuid", &product_uuid);
+ product_uuid = *__product_uuid;
+}
+
+const uuid_t *barebox_get_product_uuid(void)
+{
+ return &product_uuid;
+}
+
+BAREBOX_MAGICVAR(global.product.uuid, "SMBIOS-reported product UUID");
+
#ifdef CONFIG_OFTREE
static char *of_machine_compatible;
diff --git a/include/barebox-info.h b/include/barebox-info.h
index bcceb7b0e021..70a940862ce2 100644
--- a/include/barebox-info.h
+++ b/include/barebox-info.h
@@ -4,6 +4,7 @@
#define __BAREBOX_INFO_H__
#include <linux/types.h>
+#include <linux/uuid.h>
extern const char version_string[];
extern const char release_string[];
@@ -25,6 +26,9 @@ bool barebox_hostname_is_valid(const char *s);
const char *barebox_get_serial_number(void);
void barebox_set_serial_number(const char *);
+void barebox_set_product_uuid(const uuid_t *uuid);
+const uuid_t *barebox_get_product_uuid(void);
+
#ifdef CONFIG_OFTREE
void barebox_set_of_machine_compatible(const char *);
const char *barebox_get_of_machine_compatible(void);
diff --git a/lib/smbios.c b/lib/smbios.c
index c50fc907b255..d5aae1651f86 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -221,6 +221,8 @@ static int smbios_write_type1(void **current, int handle,
{
struct smbios_type1 *t;
int len = sizeof(*t);
+ const uuid_t *product_uuid = NULL;
+ uuid_t product_uuid_buf;
char *vendor;
t = map_sysmem(*current, len);
@@ -236,16 +238,20 @@ static int smbios_write_type1(void **current, int handle,
t->version = smbios_add_string(ctx, NULL);
t->serial_number = smbios_add_string(ctx, barebox_get_serial_number());
- if (IS_ENABLED(CONFIG_MACHINE_ID_SPECIFIC)) {
- uuid_t id;
- int ret;
+ product_uuid = barebox_get_product_uuid();
+ if (!product_uuid && IS_ENABLED(CONFIG_MACHINE_ID_SPECIFIC)) {
+ int err;
- ret = machine_id_get_app_specific(&id, ARRAY_AND_SIZE("barebox-smbios"),
+ err = machine_id_get_app_specific(&product_uuid_buf,
+ ARRAY_AND_SIZE("barebox-smbios"),
NULL);
- if (!ret)
- export_uuid(t->uuid, &id);
+ if (!err)
+ product_uuid = &product_uuid_buf;
}
+ if (product_uuid)
+ export_uuid(t->uuid, product_uuid);
+
if (reset_source_get() == RESET_WKE)
t->wakeup_type = SMBIOS_WAKEUP_TYPE_OTHER;
else
--
2.47.3
next prev parent reply other threads:[~2026-01-15 12:08 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-15 12:06 [PATCH 0/6] firmware: qemu_fw_cfg: improve support Ahmad Fatoum
2026-01-15 12:06 ` [PATCH 1/6] firmware: qemu_fw_cfg: use wider PIO reads if applicable Ahmad Fatoum
2026-01-15 12:06 ` [PATCH 2/6] param: support uuid/guid parameter type Ahmad Fatoum
2026-01-15 12:06 ` Ahmad Fatoum [this message]
2026-01-15 12:06 ` [PATCH 4/6] common: boards: qemu: process some standard fw_cfg keys Ahmad Fatoum
2026-01-19 11:13 ` Sascha Hauer
2026-01-19 11:33 ` Ahmad Fatoum
2026-01-15 12:06 ` [PATCH 5/6] firmware: qemu_fw_cfg: add proper DMA and PIO bidirectional operating modes Ahmad Fatoum
2026-01-15 12:06 ` [PATCH 6/6] ARM: configs: multi: enable QEMU FW_CFG Ahmad Fatoum
2026-01-19 12:11 ` [PATCH 0/6] firmware: qemu_fw_cfg: improve support Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260115120748.3433463-4-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox