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
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ on:
workflow_dispatch:

jobs:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
- name: CI (fmt-check + clippy + test)
run: make ci

build:
name: build-${{ matrix.arch }}
needs: ci
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ sign-bin: docker-build-base
sign-test: docker-build-base
$(DOCKER_RUN) $(DOCKER_SAMEUSER) $(BUILD_IMAGE) cargo test --manifest-path crates/stage0-sign/Cargo.toml --target x86_64-unknown-linux-musl

# ---- CI gate: fmt + clippy + unit tests across all crates (what the branch ruleset requires) ----
# stage0 is not one cargo workspace: 4 independent crates in two target families. The EFI crates
# (ena, stage0, stage0-test-payload) are no_std UEFI and not host-testable -> fmt + clippy on the
# UEFI target; the host signer (stage0-sign) also runs its unit tests (incl. the golden vector).
UEFI_CRATES := ena stage0 stage0-test-payload
HOST_CRATES := stage0-sign
.PHONY: ci fmt-fix
fmt-fix: docker-build-base ## Apply rustfmt across all crates (no --check)
$(DOCKER_RUN) $(DOCKER_SAMEUSER) $(BUILD_IMAGE) bash -c '\
for c in $(UEFI_CRATES) $(HOST_CRATES); do cargo fmt --manifest-path crates/$$c/Cargo.toml; done'
# ena.efi is include_bytes!'d by the stage0 crate, so it must exist before clippy/check can
# compile it (a clean CI checkout has no build/ artifacts; a warm local tree hid this).
ci: docker-build-base build/x86_64/ena.efi
$(DOCKER_RUN) $(DOCKER_SAMEUSER) $(BUILD_IMAGE) bash -c '\
set -e; rustup target add x86_64-unknown-uefi x86_64-unknown-linux-musl; \
for c in $(UEFI_CRATES) $(HOST_CRATES); do \
echo ">> fmt-check $$c"; cargo fmt --manifest-path crates/$$c/Cargo.toml --check; \
done; \
for c in $(UEFI_CRATES); do \
echo ">> clippy $$c (uefi)"; cargo clippy --manifest-path crates/$$c/Cargo.toml --target x86_64-unknown-uefi -- -D warnings; \
done; \
echo ">> clippy stage0-sign (host)"; cargo clippy --manifest-path crates/stage0-sign/Cargo.toml --target x86_64-unknown-linux-musl --all-targets -- -D warnings; \
echo ">> test stage0-sign (host)"; cargo test --manifest-path crates/stage0-sign/Cargo.toml --target x86_64-unknown-linux-musl'

# ---- ed25519 release key for "signed mode" payload admission ----
# Vendor key; stage0 only ever sees the public half, pinned in the metadata doc. Generated by
# stage0-sign keygen (the domain-separated signer the verifier admits against).
Expand Down
21 changes: 17 additions & 4 deletions crates/ena/src/binding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ unsafe extern "efiapi" fn supported(
agent: boot::image_handle(),
controller: None,
};
let pci = match unsafe { boot::open_protocol::<PciIo>(params, boot::OpenProtocolAttributes::GetProtocol) } {
let pci = match unsafe {
boot::open_protocol::<PciIo>(params, boot::OpenProtocolAttributes::GetProtocol)
} {
Ok(p) => p,
Err(_) => return Status::UNSUPPORTED,
};
Expand All @@ -76,14 +78,19 @@ unsafe extern "efiapi" fn start(
agent: boot::image_handle(),
controller: Some(controller),
};
let pci = match unsafe { boot::open_protocol::<PciIo>(params, boot::OpenProtocolAttributes::ByDriver) } {
let pci = match unsafe {
boot::open_protocol::<PciIo>(params, boot::OpenProtocolAttributes::ByDriver)
} {
Ok(p) => p,
Err(e) => {
// ALREADY_STARTED is expected: connect_all_controllers reaches ENA twice (via
// the parent bus and directly), so start() is invoked a second time once we
// already manage the device. That is benign; only log genuine failures.
if e.status() != Status::ALREADY_STARTED {
uefi::println!("ena: start(): open PciIo BY_DRIVER failed: {:?}", e.status());
uefi::println!(
"ena: start(): open PciIo BY_DRIVER failed: {:?}",
e.status()
);
}
return e.status();
}
Expand All @@ -100,7 +107,13 @@ unsafe extern "efiapi" fn start(
let mac = ena.mac();
uefi::println!(
"ena: probe OK mac={:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x} mtu={}",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], ena.mtu
mac[0],
mac[1],
mac[2],
mac[3],
mac[4],
mac[5],
ena.mtu
);
// Keep PciIo open for the device's lifetime (probe stored the raw pointer in `ena`).
core::mem::forget(pci);
Expand Down
Loading