Skip to content

Conversation

AlexJones0
Copy link
Contributor

@AlexJones0 AlexJones0 commented Oct 17, 2025

Note: this PR requires QEMU opentitantool SPI bootstrapping support which is not yet currently merged (see #28413), and so is not expected to pass. This PR is marked as draft for now, but is otherwise ready for review. When run on top of that PR (with some small tweaks, see my working local branch) all tests pass in QEMU environments.

This PR checks that QEMU Earlgrey emulation can correctly support ROM_EXT ownership boot service flows (with the same limitations as FPGA when unprovisioned, due to the lack of info page splicing). See relevant comments in the ownership/BUILD file - the Xmodem transfer rescue flow has fairly tight timing assumptions based on a 115200 Bps baud rate which may cause tests to fail when run in parallel or on slower hosts. To test, I would recommend running tests in serial (--test_output=streamed or -j 1). See the commit messages for further details.

Also update the different ownership tests (ownership transfer, rescue
limit / permissions, new version and flash permission tests) to provide
an option for configuring this time, as it will need to be increased for
ownership tests to pass in QEMU environments.

This is because (even on a fast host) QEMU generally emulates the ROM
at a slower rate than FPGA/silicon targets due to a `sec_mmio` code hot
loop in the ROM falling in an EPMP region that is not aligned to a 4K
page, which means that QEMU's TCG cannot use its TLB, resulting in a
large performance decrease.

Signed-off-by: Alex Jones <[email protected]>
Adds QEMU execution environment support for the ROM_EXT end-to-end
ownership tests, which test a variety of different ownership transfer
cases via the boot services.

To avoid large amounts of duplicated test definitions between the QEMU
and FPGA tests, extend the existing ownership test implementation to
instead take a dictionary of `shared_params` via which the FPGA and QEMU
params are then constructed. Dictionaries of additional parameters can
then be provided in the regular `fpga` and `qemu` fields which will
override the values in the shared parameters (allowing for per-env
customisation, or the addition of extra parameters).

A special case is added for handling the `test_cmd` to instead
automatically prepend an environment-specific prefix to the test
command to perform environment-specific setup (clear bitstream on FPGA,
increase rescue delay on QEMU). This is only applied if the `qemu/fpga`
parameter does not itself override the test command.

After several relevant fixes to QEMU and its Bazel integration, all 41
of these tests are currently passing in QEMU execution environments
(given a sufficiently fast host and not running in parallel, due to
the tight test timeouts).

Signed-off-by: Alex Jones <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant