Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
9c9299b
nai_68int6: board devices and a per-image Linux or Multiboot2 payload
dgarske Oct 28, 2026
1efd95b
x86 fsp: cache FSP-M training data in flash, stop the NAI global reset
dgarske Oct 31, 2026
d7f754c
nai_68int6: stock BIOS PCIe switch sequence, GPIO levels and full reset
dgarske Nov 2, 2026
4987d22
x86 fsp: bound the ELF load, re-hash PCR 0, use a signed HDR_CMDLINE
dgarske Nov 3, 2026
4a0685c
x86 fsp: CPU list from topology, TPM2/HPET/DMAR, root port routing, _OSC
dgarske Nov 3, 2026
855a67e
x86 ata: use WRITE DMA EXT for sector writes and return command errors
dgarske Nov 3, 2026
c675edc
nai_68int6: configure the D0, C22 and H6 pads as the stock BIOS does
dgarske Nov 3, 2026
6e76bd0
x86 fsp: time the SPI hardware-sequencing waits from the TSC
dgarske Nov 5, 2026
27323f3
nai_68int6: add an FSP-M platform debug consent build option
dgarske Nov 5, 2026
c9a41c5
elf: reject p_filesz above p_memsz and sizes the map callback truncates
dgarske Nov 5, 2026
6c3f439
x86 fsp: mark a boot with cached training data until FSP-S succeeds
dgarske Nov 11, 2026
c96b3d7
x86 fsp: list only RAM and reserved memory in the Linux e820 map
dgarske Nov 11, 2026
9715bf6
nai_68int6: split the PCI BAR window into two 512 MB pools
dgarske Nov 11, 2026
2d2414f
x86 fsp: reserve the ECAM range in e820 so Linux uses MMCONFIG
dgarske Nov 11, 2026
78843ce
x86 fsp: check cached training data against a TPM NV hash in stage 1
dgarske Nov 11, 2026
538c134
x86 fsp: fix review findings in the training data cache and ELF map
dgarske Nov 12, 2026
1a1efa2
nai_68int6: drive the PCIe switch straps right after cache-as-RAM
dgarske Nov 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ tools/unit-tests/unit-fwtpm-nv-oob
tools/unit-tests/unit-x86-paging-oob
tools/unit-tests/unit-ahci-unlock-panic
tools/unit-tests/unit-ata-security-passphrase-zeroize
tools/unit-tests/unit-ata-sector-io
tools/unit-tests/unit-arm-tee-psa-ipc
tools/unit-tests/unit-flash-write-mcxa
tools/unit-tests/unit-rw612-flash
Expand Down Expand Up @@ -633,6 +634,13 @@ tools/unit-tests/unit-hifive1-flash-write
tools/unit-tests/unit-hifive1-hfrosccfg
tools/unit-tests/unit-keygen-keystore
tools/unit-tests/unit-kontron-tgl-spi
tools/unit-tests/unit-fsp-nvs
tools/unit-tests/unit-fsp-nvs-save
tools/unit-tests/unit-tgl-spi-hwseq
tools/unit-tests/unit-x86-apic-ids
tools/unit-tests/unit-x86-acpi
tools/unit-tests/unit-boot-x86-fsp-measure
tools/unit-tests/unit-boot-x86-fsp-payload
tools/unit-tests/unit-nrf5340-flash-protect
tools/unit-tests/unit-nrf5340-uart-crlf
tools/unit-tests/unit-nrf54l-uart-write
Expand Down Expand Up @@ -678,6 +686,8 @@ tools/unit-tests/keystore_gen
tools/unit-tests/kinetis_erase_extract.h
tools/unit-tests/kontron_spi_extract.h
tools/unit-tests/kontron_spi_fn_extract.h
tools/unit-tests/tgl_spi_hwseq_extract.h
tools/unit-tests/x86_apic_ids_extract.h
tools/unit-tests/nrf5340_protect_fn_extract.h
tools/unit-tests/nrf54l_uart_write_extract.h
tools/unit-tests/p1021_erase_extract.h
Expand Down
11 changes: 11 additions & 0 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2659,6 +2659,14 @@ ifeq ("${FSP}", "1")
OBJS+=src/x86/tgl_fsp.o
OBJS+=src/ucode0.o
CFLAGS += -DUCODE0_ADDRESS=$(UCODE0_BASE)
ifeq ($(FSP_NVS_CACHE),1)
OBJS+=src/x86/fsp_nvs.o
ifeq ($(FSP_NVS_TPM),1)
ifneq ($(filter-out $(STAGE1_AUTH),1),)
OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sha256.o
endif
endif
endif
endif
else
# building wolfBoot
Expand Down Expand Up @@ -2705,6 +2713,9 @@ ifeq ("${FSP}", "1")
endif
ifeq ($(FSP_TGL), 1)
OBJS+=src/x86/tgl_fsp.o
ifeq ($(FSP_NVS_CACHE),1)
OBJS+=src/x86/fsp_nvs.o
endif
endif
endif
ifeq ($(64BIT),1)
Expand Down
25 changes: 24 additions & 1 deletion config/examples/nai_68int6.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ENCRYPTION=0
WOLFBOOT_NO_PARTITIONS=1
# Disk boot: signed kernels in GPT partitions 3/4, Ubuntu root in partition 2.
# The A/B boot-partition indices are set per target in src/update_disk.c.
WOLFBOOT_BOOT_DISK=0
FORCE_32BIT=1

########## Flash layout (measured from the factory descriptor, 32 MB) ##########
Expand All @@ -41,6 +40,15 @@ BIOS_REGION_SIZE=0xc00000
UCODE0_BASE=0xffd90000
UCODE0_BIN=src/x86/ucode0.bin

# FSP memory training data cache: 128 KB of the BIOS region just below the
# wolfBoot window, so it survives a reflash of the window.
FSP_NVS_CACHE=1
FSP_NVS_BASE=0xff9e0000
FSP_NVS_SIZE=0x20000
# Set to 1 to check the saved training data against a hash in TPM NV before
# FSP-M uses it (needs ANTI_ROLLBACK=1, ANTI_ROLLBACK_HALT_ON_FAILURE=1)
FSP_NVS_TPM=0

FSP_T_BIN=./src/x86/fsp_t.bin
FSP_M_BIN=./src/x86/fsp_m.bin
FSP_S_BIN=./src/x86/fsp_s.bin
Expand All @@ -67,6 +75,21 @@ PCI_USE_ECAM=1
PCH_HAS_PCR=1
# Generate ACPI tables so Linux gets the interrupt model and PCI routing.
ACPI=1
# MP table entries, one per logical processor: 4 cores with Hyper-Threading
MP_CPU_NUM_ENTRY=8

########## PCIe switch and backplane (stock BIOS defaults) ##########
# Lanes: 8x1, 1x4_4x1, 4x1_1x4, 1x4_1x4 or 1x8. Delays are in seconds.
NAI_68INT6_PCIE_LANES=8x1
NAI_68INT6_PCIE_NT=0
NAI_68INT6_BACKPLANE_CLK=0
NAI_68INT6_PCIE_LINK_DELAY_S=0
NAI_68INT6_BOOT_DELAY_S=0
NAI_68INT6_FPGA_READY_DELAY_S=0

# Debug consent for a JTAG probe: 0 = off (keep 0 in a shipping image),
# 4 = XDP/MIPI-60
NAI_68INT6_DEBUG_CONSENT=0

########## Payload: signed 64-bit Linux bzImage ##########
64BIT=1
Expand Down
44 changes: 35 additions & 9 deletions docs/Targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -9185,7 +9185,7 @@ wolfBoot target `nai_68int6` for the North Atlantic Industries 68INT6, a 3U Open
| | |
|---|---|
| CPU | i7-1185GRE (`06-8C-01`), Tiger Lake UP3, PCH-LP |
| Memory | 2 x 32 GB DDR4-3200 SODIMM, non-ECC |
| Memory | DDR4-3200, soldered down, with In-Band ECC (`FSP_IN_BAND_ECC`) |
| BIOS flash | Rev C/D5: 2 x W25R256JV (32 MB), selected by JP36. Next revision: one 64 MB device |
| TPM | SLB9670 (SHA-1/256), or SLB9672, which adds a SHA-384 bank |
| Storage | Onboard SATA SSD, AHCI at `00:17.0` |
Expand All @@ -9197,12 +9197,11 @@ wolfBoot target `nai_68int6` for the North Atlantic Industries 68INT6, a 3U Open
cp config/examples/nai_68int6.config .config
./tools/scripts/x86_fsp/tgl/tgl_download_fsp.sh # FSP UPD headers, first time only
./tools/scripts/x86_fsp/tgl/nai_extract_fsp.sh <68INT6.bin> # board's own FSP blobs
./tools/scripts/x86_fsp/tgl/assemble_image.sh -k # generate signing keys
make
make # first build generates the signing key
./tools/scripts/x86_fsp/tgl/assemble_image.sh -n <68INT6.bin>
```

`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`.
The host needs `nasm`, `gcc-multilib` and `python-is-python3` besides the usual build tools. `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). The result is `final_image.bin`.

### Integrity algorithms

Expand All @@ -9214,7 +9213,7 @@ ECC P-384 and SHA-384 match what Intel Boot Guard uses for the Initial Boot Bloc
| Image digest | SHA-384 (`HASH=SHA384`) |
| Measured boot PCR | SHA-256 (the SLB9670 has only SHA-1 and SHA-256 banks) |

`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).
Stage 1 re-hashes stage 2's authenticated SHA-384 digest with SHA-256 and extends PCR 0 with the result, as stage 2 does for the OS image in PCR 4, so `tools/scripts/x86_fsp/compute_pcr.py` can predict PCR 0. Only the SHA-256 PCR bank is supported.

### Configuration

Expand All @@ -9223,10 +9222,18 @@ Notable options in [config/examples/nai_68int6.config](../config/examples/nai_68
| Option | Meaning |
|---|---|
| `X86_UART_NUMBER=2` | LPSS UART2 for all three FSP phases (Kontron uses 0) |
| `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 |
| `ACPI=1` | Required. Generates ACPI tables (RSDP/XSDT/FADT/MADT/MCFG/TPM2/HPET/DMAR and a minimal DSDT with the TPM device); the board's PCI interrupt routing is only in the DSDT `_PRT`, since the MP table is the Kontron one. The DSDT also declares the board devices on LPSS I2C0 (EEPROMs, RTC/watchdog) and GSPI0 (the PRC, for NAI's `naigspi` driver) |
| `FSP_NVS_CACHE=1`, `FSP_NVS_BASE`, `FSP_NVS_SIZE` | Keeps FSP-M's memory training data (its non-volatile storage HOB) in a 128 KB area of the BIOS region below the wolfBoot window, so later boots skip full memory training. Stage 1 passes a valid copy back through `NvsBufferPtr`; stage 2 rewrites it, before FSP-S and before the BIOS region is locked, only when it changes. The record is keyed on a CRC of the FSP-M image and its UPDs, so a change to either falls back to full training. Stage 1 sets a CMOS flag before FspMemInit runs with a saved record, an FSP-requested reset clears it, and stage 2 clears it once FspSiliconInit succeeds. If FspMemInit fails with the record, or a boot finds the flag still set because the previous boot crashed or hung with the record, boots train from scratch until one gets through FspSiliconInit, and stage 2 replaces the record. The flag is kept in CMOS, so it survives a reset but needs the RTC battery to survive loss of power. `assemble_image.sh -n` blanks the area, so an image built from a board's flash dump does not carry that board's training data |
| `FSP_NVS_TPM=1` | Authenticates the saved training data, which is otherwise the only unauthenticated input FSP-M consumes. Stage 2 keeps a SHA-256 of the record in a TPM NV index that only the platform hierarchy can write, and stage 1 reads it, before memory is up, and compares it with the record in flash before handing the record to FspMemInit; without a match it trains from scratch. Needs `ANTI_ROLLBACK=1`, which disables the platform hierarchy before handoff so the OS cannot rewrite the hash, and `ANTI_ROLLBACK_HALT_ON_FAILURE=1`, so a boot that cannot disable it halts. The first boot after enabling it trains once. Without this option, prefer `FSP_NVS_CACHE=0` on a Boot Guard image |
| `FSP_HYPERTHREADING=1` | Hyper-Threading on (off by default). The MADT and the MP table list the enabled logical processors from the CPUID topology, so either setting works |
| `MP_CPU_NUM_ENTRY=8` | MP table processor entries, one per logical processor (default 4) |
| `WOLFBOOT_CMDLINE_MAX` | Buffer for a signed `HDR_CMDLINE`, including the terminating NUL (default 256); a longer command line is ignored and the built-in one is used |
| `NAI_68INT6_PCIE_LANES` | PCIe switch lane configuration, strapped on GPP_B21/B22/S4/S7/S6 before memory init: `8x1` (default), `1x4_4x1`, `4x1_1x4`, `1x4_1x4` or `1x8` |
| `NAI_68INT6_PCIE_NT`, `NAI_68INT6_BACKPLANE_CLK` | PCIe switch non-transparent mode (GPP_S2) and the backplane PCIe clock (GPP_A0); both off by default |
| `NAI_68INT6_PCIE_LINK_DELAY_S`, `NAI_68INT6_BOOT_DELAY_S`, `NAI_68INT6_FPGA_READY_DELAY_S` | Waits before CPU PCIe link training (0-5 s), before polling PCIE_RDY (0-255 s), and added to the 5 s PCIE_RDY timeout (0, 5 or 10 s); all 0 by default. Before PCI enumeration wolfBoot polls PCIE_RDY (GPP_C23) every 50 ms, continues with a warning on timeout, then drives GPP_B12 high |
| `NAI_68INT6_DEBUG_CONSENT` | FSP-M `PlatformDebugConsent`: 0 = debug disabled (default; keep it for a shipping image), 4 = enabled for an XDP/MIPI-60 JTAG probe |
| `ANTI_ROLLBACK=1` | Persistent version floor and boot audit counters in TPM NV |
| `MEASURED_BOOT=1`, `MEASURED_PCR_OS=4` | Firmware into PCR 0, the verified OS image into PCR 4 |
| `WOLFBOOT_BOOT_DISK=0` | Boot from GPT partitions; the A/B indices (sda3/sda4) are set in `src/update_disk.c` |

### BIOS region lock

Expand All @@ -9236,15 +9243,34 @@ Before handoff, `hal_flash_protect()` in the shared Tiger Lake HAL (`hal/x86_fsp

`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.

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.
TPM NV is used instead of the partition state trailer because the floor must survive a full reimage of the disk or flash. Per-slot boot confirmation is `DISK_BOOT_CONFIRM`, which this configuration leaves off, and the backend can move to a root-of-trust device later without changing the policy.

`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.

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.

### Boot, programming and recovery

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.
wolfBoot boots the highest-versioned signed 64-bit `bzImage` or Multiboot2 ELF 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. Before handoff it sets FULL_RST in the Reset Control register (0xCF9), as the stock BIOS does, so a later reset such as SYS_RESET# from the IPMC is a full reset. A kernel command line signed into the OS image (`sign --cmdline`, the `HDR_CMDLINE` TLV) replaces the built-in one, so changing a kernel argument does not need a reflash. 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.

### Multiboot2 ELF payloads

The configuration builds both payload paths (`LINUX_PAYLOAD=1`, `ELF=1`, `MULTIBOOT2=1`), and `do_boot()` picks one per image: an image that starts with the ELF magic takes the Multiboot2 path, and anything else boots as Linux. A Multiboot2 RTOS image is signed and written to an A/B slot the same way as a kernel:

```
./tools/keytools/sign --ecc384 --sha384 <payload.elf> wolfboot_signing_private_key.der <version>
```

The two paths differ only in the handoff:

| | Linux `bzImage` | Multiboot2 ELF |
|---|---|---|
| Entry | 64-bit Linux boot protocol, `boot_params` and the command line | ELF segments loaded at their physical addresses, virtual addresses mapped in wolfBoot's page tables, jump to `e_entry` in 64-bit mode with EAX=`0x36d76289` and EBX pointing to the Multiboot2 information |
| Memory map | E820 table in `boot_params` | Multiboot2 memory map and basic memory information tags, from the FSP HOBs |
| ACPI tables | Generated (`ACPI=1`) | None; they are only built on the Linux path |
| RTC | The legacy CMOS RTC is ignored under the hardware-reduced ACPI tables; the I2C0 RTC is declared in the DSDT | The CMOS RTC is usable directly; I2C0 is enabled for the board RTC |

Segments are loaded from the verified image only, and a segment that would overlap wolfBoot's own memory (from the stage 2 load address up to 4 GB) is rejected before anything is copied. Everything else is shared: FSP silicon setup (VT-d at the stock BIOS addresses, Hyper-Threading off), the halted PCH TCO watchdog, the BIOS region lock, measured boot, anti-rollback and A/B selection.

## Infineon PSOC Control C3

Expand Down
8 changes: 8 additions & 0 deletions hal/nai_68int6.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ void hal_init(void)
fsp_init_silicon();
}

/* Reset Control (0xCF9) FULL_RST: written alone it starts no reset, but makes
* any later reset a full one, as the stock BIOS does before the OS loader
* (its OS Reset Select default, Cold Reset). That covers SYS_RESET# from the
* IPMC, which is otherwise a warm reset. */
#define RST_CNT_PORT 0xcf9
#define RST_CNT_FULL_RST (1 << 3)

void hal_prepare_boot(void)
{
io_write8(RST_CNT_PORT, RST_CNT_FULL_RST);
}
#endif /* __WOLFBOOT */

Expand Down
Loading
Loading