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

Open
wants to merge 1 commit into
base: earlgrey_1.0.0
Choose a base branch
from

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
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 d34904e to 0c2d6ba Compare January 31, 2025 21:43
}
}
return kErrorOk;
}

rom_error_t owner_block_flash_apply(const owner_flash_config_t *flash,
uint32_t config_side,
uint32_t owner_lockdown) {
uint32_t owner_lockdown,
uint32_t *mp_index) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a check to ensure that mp_index isn't null?

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.

2 participants