[PATCH 09/14] ARM: i.MX: add imx6_can_access_tzasc()
Marco Felsch
m.felsch at pengutronix.de
Fri Jun 27 09:04:04 PDT 2025
On 25-06-27, Sascha Hauer wrote:
> On ARMv7 there is no direct way to detect if we are in the secure or non
> secure world. Add a imx6_can_access_tzasc() for this purpose. When
> accessing the TZASC triggers a data abort then we are in the non secure
> world. This function can be used later to detect if we have to load
^
because OP-TEE configures the TZASC access policy to secure-world R/W. ?
Keep in mind that this test will fail if a downstream/buggy OP-TEE
doesn't configure the CSU correctly. Fingers crossed that this never
will never happen.
> OP-TEE or not.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
> arch/arm/mach-imx/tzasc.c | 16 ++++++++++++++++
> include/mach/imx/tzasc.h | 1 +
> 2 files changed, 17 insertions(+)
>
> diff --git a/arch/arm/mach-imx/tzasc.c b/arch/arm/mach-imx/tzasc.c
> index ed20ad8803a2e91b67b5d8c3ab1a4265c4228ec7..63f01cbaa6d4a8fbf47b9683ca840ee64f908cfc 100644
> --- a/arch/arm/mach-imx/tzasc.c
> +++ b/arch/arm/mach-imx/tzasc.c
> @@ -13,6 +13,8 @@
> #include <linux/sizes.h>
> #include <mach/imx/imx8m-regs.h>
> #include <io.h>
> +#include <abort.h>
> +#include <asm/barebox-arm.h>
>
> /*******************************************************************************
> * TZC380 defines
> @@ -329,6 +331,20 @@ bool imx6ul_tzc380_is_bypassed(void)
> return !(readl(&gpr[9]) & MX6_GPR_TZASC1_EN);
> }
>
> +bool imx6_can_access_tzasc(void)
> +{
> + if (!IS_ENABLED(CONFIG_ARM_EXCEPTIONS_PBL))
> + panic("%s only works with CONFIG_ARM_EXCEPTIONS_PBL\n", __func__);
> +
> + arm_pbl_init_exceptions();
Can't we do that within the imx*_cpu_lowlevel_init?
Regards,
Marco
> +
> + data_abort_mask();
> +
> + readl(IOMEM(MX6_TZASC1_BASE));
> +
> + return !data_abort_unmask();
> +}
> +
> void imx8m_tzc380_init(void)
> {
> u32 __iomem *gpr = IOMEM(MX8M_IOMUXC_GPR_BASE_ADDR);
> diff --git a/include/mach/imx/tzasc.h b/include/mach/imx/tzasc.h
> index 0fbcdc2150e63864366a8dddeed2d1b97685903d..ca85704a8f459ab6e0cdc975940d855929f3d6f7 100644
> --- a/include/mach/imx/tzasc.h
> +++ b/include/mach/imx/tzasc.h
> @@ -10,6 +10,7 @@ void imx6q_tzc380_early_ns_region1(void);
> void imx6ul_tzc380_early_ns_region1(void);
> bool imx6q_tzc380_is_bypassed(void);
> bool imx6ul_tzc380_is_bypassed(void);
> +bool imx6_can_access_tzasc(void);
> void imx8m_tzc380_init(void);
> bool imx8m_tzc380_is_enabled(void);
>
>
> --
> 2.39.5
>
>
>
More information about the barebox
mailing list