Skip to content
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

[rom_ext, ownership] Fix the flash region configuration #26077

Merged
merged 1 commit into from
Feb 4, 2025

Conversation

cfrantz
Copy link
Contributor

@cfrantz cfrantz commented Jan 30, 2025

I did not write correct test cases that would check a flash configuration similar to the owner config already deployed in some skus. This oversight could cause ownership initialization to fail on devies with such a configuration.

  1. Permit a maximum of 3 regions per side in the flash configuration. The regions must be fully within the bounds of SlotA or SlotB and may not overlap the ROM_EXT region.
  2. Apply the region configuration in order. Previously, there was a correspondence between the index of the region in the owner config and the MP_REGION register that it would land in, but this makes ownership transfers prone to configuration clashes.
  3. Flash configuration is done in two passes to configure each side independently (the reason for this is to allow next_owner's flash config to apply to the non-primary side during ownership transfer). The flash_apply function maintains internal state to fill the MP_REGION registers in order. Provide a first_pass parameter to the flash_apply function to allow managing the internal state.
  4. Create a unittest case with a flash configuration similar to the already-deployed configuration. Include the ROM_EXT, application, filesystem and reserved segments.
  5. Update the existing test cases to accomodate the new configuration scheme (e.g. applying in order rather than by index).

Fixes #25435.

@cfrantz cfrantz requested review from moidx and jettr January 30, 2025 21:58
@cfrantz cfrantz requested review from a team as code owners January 30, 2025 21:58
@cfrantz cfrantz requested review from timothytrippel and removed request for a team January 30, 2025 21:58
@cfrantz cfrantz force-pushed the a1-rom_ext-protect branch from dfef607 to d34904e Compare January 30, 2025 22:19
@cfrantz cfrantz removed the request for review from a team January 31, 2025 15:59
@cfrantz cfrantz force-pushed the a1-rom_ext-protect branch from d34904e to 0c2d6ba Compare January 31, 2025 21:43
lock = kHardenedBoolFalse;
}

if (*mp_index < 2 * FLASH_CONFIG_REGIONS_PER_SLOT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the MP layout you have in mind? It would be good to capture it in an md doc so that we can provide it as a reference. I am seeing some questions from integration teams.

MP Slot Description
0 ROM_EXT slot A
1 ROM_EXT slot B
2 Owner Slot A - Entry 0
3 Owner Slot A - Entry 1
4 Owner Slot A - Entry 2
5 Owner Slot B - Entry 0
6 Owner Slot B - Entry 1
7 Owner Slot B - Entry 2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct: in the LockedOwner state, SlotA entries are programmed into MP_REGION registers first, then SlotB entries.

In the unlocked states (UnlockedAny, UnlockedEndorsed), current_owner's entries are programmed first (for whichever side is primary), then next_owner's entries are programmed (for whichever side is secondary). This ordering was chosen to keep current_owner's firmware booting in the primary slot and to allow next_owner to program their image into the secondary slot and then attempt a boot with a SetBl0Next command.

I did not write correct test cases that would check a flash
configuration similar to the owner config already deployed in some skus.
This oversight could cause ownership initialization to fail on devies
with such a configuration.

1. Permit a maximum of 3 regions per side in the flash configuration.
   The regions must be fully within the bounds of SlotA or SlotB and
   may not overlap the ROM_EXT region.
2. Apply the region configuration in order.  Previously, there was a
   correspondence between the index of the region in the owner config
   and the MP_REGION register that it would land in, but this makes
   ownership transfers prone to configuration clashes.
3. Flash configuration is done in two passes to configure each side
   independently (the reason for this is to allow next_owner's flash
   config to apply to the non-primary side during ownership transfer).
   The flash_apply function now takex an index parameter to manage
   the desination MP_REGION register between passes.
4. Create a unittest case with a flash configuration similar to the
   already-deployed configuration. Include the ROM_EXT, application,
   filesystem and reserved segments.
5. Update the existing test cases to accomodate the new configuration
   scheme (e.g. applying in order rather than by index).

Signed-off-by: Chris Frantz <[email protected]>
@cfrantz cfrantz force-pushed the a1-rom_ext-protect branch from 0c2d6ba to 9be96dc Compare February 3, 2025 22:54
@cfrantz cfrantz merged commit 5594458 into lowRISC:earlgrey_1.0.0 Feb 4, 2025
32 checks passed
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.

3 participants