Skip to content

Commit b240ee7

Browse files
authored
Merge pull request #933 from dgarske/nai_68int6
Add wolfBoot target for the NAI 68INT6 (Intel Tiger Lake UP3) OpenVPX SBC
2 parents 8685a5a + 363483e commit b240ee7

44 files changed

Lines changed: 3584 additions & 163 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/test-build-kontron-vx3060-s2.yml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ jobs:
4646
export DEBIAN_FRONTEND=noninteractive
4747
sudo apt-get update -o Acquire::Retries=3
4848
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib
49-
- name: setup git
50-
run: |
51-
git config --global user.email "you@example.com"
52-
git config --global user.name "Your Name"
5349
- name: run test
5450
run: |
5551
cp config/examples/kontron_vx3060_s2.config .config

‎.github/workflows/test-x86-fsp-qemu.yml‎

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ jobs:
4646
export DEBIAN_FRONTEND=noninteractive
4747
sudo apt-get update -o Acquire::Retries=3
4848
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 swtpm uuid-dev
49-
- name: setup git
50-
run: |
51-
git config --global user.email "you@example.com"
52-
git config --global user.name "Your Name"
5349
- name: run test
5450
run: |
5551
./tools/scripts/x86_fsp/qemu/test_qemu.sh
@@ -70,10 +66,25 @@ jobs:
7066
export DEBIAN_FRONTEND=noninteractive
7167
sudo apt-get update -o Acquire::Retries=3
7268
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 uuid-dev dosfstools mtools e2fsprogs
73-
- name: setup git
74-
run: |
75-
git config --global user.email "you@example.com"
76-
git config --global user.name "Your Name"
7769
- name: run test
7870
run: |
7971
./tools/scripts/x86_fsp/qemu/test_qemu.sh -f
72+
73+
# TPM-NV anti-rollback: the floor anchors on a fresh swtpm, survives a TPM
74+
# restart, and a validly signed downgrade boots and is counted.
75+
fsp_qemu_antirollback_test:
76+
runs-on: ubuntu-latest
77+
timeout-minutes: 15
78+
79+
steps:
80+
- uses: actions/checkout@v4
81+
with:
82+
submodules: true
83+
- name: install req
84+
run: |
85+
export DEBIAN_FRONTEND=noninteractive
86+
sudo apt-get update -o Acquire::Retries=3
87+
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 swtpm uuid-dev
88+
- name: run test
89+
run: |
90+
./tools/scripts/x86_fsp/qemu/test_qemu.sh -r

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ tools/unit-tests/unit-update-flash-db
182182
tools/unit-tests/unit-update-flash-enc-full
183183
tools/unit-tests/unit-update-flash-enc-intswap
184184
tools/unit-tests/unit-update-ram
185+
tools/unit-tests/unit-boot-state
186+
tools/unit-tests/unit-boot-state-halt
185187
tools/unit-tests/unit-boot-x86-fsp
186188
tools/unit-tests/unit-image-rsa
187189
tools/unit-tests/unit-multiboot

‎arch.mk‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,13 +2310,13 @@ ifeq ($(USE_GCC),1)
23102310
endif
23112311
OUTPUT_FLAG?=-o
23122312

2313-
ifeq ($(filter $(TARGET),x86_fsp_qemu kontron_vx3060_s2),$(TARGET))
2313+
ifeq ($(filter $(TARGET),x86_fsp_qemu kontron_vx3060_s2 nai_68int6),$(TARGET))
23142314
FSP=1
23152315
CFLAGS+=-ffunction-sections -fdata-sections -ffreestanding -nostdlib -static
23162316
# some std libc have headers that bring in extra symbols used in
23172317
# FORTIFY_SOURCE realated checks. Use -U_FORTIFY_SOURCE to avoid that.
23182318
CFLAGS+=-U_FORTIFY_SOURCE
2319-
ifeq ($(TARGET), kontron_vx3060_s2)
2319+
ifeq ($(filter $(TARGET),kontron_vx3060_s2 nai_68int6),$(TARGET))
23202320
FSP_TGL=1
23212321
CFLAGS+=-DWOLFBOOT_TGL=1
23222322
endif
@@ -2366,23 +2366,20 @@ ifeq ("${FSP}", "1")
23662366
OBJS += src/image.o
23672367
OBJS += src/keystore.o
23682368
OBJS += src/sig_wolfboot_raw.o
2369-
ifeq ($(TARGET), kontron_vx3060_s2)
2370-
OBJS += hal/kontron_vx3060_s2_loader.o
2371-
endif
23722369
OBJS += $(WOLFCRYPT_OBJS)
23732370
CFLAGS+=-DSTAGE1_AUTH
23742371
endif
23752372

2373+
# Generic stage1 loader HAL (stubs); shared by all x86 FSP targets.
2374+
OBJS += hal/stub_loader.o
2375+
23762376
CFLAGS += -fno-stack-protector -m32 -fno-PIC -fno-pie -mno-mmx -mno-sse -DDEBUG_UART
23772377
CFLAGS += -DFSP_M_BASE=$(FSP_M_BASE)
23782378
ifeq ($(FSP_TGL), 1)
23792379
OBJS+=src/x86/tgl_fsp.o
23802380
OBJS+=src/ucode0.o
23812381
CFLAGS += -DUCODE0_ADDRESS=$(UCODE0_BASE)
23822382
endif
2383-
ifeq ($(TARGET),x86_fsp_qemu)
2384-
OBJS += hal/x86_fsp_qemu_loader.o
2385-
endif
23862383
else
23872384
# building wolfBoot
23882385
ifeq ($(FSP_TGL), 1)
@@ -2405,13 +2402,20 @@ ifeq ("${FSP}", "1")
24052402
OBJS += src/gpt.o
24062403
OBJS += src/disk.o
24072404
OBJS += src/x86/mptable.o
2405+
ifeq ($(ACPI),1)
2406+
OBJS += src/x86/acpi.o
2407+
endif
24082408
OBJS += src/stage2_params.o
24092409
OBJS += src/x86/exceptions.o
24102410
OBJS += src/x86/gdt.o
24112411
OBJS += src/x86/fsp.o
24122412
OBJS += src/x86/fsp_s.o
24132413
UPDATE_OBJS := src/update_disk.o
24142414
CFLAGS+=-DWOLFBOOT_UPDATE_DISK
2415+
ifeq ($(ANTI_ROLLBACK),1)
2416+
OBJS += src/boot_state.o
2417+
OBJS += src/boot_state_tpm.o
2418+
endif
24152419
ifeq ($(64BIT),1)
24162420
LDFLAGS += -m elf_x86_64 --oformat elf64-x86-64
24172421
CFLAGS += -m64

‎config/examples/nai_68int6.config‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# NAI 68INT6 3U OpenVPX SBC (Tiger Lake UP3); needs the board's own FSP
2+
# (nai_extract_fsp.sh). See the NAI 68INT6 section of docs/Targets.md.
3+
4+
ARCH=x86_64
5+
TARGET=nai_68int6
6+
WOLFBOOT_SMALL_STACK=0
7+
8+
# ECC P-384 signature, SHA-384 digest (measured boot uses SHA-256 on an
9+
# SLB9670). See the integrity-algorithm table in docs/Targets.md.
10+
SIGN=ECC384
11+
HASH=SHA384
12+
13+
DEBUG=1
14+
# FSP-M UPD dump on the console before FspMemInit (bring-up aid).
15+
DUMP_FSP_UPD=0
16+
SPMATH=1
17+
ENCRYPTION=0
18+
WOLFBOOT_NO_PARTITIONS=1
19+
# Disk boot: signed kernels in GPT partitions 3/4, Ubuntu root in partition 2.
20+
# The A/B boot-partition indices are set per target in src/update_disk.c.
21+
WOLFBOOT_BOOT_DISK=0
22+
FORCE_32BIT=1
23+
24+
########## Flash layout (measured from the factory descriptor, 32 MB) ##########
25+
WOLFBOOT_PARTITION_BOOT_ADDRESS=0xff400000
26+
WOLFBOOT_PARTITION_SWAP_ADDRESS=0x0
27+
WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x0
28+
WOLFBOOT_LOAD_BASE=0x58000200
29+
WOLFBOOT_SECTOR_SIZE?=0x1000
30+
WOLFBOOT_DATA_ADDRESS=0x1000000
31+
32+
FSP_CONFIG_BASE=0xffe9f800
33+
FSP_T_BASE=0xfff59000
34+
FSP_M_BASE=0xfff60000
35+
36+
WOLFBOOT_ORIGIN=0xfff00000
37+
BOOTLOADER_PARTITION_SIZE=0x600000
38+
# Inert (the flash descriptor is used); kept for config parity.
39+
BIOS_REGION_SIZE=0xc00000
40+
41+
UCODE0_BASE=0xffd90000
42+
UCODE0_BIN=src/x86/ucode0.bin
43+
44+
FSP_T_BIN=./src/x86/fsp_t.bin
45+
FSP_M_BIN=./src/x86/fsp_m.bin
46+
FSP_S_BIN=./src/x86/fsp_s.bin
47+
FSP_S_UPD_DATA_BIN=./src/x86/fsp_s_upd_data.bin
48+
# Boot Guard is left to the board owner: supply an ACM and key here to build a
49+
# Boot-Guard image. Unset, wolfBoot builds and boots without it.
50+
ACM_BIN=
51+
FSP_S_LOAD_BASE=0x0FED5F00
52+
53+
POLICY_BASE=0xffaa4000
54+
KEYSTORE_OFFSET=0x3FE00
55+
KEYSTORE_STAGE1_OFFSET=0x400
56+
57+
########## Console: LPSS UART2 (PCI 00:19.2), verified on hardware ##########
58+
X86_UART_NUMBER=2
59+
X86_UART_BASE=0xFE032000
60+
X86_UART_REG_WIDTH=4
61+
X86_UART_MMIO=1
62+
63+
########## PCH / PCI ##########
64+
PCH_PCR_BASE=0xFD000000
65+
PCI_ECAM_BASE=0xC0000000
66+
PCI_USE_ECAM=1
67+
PCH_HAS_PCR=1
68+
# Generate ACPI tables so Linux gets the interrupt model and PCI routing.
69+
ACPI=1
70+
71+
########## Payload: signed 64-bit Linux bzImage ##########
72+
64BIT=1
73+
ELF=1
74+
DEBUG_ELF=0
75+
MULTIBOOT2=1
76+
LINUX_PAYLOAD=1
77+
78+
########## Security ##########
79+
STAGE1_AUTH=1
80+
WOLFTPM=1
81+
MEASURED_BOOT=1
82+
MEASURED_PCR_A=0
83+
# Measure the verified OS image into PCR4, alongside the firmware in PCR0.
84+
MEASURED_PCR_OS=4
85+
WOLFBOOT_UNIVERSAL_KEYSTORE=1
86+
WOLFBOOT_SKIP_AUTH_CHECK=0
87+
ENABLE_DEBUG_CONSENT=0
88+
89+
# Deferred: TPM sealing and ATA disk lock/erase.
90+
WOLFBOOT_TPM_SEAL=0
91+
DISK_LOCK=0
92+
DISK_ERASE=0
93+
94+
# Anti-rollback: persistent version floor + audit counters in TPM NV
95+
# (trust-on-first-use; provision before first boot where that matters).
96+
ANTI_ROLLBACK=1
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
ARCH=x86_64
2+
TARGET=x86_fsp_qemu
3+
WOLFBOOT_SMALL_STACK=1
4+
SIGN=ECC256
5+
HASH=SHA256
6+
DEBUG=1
7+
SPMATH=1
8+
FORCE_32BIT=1
9+
ENCRYPTION=0
10+
WOLFBOOT_NO_PARTITIONS=1
11+
12+
# TPM Keystore options
13+
#WOLFBOOT_TPM_KEYSTORE?=1
14+
#WOLFBOOT_TPM_KEYSTORE_NV_BASE?=0x01800200
15+
#WOLFBOOT_TPM_POLICY_NV_INDEX?=0x01800201
16+
17+
# 4gb - 8mb
18+
WOLFBOOT_LOAD_BASE=0x2000000
19+
WOLFBOOT_LOAD_ADDRESS=0x1000000
20+
21+
# required for keytools
22+
WOLFBOOT_SECTOR_SIZE?=0x1000
23+
WOLFBOOT_DATA_ADDRESS=0x1000000
24+
25+
FSP_M_BASE=0xffe30000
26+
FSP_S_BASE=0xffed6000
27+
FSP_T_BASE=0xfffe0000
28+
FSP_S_LOAD_BASE=0x0FED5F00
29+
WOLFBOOT_ORIGIN=0xfff80000
30+
31+
BOOTLOADER_PARTITION_SIZE=0xe0000
32+
BIOS_REGION_SIZE=0x800000
33+
MACHINE_OBJ=src/x86/qemu_fsp.o
34+
FSP_T_BIN=./src/x86/fsp_t.bin
35+
FSP_M_BIN=./src/x86/fsp_m.bin
36+
FSP_S_BIN=./src/x86/fsp_s.bin
37+
STAGE1_AUTH=1
38+
64BIT=1
39+
ELF=1
40+
MULTIBOOT2=1
41+
42+
# TPM-NV anti-rollback (version floor and audit counters), tested by
43+
# tools/scripts/x86_fsp/qemu/test_qemu.sh -r
44+
ANTI_ROLLBACK=1
45+
ANTI_ROLLBACK_HALT_ON_FAILURE=1

‎docs/Targets.md‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ This README describes configuration of supported targets.
1515
* [Infineon AURIX TC4xx](#infineon-aurix-tc4xx)
1616
* [Intel x86-64 Intel FSP](#intel-x86_64-with-intel-fsp-support)
1717
* [Kontron VX3060-S2](#kontron-vx3060-s2)
18+
* [NAI 68INT6 (Intel Tiger Lake)](#nai-68int6-intel-tiger-lake)
1819
* [Microchip PIC32CK](#microchip-pic32ck)
1920
* [Microchip PIC32CZ](#microchip-pic32cz)
2021
* [Microchip PolarFire SoC](#microchip-polarfire-soc)
@@ -9719,6 +9720,74 @@ Attempting boot from partition A
97199720
```
97209721
At this point, the kernel image in partition "A" is verified and staged and you should be seeing the log messages of your OS booting.
97219722

9723+
## NAI 68INT6 (Intel Tiger Lake)
9724+
9725+
wolfBoot target `nai_68int6` for the North Atlantic Industries 68INT6, a 3U OpenVPX SOSA-aligned single board computer (Intel Core i7-1185GRE, Tiger Lake UP3). It uses the Intel FSP support described [above](#intel-x86_64-with-intel-fsp-support) and shares the Tiger Lake path with the Kontron target. wolfBoot boots a signed 64-bit Linux from the SATA disk with A/B update, measured boot and TPM anti-rollback, verified on a Rev D5 bench board. The public Tiger Lake FSP does not train this board's memory, so the FSP is extracted from a 68INT6 BIOS image.
9726+
9727+
| | |
9728+
|---|---|
9729+
| CPU | i7-1185GRE (`06-8C-01`), Tiger Lake UP3, PCH-LP |
9730+
| Memory | 2 x 32 GB DDR4-3200 SODIMM, non-ECC |
9731+
| BIOS flash | Rev C/D5: 2 x W25R256JV (32 MB), selected by JP36. Next revision: one 64 MB device |
9732+
| TPM | SLB9670 (SHA-1/256), or SLB9672, which adds a SHA-384 bank |
9733+
| Storage | Onboard SATA SSD, AHCI at `00:17.0` |
9734+
| Console | LPSS UART2, PCI `00:19.2`, RS-232; `X86_UART_NUMBER=2` |
9735+
9736+
### Building
9737+
9738+
```
9739+
cp config/examples/nai_68int6.config .config
9740+
./tools/scripts/x86_fsp/tgl/tgl_download_fsp.sh # FSP UPD headers, first time only
9741+
./tools/scripts/x86_fsp/tgl/nai_extract_fsp.sh <68INT6.bin> # board's own FSP blobs
9742+
./tools/scripts/x86_fsp/tgl/assemble_image.sh -k # generate signing keys
9743+
make
9744+
./tools/scripts/x86_fsp/tgl/assemble_image.sh -n <68INT6.bin>
9745+
```
9746+
9747+
`nai_extract_fsp.sh` takes FSP-T/M/S and the microcode from a 68INT6 BIOS image. Without it the build uses the public FSP, which compiles but does not train memory. The `-n` stitch replaces the top 6 MB (`BOOTLOADER_PARTITION_SIZE`) of the 12 MB BIOS region and keeps the descriptor and CSME byte for byte. The board has no recovery region (recovery is the second flash device), so use `-n`, not `-m`. The result is `final_image.bin`.
9748+
9749+
### Integrity algorithms
9750+
9751+
ECC P-384 and SHA-384 match what Intel Boot Guard uses for the Initial Boot Block.
9752+
9753+
| Layer | Algorithm |
9754+
|---|---|
9755+
| Image signature | ECC P-384 (`SIGN=ECC384`) |
9756+
| Image digest | SHA-384 (`HASH=SHA384`) |
9757+
| Measured boot PCR | SHA-256 (the SLB9670 has only SHA-1 and SHA-256 banks) |
9758+
9759+
`wolfBoot_image_measure()` re-hashes the authenticated digest with the PCR bank's algorithm, so one image serves either TPM. `MEASURED_PCR_ALG=SHA384` needs an SLB9672 with its SHA-384 bank allocated (`TPM2_PCR_Allocate` under platform auth, a provisioning step).
9760+
9761+
### Configuration
9762+
9763+
Notable options in [config/examples/nai_68int6.config](../config/examples/nai_68int6.config):
9764+
9765+
| Option | Meaning |
9766+
|---|---|
9767+
| `X86_UART_NUMBER=2` | LPSS UART2 for all three FSP phases (Kontron uses 0) |
9768+
| `ACPI=1` | Required. Generates ACPI tables (RSDP/XSDT/FADT/MADT/MCFG and a minimal DSDT); the board's PCI interrupt routing is only in the DSDT `_PRT`, since the MP table is the Kontron one |
9769+
| `ANTI_ROLLBACK=1` | Persistent version floor and boot audit counters in TPM NV |
9770+
| `MEASURED_BOOT=1`, `MEASURED_PCR_OS=4` | Firmware into PCR 0, the verified OS image into PCR 4 |
9771+
| `WOLFBOOT_BOOT_DISK=0` | Boot from GPT partitions; the A/B indices (sda3/sda4) are set in `src/update_disk.c` |
9772+
9773+
### BIOS region lock
9774+
9775+
Before handoff, `hal_flash_protect()` in the shared Tiger Lake HAL (`hal/x86_fsp_tgl.c`, as on Kontron) sets SPI Flash Protected Range 0 over the BIOS region with read and write protection, then FLOCKDN. Both hold until the next platform reset, so the booted OS cannot read or reprogram the BIOS region; update it with an external programmer.
9776+
9777+
### Anti-rollback
9778+
9779+
`ANTI_ROLLBACK=1` keeps a version floor and boot audit counters in a TPM NV index; the backend is `src/boot_state_tpm.c` and the policy is `src/boot_state.c`. The floor is the highest version ever booted, set trust-on-first-use. A validly signed older image still boots and records a rollback event. Only an untrustworthy reference halts the boot; `ANTI_ROLLBACK_HALT_ON_FAILURE=1` also halts when the TPM is unreachable, a write fails or the platform hierarchy cannot be disabled.
9780+
9781+
TPM NV is used instead of the partition state trailer because the floor must survive a full reimage of the disk or flash. `DISK_BOOT_CONFIRM` still handles per-slot confirmation, and the backend can move to a root-of-trust device later without changing the policy.
9782+
9783+
`ALLOW_DOWNGRADE` is left unset, the secure default: if the higher-versioned slot fails to verify, wolfBoot halts (`Rollback to lower version not allowed`) rather than boot the lower one. Building with `ALLOW_DOWNGRADE=1` allows that fall-back and leaves the TPM floor as the only rollback guard.
9784+
9785+
The booted OS cannot lower the floor. The index is platform-created and writable only under platform auth (`TPMA_NV_PPWRITE`), and on every boot wolfBoot disables the platform hierarchy (`TPM2_HierarchyControl`) until the next TPM reset, as in section 10 of the TCG PC Client Platform specification. The OS can then neither write nor undefine the index. An index with any other write attributes is treated as corrupt. Platform-auth provisioning, such as `TPM2_PCR_Allocate`, must be done before wolfBoot is installed.
9786+
9787+
### Boot, programming and recovery
9788+
9789+
wolfBoot boots the highest-versioned signed 64-bit `bzImage` that verifies from the two GPT boot partitions. It falls back to the other slot only if that is not a downgrade (see Anti-rollback), and halts if neither boots. Program the flash with a Dediprog SF100 on JP4 while the board is off; the BIOS region lock blocks `flashrom` from the booted OS. JP36 selects which bank boots and which one the programmer sees; move it only with the board off.
9790+
97229791
## Infineon PSOC Control C3
97239792

97249793
The [PSOC Control C3](https://www.infineon.com/products/microcontroller/32-bit-psoc-arm-cortex/32-bit-psoc-control-arm-cortex-m33-mcu/psoc-control-c3-main-line) family (PSC3, CAT1B) is an Arm Cortex-M33 motor-control MCU. wolfBoot runs as the first application the BootROM launches, verifies the signed firmware in the BOOT partition and jumps to it.

0 commit comments

Comments
 (0)