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

secure_storage: fix Kconfig dependencies #86181

Merged

Conversation

JordanYates
Copy link
Collaborator

@JordanYates JordanYates commented Feb 22, 2025

SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS does not use either the FLASH_MAP or NVS APIs, only SETTINGS. Similarly, SECURE_STORAGE_ITS_STORE_MODULE does not consist of any code itself and therefore should not select or imply any options.

Mixing select and depends on is a common source of Kconfig dependency loops and should be avoided. Both ZMS and SETTINGS are more commonly used with depends on rather than select.

The usage here also contradicts the Zephyr best practices guide for select:

  • Avoid selecting symbols with prompts or dependencies. Prefer depends on.

Fixes #86328

@JordanYates JordanYates changed the title 250222 secure storage deps secure_storage: fix Kconfig dependencies Feb 22, 2025
@JordanYates JordanYates added this to the v4.1.0 milestone Feb 22, 2025
@zephyrbot zephyrbot added the area: Secure Storage Secure Storage label Feb 22, 2025
@zephyrbot zephyrbot requested a review from tomi-font February 22, 2025 11:57
rruuaanng
rruuaanng previously approved these changes Feb 22, 2025
Copy link
Collaborator

@rruuaanng rruuaanng left a comment

Choose a reason for hiding this comment

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

Looks good.

@JordanYates
Copy link
Collaborator Author

Removed additional imply on SECURE_STORAGE_ITS_STORE_MODULE

Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

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

Thanks for the fixes.

You will need to adjust the configurations under samples/psa/ and tests/subsys/secure_storage/ to enable those Kconfig options where needed.
Because now with your PR all the tests get skipped because of the filters as some conditions are missing:

zephyr$ twister -p native_sim -T ./samples/psa
[...]
INFO    - 1/6 native_sim/native         samples/psa/its/sample.psa.its.secure_storage.entropy_driver FILTERED (runtime filter)
INFO    - 2/6 native_sim/native         samples/psa/persistent_key/sample.psa.persistent_key.secure_storage.entropy_not_secure FILTERED (runtime filter)
INFO    - 3/6 native_sim/native         samples/psa/persistent_key/sample.psa.persistent_key.secure_storage.entropy_driver FILTERED (runtime filter)
INFO    - 4/6 native_sim/native         samples/psa/its/sample.psa.its.tfm                 FILTERED (runtime filter)
INFO    - 5/6 native_sim/native         samples/psa/persistent_key/sample.psa.persistent_key.tfm FILTERED (runtime filter)
INFO    - 6/6 native_sim/native         samples/psa/its/sample.psa.its.secure_storage.entropy_not_secure FILTERED (runtime filter)

@zephyrbot zephyrbot added the area: Samples Samples label Feb 24, 2025
@zephyrbot zephyrbot requested review from kartben and nashif February 24, 2025 10:21
@JordanYates JordanYates force-pushed the 250222_secure_storage_deps branch from 717aa45 to fc39f58 Compare February 24, 2025 10:44
Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

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

This change would also deserve a migration guide entry.

`FLASH_PAGE_LAYOUT` has a hardware dependency on `FLASH_HAS_PAGE_LAYOUT`
which is not present for all boards. Forcing this symbol to `y` when
the hardware doesn't support it results in build errors at the Kconfig
stage.

`FLASH_PAGE_LAYOUT` is enabled by default when `FLASH_HAS_PAGE_LAYOUT`
is true, so this change will not require any user changes.

Signed-off-by: Jordan Yates <[email protected]>
`SECURE_STORAGE_ITS_STORE_IMPLEMENTATION_SETTINGS` does not use either
the `FLASH_MAP` or `NVS` APIs, only `SETTINGS`.

Similarly, `SECURE_STORAGE_ITS_STORE_MODULE` does not consist of any
code itself and therefore should not select or imply any options.

Signed-off-by: Jordan Yates <[email protected]>
@JordanYates JordanYates force-pushed the 250222_secure_storage_deps branch from fc39f58 to 967818f Compare February 26, 2025 00:02
@JordanYates JordanYates force-pushed the 250222_secure_storage_deps branch from 967818f to 0979108 Compare February 26, 2025 00:07
@zephyrbot zephyrbot added the Release Notes To be mentioned in the release notes label Feb 26, 2025
@JordanYates
Copy link
Collaborator Author

The FLASH commit is required for CI to work, and is a dedicated PR in #86327

@tomi-font tomi-font added the bug The issue is a bug, or the PR is fixing a bug label Feb 26, 2025
Copy link
Collaborator

@tomi-font tomi-font left a comment

Choose a reason for hiding this comment

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

Just a few nits left.

@JordanYates JordanYates force-pushed the 250222_secure_storage_deps branch from 0979108 to 9fb07c5 Compare February 26, 2025 08:43
Mixing `select` and `depends on` is a common source of Kconfig
dependency loops and should be avoided. Both `ZMS` and `SETTINGS` are
more commonly used with `depends on` rather than `select`.

The usage here also contradicts the Zephyr best practices guide for
`select`:
 * Avoid selecting symbols with prompts or dependencies.
   Prefer depends on.

Signed-off-by: Jordan Yates <[email protected]>
Now that `SECURE_STORAGE` does not `select` dependencies, they need to
be enabled explicitly by the tests.

Signed-off-by: Jordan Yates <[email protected]>
@JordanYates JordanYates force-pushed the 250222_secure_storage_deps branch from 9fb07c5 to 863e191 Compare February 27, 2025 00:30
@fabiobaltieri fabiobaltieri merged commit c0ef487 into zephyrproject-rtos:main Feb 27, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: File System area: Samples Samples area: Secure Storage Secure Storage bug The issue is a bug, or the PR is fixing a bug Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Secure Storage: incorrect usage of select/imply
6 participants