Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions .github/workflows/test-endian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,14 @@ jobs:
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -o Acquire::Retries=3
# Ubuntu 26.04 dropped qemu-user-static: qemu-user carries the
# static emulators there, as qemu-ppc.
QEMU_PKG=qemu-user-static
apt-cache policy "$QEMU_PKG" | grep -q 'Candidate: [0-9]' \
|| QEMU_PKG=qemu-user
sudo apt-get install --no-install-recommends -y -q \
-o Acquire::Retries=3 \
gcc-powerpc-linux-gnu libc6-dev-powerpc-cross qemu-user-static \
gcc-powerpc-linux-gnu libc6-dev-powerpc-cross "$QEMU_PKG" \
dosfstools mtools e2fsprogs
# Fixture generation takes minutes, so prove the cross toolchain works
Expand All @@ -39,8 +44,9 @@ jobs:
powerpc-linux-gnu-gcc -static -o /tmp/be_probe /tmp/be_probe.c
file /tmp/be_probe | grep -q 'MSB' \
|| { echo "cross-compiler did not produce a big-endian binary"; exit 1; }
qemu-ppc-static /tmp/be_probe \
|| { echo "qemu-ppc-static cannot run a big-endian binary"; exit 1; }
QEMU_PPC=$(command -v qemu-ppc-static || command -v qemu-ppc)
"$QEMU_PPC" /tmp/be_probe \
|| { echo "$QEMU_PPC cannot run a big-endian binary"; exit 1; }
echo "big-endian toolchain OK"
- name: generate filesystem fixtures
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/test-sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ on:

jobs:
sbom_canary:
runs-on: ubuntu-latest
# Held on 24.04: the macro capture runs each compiler at its own default
# language standard, and from GCC 15 that default is C23, which defines
# macros (the <stdint.h> *_WIDTH family) that clang's default does not.
# The neutrality check below then fails on 26.04 until the capture pins a
# standard.
runs-on: ubuntu-24.04
timeout-minutes: 20

steps:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-x86-fsp-qemu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -o Acquire::Retries=3
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 swtpm uuid-dev
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 swtpm uuid-dev python3-setuptools
- name: run test
run: |
./tools/scripts/x86_fsp/qemu/test_qemu.sh
Expand All @@ -65,7 +65,7 @@ jobs:
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -o Acquire::Retries=3
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 uuid-dev dosfstools mtools e2fsprogs
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 uuid-dev python3-setuptools dosfstools mtools e2fsprogs
- name: run test
run: |
./tools/scripts/x86_fsp/qemu/test_qemu.sh -f
Expand All @@ -84,7 +84,7 @@ jobs:
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update -o Acquire::Retries=3
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 swtpm uuid-dev
sudo apt-get install --no-install-recommends -y -q -o Acquire::Retries=3 nasm gcc-multilib qemu-system-x86 swtpm uuid-dev python3-setuptools
- name: run test
run: |
./tools/scripts/x86_fsp/qemu/test_qemu.sh -r
4 changes: 4 additions & 0 deletions arch.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2609,6 +2609,10 @@ endif
# x86-64 FSP targets
ifeq ("${FSP}", "1")
CFLAGS+=-DWOLFBOOT_FSP=1
# State the baseline CPU. A distribution compiler can default to a newer
# level (Ubuntu's amd64v3 variant targets x86-64-v3), and the BMI2-class
# instructions it then emits fault on a CPU, real or emulated, without them.
CFLAGS+=-march=x86-64
USE_GCC_HEADLESS=0
LD_START_GROUP =
LD_END_GROUP =
Expand Down
5 changes: 5 additions & 0 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ int memcmp(const void *_s1, const void *_s2, size_t n)
return diff;
}

/* A C23 <string.h> defines memchr as a macro that keeps the constness of
* its argument; this is the function itself. */
#ifdef memchr
#undef memchr
#endif
void* memchr(void const *s, int c_in, size_t n)
{
unsigned char c = (unsigned char)c_in;
Expand Down
2 changes: 1 addition & 1 deletion tools/fs-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Two notes on the fixtures:

## Big-endian coverage

`make check` also runs the fixtures as **big-endian PowerPC** under `qemu-user`, when `powerpc-linux-gnu-gcc` and `qemu-ppc-static` are installed. It skips with a note otherwise.
`make check` also runs the fixtures as **big-endian PowerPC** under `qemu-user`, when `powerpc-linux-gnu-gcc` and `qemu-ppc-static` (or `qemu-ppc`, on distributions whose `qemu-user` package replaced `qemu-user-static`) are installed. It skips with a note otherwise.

This matters because the parsers read every multi-byte on-media field through byte-wise accessors (`fs_le16` / `fs_le32`) rather than casting a buffer to a struct. That should make them endian-neutral, and the big-endian run proves it instead of assuming it.

Expand Down
9 changes: 6 additions & 3 deletions tools/fs-test/runtests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ neg ext4-4k.img 0 "/a/b/c/d/e/f/g/h/i/j/k/l.itb" "path too deep"
# entries, and every FAT32/ext4 field. All of it is read byte-wise, so the
# whole stack should be endian-neutral. Prove it by running the same
# fixtures as big-endian PowerPC under qemu-user.
# The emulator is qemu-ppc-static where the qemu-user-static package exists,
# and qemu-ppc from qemu-user on distributions that dropped it.
QEMU_PPC=$(command -v qemu-ppc-static || command -v qemu-ppc || true)
if command -v powerpc-linux-gnu-gcc >/dev/null 2>&1 && \
command -v qemu-ppc-static >/dev/null 2>&1; then
[ -n "$QEMU_PPC" ]; then
echo
echo "=== big-endian (PowerPC), full stack incl. MBR/GPT ==="
# Do NOT hide this build. A cross-compile failure here (a missing
Expand All @@ -86,7 +89,7 @@ if command -v powerpc-linux-gnu-gcc >/dev/null 2>&1 && \
local img="$1" path="$2"
[ -f "$F/$img" ] || return
printf " %-26s " "$img"
if qemu-ppc-static ./fs-test-be verify "$F/$img" 0 "$path" \
if "$QEMU_PPC" ./fs-test-be verify "$F/$img" 0 "$path" \
"$F/payload/os.itb" >/dev/null 2>&1; then
echo "PASS"; pass=$((pass + 1))
else
Expand All @@ -102,7 +105,7 @@ if command -v powerpc-linux-gnu-gcc >/dev/null 2>&1 && \
fi
else
echo
echo " (big-endian check skipped: needs powerpc-linux-gnu-gcc + qemu-ppc-static)"
echo " (big-endian check skipped: needs powerpc-linux-gnu-gcc + qemu-ppc-static or qemu-ppc)"
fi

echo
Expand Down
3 changes: 3 additions & 0 deletions tools/scripts/x86_fsp/qemu/qemu_build_fsp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ download_sbl_patch_and_patch_edkii() {
}

build_qemu_fsp() {
# This EDK2 release's host tools are pre-C23 code (old-style function
# declarations), and C23 is the default from GCC 15.
export BUILD_CC="${BUILD_CC:-gcc -std=gnu17}"
(cd "$WORK_DIR/edk2" &&
python ./BuildFsp.py &&
cd BuildFsp &&
Expand Down
Loading