Skip to content

Commit d4eef75

Browse files
dthompsoij-intel
authored andcommitted
mlxbf-bootctl: correctly identify secure boot with development keys
The secure boot state of the BlueField SoC is represented by two bits: 0 = production state 1 = secure boot enabled 2 = non-secure (secure boot disabled) 3 = RMA state There is also a single bit to indicate whether production keys or development keys are being used when secure boot is enabled. This single bit (specified by MLXBF_BOOTCTL_SB_DEV_MASK) only has meaning if secure boot state equals 1 (secure boot enabled). The secure boot states are as follows: - “GA secured” is when secure boot is enabled with official production keys. - “Secured (development)” is when secure boot is enabled with development keys. Without this fix “GA Secured” is displayed on development cards which is misleading. This patch updates the logic in "lifecycle_state_show()" to handle the case where the SoC is configured for secure boot and is using development keys. Fixes: 79e29cb ("platform/mellanox: Add bootctl driver for Mellanox BlueField Soc") Reviewed-by: Khalil Blaiech <[email protected]> Signed-off-by: David Thompson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent cbf54f3 commit d4eef75

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

drivers/platform/mellanox/mlxbf-bootctl.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#define MLXBF_BOOTCTL_SB_SECURE_MASK 0x03
2222
#define MLXBF_BOOTCTL_SB_TEST_MASK 0x0c
23+
#define MLXBF_BOOTCTL_SB_DEV_MASK BIT(4)
2324

2425
#define MLXBF_SB_KEY_NUM 4
2526

@@ -40,11 +41,18 @@ static struct mlxbf_bootctl_name boot_names[] = {
4041
{ MLXBF_BOOTCTL_NONE, "none" },
4142
};
4243

44+
enum {
45+
MLXBF_BOOTCTL_SB_LIFECYCLE_PRODUCTION = 0,
46+
MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE = 1,
47+
MLXBF_BOOTCTL_SB_LIFECYCLE_GA_NON_SECURE = 2,
48+
MLXBF_BOOTCTL_SB_LIFECYCLE_RMA = 3
49+
};
50+
4351
static const char * const mlxbf_bootctl_lifecycle_states[] = {
44-
[0] = "Production",
45-
[1] = "GA Secured",
46-
[2] = "GA Non-Secured",
47-
[3] = "RMA",
52+
[MLXBF_BOOTCTL_SB_LIFECYCLE_PRODUCTION] = "Production",
53+
[MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE] = "GA Secured",
54+
[MLXBF_BOOTCTL_SB_LIFECYCLE_GA_NON_SECURE] = "GA Non-Secured",
55+
[MLXBF_BOOTCTL_SB_LIFECYCLE_RMA] = "RMA",
4856
};
4957

5058
/* Log header format. */
@@ -247,25 +255,30 @@ static ssize_t second_reset_action_store(struct device *dev,
247255
static ssize_t lifecycle_state_show(struct device *dev,
248256
struct device_attribute *attr, char *buf)
249257
{
258+
int status_bits;
259+
int use_dev_key;
260+
int test_state;
250261
int lc_state;
251262

252-
lc_state = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS,
253-
MLXBF_BOOTCTL_FUSE_STATUS_LIFECYCLE);
254-
if (lc_state < 0)
255-
return lc_state;
263+
status_bits = mlxbf_bootctl_smc(MLXBF_BOOTCTL_GET_TBB_FUSE_STATUS,
264+
MLXBF_BOOTCTL_FUSE_STATUS_LIFECYCLE);
265+
if (status_bits < 0)
266+
return status_bits;
256267

257-
lc_state &=
258-
MLXBF_BOOTCTL_SB_TEST_MASK | MLXBF_BOOTCTL_SB_SECURE_MASK;
268+
use_dev_key = status_bits & MLXBF_BOOTCTL_SB_DEV_MASK;
269+
test_state = status_bits & MLXBF_BOOTCTL_SB_TEST_MASK;
270+
lc_state = status_bits & MLXBF_BOOTCTL_SB_SECURE_MASK;
259271

260272
/*
261273
* If the test bits are set, we specify that the current state may be
262274
* due to using the test bits.
263275
*/
264-
if (lc_state & MLXBF_BOOTCTL_SB_TEST_MASK) {
265-
lc_state &= MLXBF_BOOTCTL_SB_SECURE_MASK;
266-
276+
if (test_state) {
267277
return sprintf(buf, "%s(test)\n",
268278
mlxbf_bootctl_lifecycle_states[lc_state]);
279+
} else if (use_dev_key &&
280+
(lc_state == MLXBF_BOOTCTL_SB_LIFECYCLE_GA_SECURE)) {
281+
return sprintf(buf, "Secured (development)\n");
269282
}
270283

271284
return sprintf(buf, "%s\n", mlxbf_bootctl_lifecycle_states[lc_state]);

0 commit comments

Comments
 (0)