Skip to content

Commit b91ea4f

Browse files
committed
Move security support from common to drivers
- No board change; continue selecting `SECURITY` config - Security state enum moved to driver header - Update related doc Signed-off-by: Tim Crawford <[email protected]>
1 parent 62fd5e7 commit b91ea4f

File tree

9 files changed

+56
-38
lines changed

9 files changed

+56
-38
lines changed

docs/security.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
# Firmware security
22

33
The firmware security feature can be configured by setting `CONFIG_SECURITY=1`
4-
in the `src/board/system76/[board]/board.mk` file. This feature prevents
4+
in the `src/board/system76/<board>/board.mk` file. This feature prevents
55
programming the EC firmware at runtime, unless the EC is unlocked with the
66
`system76-ectool security unlock` command. After this, on the next reboot, the
7-
EC will respond to the SPI and reset commands. On boards where the `ME_WE` GPIO
8-
exists, it will be set high when the EC security state is unlocked.
7+
EC will respond to the SPI and reset commands.
8+
9+
This feature will drive the `ME_WE` pin high when the state is unlocked. On
10+
Intel hosts, this pin is connected to `HDA_SDO` and will disable security
11+
policies set in the flash descriptor.
12+
13+
- `HDA_SDO`: Flash Descriptor Security Override
914

1015
Other firmware components can use this state to perform their own locking and
11-
unlocking primitives. For example, in `coreboot`, flash regions may be locked
12-
when the EC security state is locked. In `EDK2`, a physical presence dialog may
13-
be shown when the EC security state is unlocked.
16+
unlocking primitives. For example, in coreboot, flash regions may be locked
17+
when the EC security state is locked. In the UEFI payload, a physical presence
18+
dialog may be shown when the EC security state is unlocked.

src/board/system76/common/common.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ board-common-y += pnp.c
1818
board-common-y += ps2.c
1919
board-common-y += pwm.c
2020
board-common-y += scratch.c
21-
board-common-$(CONFIG_SECURITY) += security.c
2221
board-common-y += smbus.c
2322
board-common-y += smfi.c
2423
board-common-y += stdio.c
@@ -40,10 +39,6 @@ CFLAGS += -DI2C_SMBUS=$(CONFIG_I2C_SMBUS)
4039
# Uncomment to enable I2C debug on 0x76
4140
#CFLAGS+=-DI2C_DEBUGGER=0x76
4241

43-
ifeq ($(CONFIG_SECURITY),y)
44-
CFLAGS+=-DCONFIG_SECURITY=1
45-
endif
46-
4742
ifeq ($(CONFIG_PLATFORM_INTEL),y)
4843
board-common-y += peci.c
4944
board-common-y += power/intel.c

src/board/system76/common/include/board/security.h

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/board/system76/common/power/intel.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#endif
2727

2828
#if CONFIG_SECURITY
29-
#include <board/security.h>
29+
#include <drivers/security/security.h>
3030
#endif // CONFIG_SECURITY
3131

3232
#define GPIO_SET_DEBUG(G, V) \

src/board/system76/common/smfi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <board/scratch.h>
2323

2424
#if CONFIG_SECURITY
25-
#include <board/security.h>
25+
#include <drivers/security/security.h>
2626
#endif // CONFIG_SECURITY
2727
#endif // !defined(__SCRATCH__)
2828

src/common/include/common/command.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,4 @@ enum CommandSpiFlag {
7777

7878
#define CMD_LED_INDEX_ALL 0xFF
7979

80-
enum SecurityState {
81-
// Default value, flashing is prevented, cannot be set with CMD_SECURITY_SET
82-
SECURITY_STATE_LOCK = 0,
83-
// Flashing is allowed, cannot be set with CMD_SECURITY_SET
84-
SECURITY_STATE_UNLOCK = 1,
85-
// Flashing will be prevented on the next reboot
86-
SECURITY_STATE_PREPARE_LOCK = 2,
87-
// Flashing will be allowed on the next reboot
88-
SECURITY_STATE_PREPARE_UNLOCK = 3,
89-
};
90-
9180
#endif // _COMMON_COMMAND_H

src/drivers/security/Makefile.mk

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-License-Identifier: GPL-3.0-only
2+
# SPDX-FileCopyrightText: 2025 System76, Inc.
3+
4+
# Firmware security state feature.
5+
#
6+
# Requires:
7+
# - Board must declare the `ME_WE` pin.
8+
#
9+
# External integrations:
10+
# - system76/coreboot: `ec/system76/ec` config `EC_SYSTEM76_EC_LOCKDOWN`.
11+
# - system76/firmware-setup: UEFI protocol for physical presence prompt.
12+
13+
ifeq ($(CONFIG_SECURITY),y)
14+
15+
CFLAGS += -DCONFIG_SECURITY=1
16+
17+
drivers-y += security.c
18+
19+
endif
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-3.0-only
22

3+
#include "security.h"
34
#include <board/gpio.h>
4-
#include <board/security.h>
55

66
static enum SecurityState security_state = SECURITY_STATE_LOCK;
77

src/drivers/security/security.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
3+
#ifndef _DRIVERS_SECURITY_H
4+
#define _DRIVERS_SECURITY_H
5+
6+
#include <stdbool.h>
7+
8+
enum SecurityState {
9+
// Default value, flashing is prevented, cannot be set with CMD_SECURITY_SET
10+
SECURITY_STATE_LOCK = 0,
11+
// Flashing is allowed, cannot be set with CMD_SECURITY_SET
12+
SECURITY_STATE_UNLOCK = 1,
13+
// Flashing will be prevented on the next reboot
14+
SECURITY_STATE_PREPARE_LOCK = 2,
15+
// Flashing will be allowed on the next reboot
16+
SECURITY_STATE_PREPARE_UNLOCK = 3,
17+
};
18+
19+
enum SecurityState security_get(void);
20+
bool security_set(enum SecurityState state);
21+
bool security_power(void);
22+
23+
#endif // _DRIVERS_SECURITY_H

0 commit comments

Comments
 (0)