Skip to content

[rom_ext] Boot services refactor and unit tests #27453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jun 25, 2025

Conversation

ShadowBearVR
Copy link

These changes refactor the handle_boot_svc method and several related methods out of rom_ext.c into separate libraries - rom_ext_boot_services.c and rom_ext_verify.c. This enables standalone unit tests to be written for boot services (and shortly, fuzzing for boot services).

Unit tests were added for each action handled in handle_boot_svc. Mocks and conditional compilation were added where necessary to support on-host tests for rom_ext.

@ShadowBearVR ShadowBearVR marked this pull request as ready for review June 17, 2025 14:00
@ShadowBearVR ShadowBearVR requested a review from a team as a code owner June 17, 2025 14:00
@ShadowBearVR ShadowBearVR requested review from pamaury and removed request for a team June 17, 2025 14:00
@ShadowBearVR ShadowBearVR force-pushed the rom_ext_refactor branch 2 times, most recently from 0f7fa3d to 5d5a639 Compare June 23, 2025 16:30
Copy link
Contributor

@timothytrippel timothytrippel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped a couple comments. In general mostly LGTM. Thanks for this first submission!

One other improvement that would be useful: could you please add/expand commit messages? Each commit just has a title but no detailed description. See here https://opentitan.org/book/doc/contributing/detailed_contribution_guide/index.html?highlight=commit%20messages#what-should-commit-messages-look-like for some guidelines, and also it can be useful to take a look at other commit messages in the repo already.

ShadowBearVR and others added 8 commits June 24, 2025 11:30
In preparation for fuzzing efforts, all boot services related
code in rom_ext has been refactored into a seperate library.
This will allow unit tests, and fuzz tests, to run this code
directly on the host by removing device dependencies. The
majority of code changes in this commit are due to moving code
from one file to another.

Signed-off-by: Collin MacDonald <cmacd@google.com>
This change converts the owner_verify library into a dual library, with
support for running both on device and host targets. Additionally, this
change adds the required mocks to allow hosts to run owner_verify.

Signed-off-by: Collin MacDonald <cmacd@google.com>
This change expands the existing Manifest mock to include support
for three additional methods: manifest_ext_get_spx_key,
manifest_ext_get_spx_signature, and manifest_ext_get_isfb. Future
unit tests will use each of these methods.

Signed-off-by: Collin MacDonald <cmacd@google.com>
When running on a host target, the rescue type is undefined, as it
is currently only defined on a per device basis. This change adds
a NULL rescue type to be used by future unit tests.

Signed-off-by: Collin MacDonald <cmacd@google.com>
This change adds conditional compilation flags to dbg_print related
functions to better support on host unit tests. Additionally, to support
existing dbg_print unit tests, a unit test specific flag was added.

Signed-off-by: Collin MacDonald <cmacd@google.com>
This change adds 7 initial tests for boot services with basic
parameters for each. These tests serve as a starting point for
more complex unit tests and fuzzing tests related to boot
services.

Signed-off-by: Collin MacDonald <cmacd@google.com>
This change fills out the BootSvcEnterRescue,
BootSvcOwnershipUnlock, and BootSvcOwnershipActivate unit tests
with the required inputs to pass.

Signed-off-by: Ellis Sarza-Nguyen <sarzanguyen@google.com>
Adds additional equality checks, formats all unit tests, and ensures
similar checks are present in all 7 boot service handler related unit
tests.

Signed-off-by: Collin MacDonald <cmacd@google.com>
@timothytrippel timothytrippel self-requested a review June 25, 2025 06:43
@timothytrippel timothytrippel merged commit 36e8bf1 into lowRISC:earlgrey_1.0.0 Jun 25, 2025
33 checks passed
@ShadowBearVR ShadowBearVR deleted the rom_ext_refactor branch June 25, 2025 18:02
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.

4 participants