What changed, and why it matters
This commit is a pure code reorganization: it moves the CPU-ID reading module from a 'util' directory to a 'sys' directory, updating include paths and build lists accordingly. The actual logic for reading the chip's unique identifier is unchanged, and there is no visible security fix or behavior change.
No security action needed; treat as routine refactoring. Standard review/merge process is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change relocates the cpuid module from core/embed/util/cpuid to core/embed/sys/cpuid. Header include paths are updated from
Changed components
core/embed/sys/cpuidcore/embed/projects/prodtest/cmd/prodtest_get_cpuid.ccore/site_scons/models/stm32f4_common.pycore/site_scons/models/stm32u5_common.pycore/site_scons/models/unix_common.pyInspect captured patch +106 / −106
diff --git a/core/embed/projects/prodtest/cmd/prodtest_get_cpuid.c b/core/embed/projects/prodtest/cmd/prodtest_get_cpuid.c
index 2ae0bd715..aa61e8ad7 100644
--- a/core/embed/projects/prodtest/cmd/prodtest_get_cpuid.c
+++ b/core/embed/projects/prodtest/cmd/prodtest_get_cpuid.c
@@ -21,7 +21,7 @@
#include <trezor_rtl.h>
#include <rtl/cli.h>
-#include <util/cpuid.h>
+#include <sys/cpuid.h>
static void prodtest_get_cpuid(cli_t* cli) {
if (cli_arg_count(cli) > 0) {
diff --git a/core/embed/sys/cpuid/inc/sys/cpuid.h b/core/embed/sys/cpuid/inc/sys/cpuid.h
new file mode 100644
index 000000000..c630c53c9
--- /dev/null
+++ b/core/embed/sys/cpuid/inc/sys/cpuid.h
@@ -0,0 +1,28 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <trezor_types.h>
+
+typedef struct {
+ uint32_t id[3];
+} cpuid_t;
+
+void cpuid_get(cpuid_t* cpuid);
diff --git a/core/embed/sys/cpuid/stm32/cpuid.c b/core/embed/sys/cpuid/stm32/cpuid.c
new file mode 100644
index 000000000..c4e1d89cc
--- /dev/null
+++ b/core/embed/sys/cpuid/stm32/cpuid.c
@@ -0,0 +1,42 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef KERNEL_MODE
+
+#include <trezor_bsp.h>
+#include <trezor_rtl.h>
+
+#include <sys/cpuid.h>
+#include <sys/mpu.h>
+
+#ifdef STM32U5
+#include "stm32u5xx_ll_utils.h"
+#else
+#include "stm32f4xx_ll_utils.h"
+#endif
+
+void cpuid_get(cpuid_t* cpuid) {
+ mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
+ cpuid->id[0] = LL_GetUID_Word0();
+ cpuid->id[1] = LL_GetUID_Word1();
+ cpuid->id[2] = LL_GetUID_Word2();
+ mpu_restore(mpu_mode);
+}
+
+#endif
diff --git a/core/embed/sys/cpuid/unix/cpuid.c b/core/embed/sys/cpuid/unix/cpuid.c
new file mode 100644
index 000000000..4a452719d
--- /dev/null
+++ b/core/embed/sys/cpuid/unix/cpuid.c
@@ -0,0 +1,29 @@
+/*
+ * This file is part of the Trezor project, https://trezor.io/
+ *
+ * Copyright (c) SatoshiLabs
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <trezor_bsp.h>
+#include <trezor_rtl.h>
+
+#include <sys/cpuid.h>
+
+void cpuid_get(cpuid_t* cpuid) {
+ cpuid->id[0] = 0;
+ cpuid->id[1] = 0;
+ cpuid->id[2] = 0;
+}
diff --git a/core/embed/util/cpuid/inc/util/cpuid.h b/core/embed/util/cpuid/inc/util/cpuid.h
deleted file mode 100644
index c630c53c9..000000000
--- a/core/embed/util/cpuid/inc/util/cpuid.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#pragma once
-
-#include <trezor_types.h>
-
-typedef struct {
- uint32_t id[3];
-} cpuid_t;
-
-void cpuid_get(cpuid_t* cpuid);
diff --git a/core/embed/util/cpuid/stm32/cpuid.c b/core/embed/util/cpuid/stm32/cpuid.c
deleted file mode 100644
index 78ea09aca..000000000
--- a/core/embed/util/cpuid/stm32/cpuid.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifdef KERNEL_MODE
-
-#include <trezor_bsp.h>
-#include <trezor_rtl.h>
-
-#include <sys/mpu.h>
-#include <util/cpuid.h>
-
-#ifdef STM32U5
-#include "stm32u5xx_ll_utils.h"
-#else
-#include "stm32f4xx_ll_utils.h"
-#endif
-
-void cpuid_get(cpuid_t* cpuid) {
- mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_OTP);
- cpuid->id[0] = LL_GetUID_Word0();
- cpuid->id[1] = LL_GetUID_Word1();
- cpuid->id[2] = LL_GetUID_Word2();
- mpu_restore(mpu_mode);
-}
-
-#endif
diff --git a/core/embed/util/cpuid/unix/cpuid.c b/core/embed/util/cpuid/unix/cpuid.c
deleted file mode 100644
index 94496c561..000000000
--- a/core/embed/util/cpuid/unix/cpuid.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of the Trezor project, https://trezor.io/
- *
- * Copyright (c) SatoshiLabs
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <trezor_bsp.h>
-#include <trezor_rtl.h>
-
-#include <util/cpuid.h>
-
-void cpuid_get(cpuid_t* cpuid) {
- cpuid->id[0] = 0;
- cpuid->id[1] = 0;
- cpuid->id[2] = 0;
-}
diff --git a/core/site_scons/models/stm32f4_common.py b/core/site_scons/models/stm32f4_common.py
index 7fa7226dc..acccc6b93 100644
--- a/core/site_scons/models/stm32f4_common.py
+++ b/core/site_scons/models/stm32f4_common.py
@@ -20,6 +20,7 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/secure_aes/inc",
"embed/sec/time_estimate/inc",
"embed/sys/bsp/stm32f4",
+ "embed/sys/cpuid/inc",
"embed/sys/inc",
"embed/sys/irq/inc",
"embed/sys/linker/inc",
@@ -34,7 +35,6 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/syscall/inc",
"embed/sys/task/inc",
"embed/sys/time/inc",
- "embed/util/cpuid/inc",
"embed/util/flash/inc",
"embed/util/fwutils/inc",
"vendor/micropython/lib/cmsis/inc",
@@ -79,6 +79,7 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/storage/stm32f4/storage_salt.c",
"embed/sec/time_estimate/stm32/time_estimate.c",
"embed/sec/unit_properties/stm32/unit_properties.c",
+ "embed/sys/cpuid/stm32/cpuid.c",
"embed/sys/irq/stm32/irq.c",
"embed/sys/linker/linker_utils.c",
"embed/sys/mpu/stm32f4/mpu.c",
@@ -103,7 +104,6 @@ def stm32f4_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/time/stm32/systick.c",
"embed/sys/time/stm32/systimer.c",
"embed/sys/task/sysevent.c",
- "embed/util/cpuid/stm32/cpuid.c",
"embed/util/flash/stm32f4/flash.c",
"embed/util/flash/stm32f4/flash_layout.c",
"embed/util/flash/stm32f4/flash_otp.c",
diff --git a/core/site_scons/models/stm32u5_common.py b/core/site_scons/models/stm32u5_common.py
index c28aee362..04f83de63 100644
--- a/core/site_scons/models/stm32u5_common.py
+++ b/core/site_scons/models/stm32u5_common.py
@@ -25,6 +25,7 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/time_estimate/inc",
"embed/sec/unit_properties/inc",
"embed/sys/bsp/stm32u5",
+ "embed/sys/cpuid/inc",
"embed/sys/inc",
"embed/sys/irq/inc",
"embed/sys/linker/inc",
@@ -37,7 +38,6 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/task/inc",
"embed/sys/time/inc",
"embed/sys/trustzone/inc",
- "embed/util/cpuid/inc",
"embed/util/flash/inc",
"embed/util/fwutils/inc",
"vendor/stm32u5xx_hal_driver/Inc",
@@ -105,6 +105,7 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/tamper/stm32u5/tamper.c",
"embed/sec/time_estimate/stm32/time_estimate.c",
"embed/sec/unit_properties/stm32/unit_properties.c",
+ "embed/sys/cpuid/stm32/cpuid.c",
"embed/sys/irq/stm32/irq.c",
"embed/sys/linker/linker_utils.c",
"embed/sys/mpu/stm32u5/mpu.c",
@@ -132,7 +133,6 @@ def stm32u5_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/time/stm32/systimer.c",
"embed/sys/task/sysevent.c",
"embed/sys/trustzone/stm32u5/trustzone.c",
- "embed/util/cpuid/stm32/cpuid.c",
"embed/util/flash/stm32u5/flash.c",
"embed/util/flash/stm32u5/flash_layout.c",
"embed/util/flash/stm32u5/flash_otp.c",
diff --git a/core/site_scons/models/unix_common.py b/core/site_scons/models/unix_common.py
index 4d10714b3..5cfcff30a 100644
--- a/core/site_scons/models/unix_common.py
+++ b/core/site_scons/models/unix_common.py
@@ -21,13 +21,13 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/monoctr/inc",
"embed/sec/secret/inc",
"embed/sec/unit_properties/inc",
+ "embed/sys/cpuid/inc",
"embed/sys/irq/inc",
"embed/sys/mpu/inc",
"embed/sys/rng/inc",
"embed/sys/startup/inc",
"embed/sys/task/inc",
"embed/sys/time/inc",
- "embed/util/cpuid/inc",
"embed/util/flash/inc",
"embed/util/fwutils/inc",
]
@@ -46,6 +46,7 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
"embed/sec/rng/rng_strong.c",
"embed/sec/time_estimate/unix/time_estimate.c",
"embed/sec/unit_properties/unix/unit_properties.c",
+ "embed/sys/cpuid/unix/cpuid.c",
"embed/sys/mpu/unix/mpu.c",
"embed/sys/rng/unix/rng.c",
"embed/sys/startup/unix/bootutils.c",
@@ -55,7 +56,6 @@ def unix_common_files(env, features_wanted, defines, sources, paths):
"embed/sys/task/unix/systask.c",
"embed/sys/time/unix/systick.c",
"embed/sys/time/unix/systimer.c",
- "embed/util/cpuid/unix/cpuid.c",
"embed/util/flash/unix/flash.c",
"embed/util/flash/unix/flash_otp.c",
"embed/util/fwutils/fwutils.c",
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.