* [PATCH] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work
@ 2026-04-02 14:01 Sascha Hauer
2026-04-10 11:23 ` Ahmad Fatoum
2026-04-13 7:31 ` Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-04-02 14:01 UTC (permalink / raw)
To: Barebox List; +Cc: Steffen Trumtrar
On ARMv4/5 we have the SCTLR.S and SCTLR.R bits. We set the former which
is deprecated and has implementation defined behaviour on ARMv5. We
clear the latter which has the effect that AP=0b00 as used in PTE_SMALL_AP_UNO_SRO
means "no access".
Clear SCTLR.S and set SCTLR.R instead. With this AP=0b00 maps to
read-only access as intended.
Do not touch any of these bits for >= ARMv6 as both are reserved there.
Fixes: 5916385fae ("ARM: MMU: map text segment ro and data segments execute never")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/lowlevel_32.S | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/arm/cpu/lowlevel_32.S b/arch/arm/cpu/lowlevel_32.S
index 3b1dea5c67..517cefa7b4 100644
--- a/arch/arm/cpu/lowlevel_32.S
+++ b/arch/arm/cpu/lowlevel_32.S
@@ -59,7 +59,7 @@ THUMB( orr r12, r12, #PSR_T_BIT )
/* disable MMU stuff and data/unified caches */
mrc p15, 0, r12, c1, c0, 0 /* SCTLR */
bic r12, r12, #(CR_M | CR_C | CR_B)
- bic r12, r12, #(CR_S | CR_R | CR_V)
+ bic r12, r12, #CR_V
#ifndef CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND
/* enable instruction cache */
@@ -70,7 +70,8 @@ THUMB( orr r12, r12, #PSR_T_BIT )
orr r12, r12, #CR_U
bic r12, r12, #CR_A
#else
- orr r12, r12, #CR_S
+ bic r12, r12, #CR_S
+ orr r12, r12, #CR_R
orr r12, r12, #CR_A
#endif
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work
2026-04-02 14:01 [PATCH] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work Sascha Hauer
@ 2026-04-10 11:23 ` Ahmad Fatoum
2026-04-13 7:31 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2026-04-10 11:23 UTC (permalink / raw)
To: Sascha Hauer, Barebox List; +Cc: Steffen Trumtrar
On 4/2/26 4:01 PM, Sascha Hauer wrote:
> On ARMv4/5 we have the SCTLR.S and SCTLR.R bits. We set the former which
> is deprecated and has implementation defined behaviour on ARMv5. We
> clear the latter which has the effect that AP=0b00 as used in PTE_SMALL_AP_UNO_SRO
> means "no access".
>
> Clear SCTLR.S and set SCTLR.R instead. With this AP=0b00 maps to
> read-only access as intended.
>
> Do not touch any of these bits for >= ARMv6 as both are reserved there.
>
> Fixes: 5916385fae ("ARM: MMU: map text segment ro and data segments execute never")
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> arch/arm/cpu/lowlevel_32.S | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/cpu/lowlevel_32.S b/arch/arm/cpu/lowlevel_32.S
> index 3b1dea5c67..517cefa7b4 100644
> --- a/arch/arm/cpu/lowlevel_32.S
> +++ b/arch/arm/cpu/lowlevel_32.S
> @@ -59,7 +59,7 @@ THUMB( orr r12, r12, #PSR_T_BIT )
> /* disable MMU stuff and data/unified caches */
> mrc p15, 0, r12, c1, c0, 0 /* SCTLR */
> bic r12, r12, #(CR_M | CR_C | CR_B)
> - bic r12, r12, #(CR_S | CR_R | CR_V)
> + bic r12, r12, #CR_V
>
> #ifndef CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND
> /* enable instruction cache */
> @@ -70,7 +70,8 @@ THUMB( orr r12, r12, #PSR_T_BIT )
> orr r12, r12, #CR_U
> bic r12, r12, #CR_A
> #else
> - orr r12, r12, #CR_S
> + bic r12, r12, #CR_S
> + orr r12, r12, #CR_R
> orr r12, r12, #CR_A
> #endif
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work
2026-04-02 14:01 [PATCH] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work Sascha Hauer
2026-04-10 11:23 ` Ahmad Fatoum
@ 2026-04-13 7:31 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2026-04-13 7:31 UTC (permalink / raw)
To: Barebox List, Sascha Hauer; +Cc: Steffen Trumtrar
On Thu, 02 Apr 2026 16:01:29 +0200, Sascha Hauer wrote:
> On ARMv4/5 we have the SCTLR.S and SCTLR.R bits. We set the former which
> is deprecated and has implementation defined behaviour on ARMv5. We
> clear the latter which has the effect that AP=0b00 as used in PTE_SMALL_AP_UNO_SRO
> means "no access".
>
> Clear SCTLR.S and set SCTLR.R instead. With this AP=0b00 maps to
> read-only access as intended.
>
> [...]
Applied, thanks!
[1/1] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work
https://git.pengutronix.de/cgit/barebox/commit/?id=15ccb9d41534 (link may not be stable)
Best regards,
--
Sascha Hauer <s.hauer@pengutronix.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-13 7:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-04-02 14:01 [PATCH] ARM: ARMv5: make PTE_SMALL_AP_UNO_SRO work Sascha Hauer
2026-04-10 11:23 ` Ahmad Fatoum
2026-04-13 7:31 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox