-
Notifications
You must be signed in to change notification settings - Fork 7.3k
soc: nxp: mcxn: configure CPU1 TrustZone access level #88975
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
base: main
Are you sure you want to change the base?
Conversation
This reverts commit feb966d. That change makes GPIO registers inaccessible from cpu0. Signed-off-by: Derek Snell <[email protected]>
Configures AHBSC MASTER_SEC_LEVEL register for the cpu1 before cpu1 is enabled. By default, this gives CPU1 secure and privileged access to the rest of the SOC, same as CPU0. Signed-off-by: Derek Snell <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested and confirmed it fixes the regression. Thanks!
/* Configure CPU1 TrustZone access level before CPU1 is enabled */ | ||
AHBSC->MASTER_SEC_LEVEL |= | ||
AHBSC_MASTER_SEC_LEVEL_CPU1(CONFIG_SECOND_CORE_MCUX_ACCESS_LEVEL); | ||
AHBSC->MASTER_SEC_ANTI_POL_REG = (~AHBSC->MASTER_SEC_LEVEL & 0x3FFFFFF3U) | 0x80000000U; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bits 3-2 (CPU1 field) are cleared by the mask & 0x3FFFFFF3U
, which doesn't seem to be the intended behavior.
If COP1 in MASTER_SEC_LEVEL
is set to 1 or 2 (Non-secure and privileged Master, respectively Secure and non-privileged Master), MASTER_SEC_ANTI_POL_REG
will not have the inverse polarity of MASTER_SEC_LEVEL
as specified.
IMHO, the mask should be set to 0x3FFFFFFFU
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't macros be used instead of hard-coded values?
Concretely:
AHBSC->MASTER_SEC_ANTI_POL_REG = (~AHBSC->MASTER_SEC_LEVEL & ~AHBSC_MASTER_SEC_ANTI_POL_REG_MASTER_SEC_LEVEL_ANTIPOL_LOCK_MASK) | AHBSC_MASTER_SEC_ANTI_POL_REG_MASTER_SEC_LEVEL_ANTIPOL_LOCK(2);
Configures AHBSC MASTER_SEC_LEVEL register for the cpu1 before cpu1 is enabled. By default, this gives CPU1 secure and privileged access to the rest of the SOC, same as CPU0.
This also reverts feb966d. Configuring the GPIO access permissions is no longer required for CPU1 to access the GPIO.
Resolves #88965 .
Tested using the blinky sample running on CPU1 using the following commands:
GPIO also accessible from CPU0, tested with sample blinky and button.