Commit Graph

551 Commits (2fdc99f323f1663a5cd551c032bdf7e9b34b2a09)

Author SHA1 Message Date
Daniele Lacamera 2fdc99f323 pci: keep the allocation cursors 64-bit at the 4 GiB pool end
The cursors mem, mem_pf and io advanced as 32-bit values: after a
BAR allocation whose end is exactly the pool end 0x100000000 (now
reachable), *base = bar_value + length wrapped to 0.  Every later
allocation then passed the start and end checks and programmed its
BAR at address 0, over the legacy IO range and DRAM.

Widen the three cursors to 64-bit and advance with a 64-bit sum, so
an exhausted pool leaves the cursor at the end.  The address
parameters of pci_enum_next_aligned32 and pci_align_check_up widen
with them; pci_enum_next_aligned32 computes in uint64_t rather than
uintptr_t, which on 32-bit targets would truncate the exhausted
cursor back to 0 and defeat the addr > 0xffffffff rejection.  The
programmed BAR value stays 32-bit.

The 4 GiB pool unit test now also adds a second device with a
preset (previously programmed) BAR: exactly filling the pool must
leave that BAR untouched instead of re-allocating it from a wrapped
cursor.  The mock learns to seed a BAR preset from the bar info,
and the loop variable shadowing in test_pci_commit that it exposed
is fixed (the inner preset loop clobbered the outer node loop
counter, so only the first node was ever committed).

Verified: unit-pci 30/30, unit-pci-4gib green, full nxp_t1024
powerpc build green.
2026-08-26 20:05:56 +02:00
Daniele Lacamera b115363291 pci: accept MMIO pools whose exclusive end is 4 GiB
A pool ending exactly at 0x100000000 (e.g. 0xC0000000 + 0x40000000,
the classic top-half 32-bit MMIO layout) was a working configuration:
the old base + length - 1 initialization wrapped to 0xFFFFFFFF in
32-bit arithmetic. The overflow guard from the exclusive-limit fix
rejected such pools with base + length > 0xFFFFFFFF, aborting
enumeration - and the FSP caller discards the return value, so the
platform would boot with no PCI BARs programmed.

The limit fields cannot hold the exclusive end 0x100000000 while
32-bit, so widen mem_limit and mem_pf_limit (and the limit
parameters of pci_enum_next_aligned32 and pci_align_check_up, plus
the local in pci_program_bar) to 64-bit, and reject only pools whose
end is above the 32-bit space. The initialization now casts to
64-bit before the addition so the sum cannot wrap.

The T10xx PCIe setup initializes the same struct with the old
inclusive base + length - 1 form; align it to the exclusive
semantics the allocator enforces, or the last byte of the configured
pool is unusable.

New unit-pci-4gib build of the existing test file with the MMIO
pool [0xC0000000, 0x100000000): pci_enum_do() must accept the pool
and map a 1 MB BAR at the pool base. Fails on the old guard.
2026-08-26 18:59:48 +02:00
David Garske 25cdd5a0d7 c2000: add wolfBoot TI C28x (TMS320F28P550SJ) secure-boot XIP port 2026-08-25 00:01:33 +02:00
David Garske c409adb088 lib/wolfssl: bump to ti_c25 merge (e71b086fc) for CHAR_BIT!=8 wide-byte support 2026-08-25 00:01:33 +02:00
David Garske a5c94502d4
Merge pull request #868 from danielinux/fenrir-fixes-2026-08-21
Fenrir fixes 2026 08 21
2026-08-24 13:34:37 -04:00
David Garske 8015a1fa4f Peer review fixes (thanks Daniele) 2026-08-24 12:47:34 +02:00
David Garske 88984858d5 Peer review fixes (thanks Jack) 2026-08-24 12:47:34 +02:00
David Garske 67c819bc0b cm4: add RAUC A/B slot selection via U-Boot env (wolfBoot replaces U-Boot) 2026-08-24 12:47:34 +02:00
David Garske 56651bde95 cm4: add Linux kernel FIT boot via firmware-provided DTB with injected bootargs 2026-08-24 12:47:34 +02:00
David Garske 71b855f7b5 cm4: add wolfCrypt FIPS 140-3 support + CI, SDHCI unit test, review fixes 2026-08-24 12:47:34 +02:00
Daniele Lacamera 9b1a48554a share the DTS size bounds in fdt.h and state the window assumption
The WOLFBOOT_DTS_MAX_SIZE/WOLFBOOT_DTS_MIN_SIZE pair was defined
separately in update_disk.c (F-7066) and update_ram.c (pre-existing), so
the two copies could drift. Move it to include/fdt.h, the FDT dialect
header both translation units already pull in via image.h; the hal
override (nxp_ppc.h, included before fdt.h in boot_ppc.c) keeps its
precedence. Also replace the 'bounded by the staging region' comment,
which claimed more than the code guarantees: the copy is clamped to
WOLFBOOT_DTS_MAX_SIZE, so the staging window at
WOLFBOOT_LOAD_DTS_ADDRESS must be at least that large (or the bound
overridden for the target), and the header comment now says so.

Skoll review finding 3, 2026-08-21 wolfboot review.
2026-08-21 09:08:26 +02:00
Brett Nicholas 25aa151f0b add asymmetric partition sizing for monolithic updates 2026-08-19 17:47:48 +02:00
David Garske d42109c843
Merge pull request #862 from danielinux/fenrir-fixes-2026-08-18
Fenrir fixes 2026 08 18
2026-08-18 12:12:50 -07:00
Daniele Lacamera 502a69e9df Condense the verbose comments
The test file headers ran to 20-40 lines of prose before the licence,
restating the whole finding and the harness design. Cut them to a short
paragraph on what broke and a short one on how the test reaches the
code. Same for the long inline blocks in the HAL and libwolfboot
changes.

Comments only; no functional change.
2026-08-18 20:12:06 +02:00
David Garske 27edd0f5e7 tegra234: bare-metal BL33 target with verified EL2->EL1 + device-tree boot 2026-08-18 11:01:45 +02:00
Daniele Lacamera 3865c62614 user_settings: actually harden fast math for software DICE
tfm.c never tests WC_NO_HARDEN, so dropping it enabled nothing; it only
un-silenced the advisory #warning in settings.h, which -Werror turns
into a build failure for any USE_FAST_MATH + WOLFCRYPT_TZ_PSA build.
Define TFM_TIMING_RESISTANT, which is what makes tfm.c constant time.
2026-08-18 09:19:13 +02:00
Daniele Lacamera b9c32027bc F-9722: keep WC_NO_HARDEN out of software-DICE fast-math builds
The comment justified WC_NO_HARDEN on the grounds that 'wolfBoot only
does public asymmetric operations'. That is not true for software
DICE: with WOLFCRYPT_TZ_PSA and no WOLFBOOT_DICE_HW, src/dice/dice.c
retrieves the private IAK (wolfboot_attest_get_private_key) and signs
the attestation claims with wc_CoseSign1_Sign_ex(), and arch.mk still
selects USE_FAST_MATH for those builds. A configuration maintainer
trusting the comment would have left the private-key signing path
without timing hardening.

Gate the definition to verify-only configurations: WC_NO_HARDEN is
now defined only when WOLFCRYPT_TZ_PSA is absent or WOLFBOOT_DICE_HW
is set (hardware DICE keeps signing in the crypto engine), and the
comment states the actual rationale.

Verified with a preprocessor probe: plain fast-math and hardware DICE
still get WC_NO_HARDEN; software DICE no longer does.
2026-08-18 05:03:00 +02:00
Daniele Lacamera 3a3f66e1b4 F-9720: describe IMG_STATE_TESTING as the post-swap boot-confirmation state
The comment labeled IMG_STATE_TESTING as an 'ELF loading state', but
the constant is wolfBoot's general dual-bank confirm/rollback marker:
it is set on the BOOT partition after every swap (update_flash.c,
update_flash_hwswap.c, update_ram.c - none ELF-specific) and cleared
by wolfBoot_success(); if still present at the next boot it triggers
a rollback. A maintainer trusting the old comment could have treated
the state as inert on non-ELF targets and disabled the anti-brick
path.

Reword to the accurate description already used in
docs/flash_partitions.md, keeping the note that it only lives on the
boot partition so it cannot conflict with IMAGE_STATE_UPDATING.

Comment-only change; no code or behavior changes.
2026-08-18 05:01:22 +02:00
Alex Lanzano 4fb9e81b44
Merge pull request #853 from dgarske/zynqmp_sdhci_reset
SDHCI: fix silent read failures and unbootable warm reset with UHS-I cards
2026-08-14 12:51:20 -04:00
David Garske c8faa5adc2 Authenticate raw device tree via signed HDR_DEVICE_TREE_DIGEST TLV (Fenrir #7998) 2026-08-13 08:39:22 +02:00
David Garske 38ec1e1bed sdhci: fix silent read failures and unbootable warm reset with UHS-I cards 2026-08-11 15:37:56 -07:00
David Garske 2b3b7034a5 aarch64_efi: address PR818 review (measure cmdline, DTB GUID, size/page/desc fixes) 2026-08-10 21:03:50 +02:00
David Garske 4a16dce4f8 efi: authenticate the kernel command line via a signed HDR_CMDLINE manifest TLV 2026-08-10 21:03:50 +02:00
Daniele Lacamera 31f0168afc ARMORED: harden digest comparison against instruction skips 2026-08-05 20:13:44 +02:00
David Garske 5f40400e57 PolarFire SoC: address PR review
- wolfBoot_fit_memcpy: return int so a failed PDMA copy propagates instead
  of being swallowed. The weak default (memcpy) returns 0; the MPFS250 PDMA
  override returns -1 if any chunk's mpfs_pdma_memcpy() fails. Callers now
  fail closed: fit_load_image_inner returns NULL (kernel load then panics
  via update_disk.c), the update_disk DTS copy panics, and hal_dts_fixup
  returns an error on a failed L2->DDR copy-back.
- options.mk: gate -DSTACK_SIZE_PER_HART behind RISC-V arch (RISCV/RISCV64).
  The macro is only consumed by the RISC-V startup asm and the mpfs250-m.ld
  sed token, so it is no longer emitted for PPC/ARM/other targets. The
  unconditional default (?= 0) is kept because the linker sed always needs
  a value to substitute.
2026-08-03 12:27:22 +02:00
David Garske e718eed709 PolarFire SoC: LPDDR4 DDR init for MPFS250T Video Kit (M-Mode) 2026-08-03 12:27:22 +02:00
Mattia Moffa bb6aa35d02 Don't define WOLFSSL_HAVE_SP_ECC under SP_MATH_ALL (fixes CI) 2026-07-31 14:33:56 +02:00
Mattia Moffa 60b9e87413 SHA256 acceleration for bootloader 2026-07-31 14:33:56 +02:00
Mattia Moffa f5f54c294e Implementation of test-app crypto test 2026-07-31 14:33:56 +02:00
David Garske d073ae4ddb watchdog: add generic feed hook and RX driver 2026-07-30 15:32:31 +02:00
David Garske eaa39be9e4 renesas-rx: fix build for GCC RX 8.3/14.2 2026-07-30 15:32:31 +02:00
David Garske 29c9ea1ce1 test-app: add wolfIP + wolfCrypt test harness and PPC crypto asm 2026-07-30 13:29:09 +02:00
Aidan Garske 4ab9891830
Merge pull request #836 from bigbrett/wh-tz-fix-unconditional-sha512-enable
fix unconditional SHA512 opt-in for wolfHSM builds
2026-07-29 12:21:54 -07:00
Marco Oliverio 15c7e621ed wolfHSM client: target-independent build fixes and improvement
Four fixes needed by any wolfHSM client

- include/user_settings.h emitted "typedef struct WC_RNG WC_RNG;" whenever
  WOLF_CRYPTO_CB && WC_NO_RNG, with no __ASSEMBLER__ guard, so a client built
  with ARM thumb2 assembly failed to assemble wolfSSL's .S sources. Guard it.

- options.mk hardcoded WOLFHSM_CFG_COMM_DATA_LEN=5000 for every client. Make
  it a variable (default unchanged) so ports whose transport slot is smaller
  can override it.

- options.mk gated DEBUG_UART on the existence of the driver *object*, which
  never exists on a clean tree, so DEBUG_UART was dropped on the very build
  meant to enable it. Test for the source instead.

- Makefile unconditionally built an NVM key image with whnvmtool for
  WOLFHSM_CLIENT=1. Add WOLFHSM_NVM_IMAGE=0 for ports that install the
  verification key at boot instead.
2026-07-29 18:07:45 +02:00
Brett Nicholas fa53af0b49 remove unconditional SHA512 opt-in for wolfHSM server targets and scope to only TZ mode 2026-07-28 13:14:53 -06:00
David Garske 1ceaef3eee zynqmp: wolfBoot ZynqMP FSBL with signed FIT Linux boot and EL3 security (eFuse/PUF/AES-CSU) 2026-07-22 11:56:40 +02:00
Brett Nicholas 235bd820e6 Add support for auxillary algorithms and cert chain/TPM usage 2026-07-22 11:47:16 +02:00
Daniele Lacamera 4d67268a03 version: 2.9.0 2026-07-02 22:58:46 +02:00
Daniele Lacamera 195610647c armored: address review on hardened compare and fw_base check 2026-07-02 20:33:07 +02:00
Daniele Lacamera 6708438024 armored: use hardened digest compare in elf and delta paths 2026-07-02 20:11:46 +02:00
Daniele Lacamera eca9a20b3b armored: harden fw_base against fault injection 2026-07-02 20:09:16 +02:00
Mattia Moffa d15f4cbbf2 Revert check for overlap of swap/update with bootloader
Some configs may exploit that possibility
2026-07-02 17:53:12 +02:00
Mattia Moffa ef03cf007f Fix additional findings
- Check diag_erase() return value in wolfBoot_record_failure()
- Dedicated WOLFBOOT_FAILURE_PHASE_SELF_UPDATE
- Mark the diagnostics flash write buffers XALIGNED_STACK(4) for HALs
  that access the source word by word
- Ensure diagnostics, update, or swap partitions don't overlap the
  bootloader
2026-07-02 17:53:12 +02:00
Mattia Moffa 1da9866630 Diagnostics: record additional events
- Failed boot after emergency update (WOLFBOOT_FAILURE_PHASE_RECOVERY)
- Failed verification of self-update image
2026-07-02 17:53:12 +02:00
Mattia Moffa 00e228d8d7 Check diagnostics partition is aligned and doesn't overlap
Also updates docs to specify the requirement of the HAL flash driver by
wolfBoot_clear_failures().
2026-07-02 17:53:12 +02:00
Mattia Moffa ceaed58782 Allow configuration of diagnostics record size on flash 2026-07-02 17:53:12 +02:00
Mattia Moffa 69e8e044c9 Add unit tests 2026-07-02 17:53:12 +02:00
Mattia Moffa 7cc4990907 Add option to persist boot/update failure info to flash
When boot/update partition verification fails during boot or update,
with this option the event is logged to flash in an ad-hoc partition.
Information about logged failures is made available to the application
through an API.
2026-07-02 17:53:12 +02:00
Daniele Lacamera ed695bb0a2 armored: reset integrity state and extend sanity check 2026-07-01 20:28:58 +02:00
Daniele Lacamera 93f068b930 armored: harden image integrity check against fault injections 2026-07-01 19:48:02 +02:00