mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 2/2] ARM: sm.c: add the attribute 'volatile' to some asm() statements.
@ 2020-04-07 15:32 Giorgio Dal Molin
  2020-04-14 10:06 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Giorgio Dal Molin @ 2020-04-07 15:32 UTC (permalink / raw)
  To: barebox; +Cc: Giorgio Dal Molin

Prevent the compiler to eventually cache register values read/written
to/from CP15.

Signed-off-by: Giorgio Dal Molin <giorgio.nicole@arcor.de>
---
 arch/arm/cpu/sm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/cpu/sm.c b/arch/arm/cpu/sm.c
index cb33d9625..f5a1edbd4 100644
--- a/arch/arm/cpu/sm.c
+++ b/arch/arm/cpu/sm.c
@@ -26,7 +26,7 @@ static unsigned int read_id_pfr1(void)
 {
 	unsigned int reg;
 
-	asm("mrc p15, 0, %0, c0, c1, 1\n" : "=r"(reg));
+	asm volatile ("mrc p15, 0, %0, c0, c1, 1\n" : "=r"(reg));
 	return reg;
 }
 
@@ -34,18 +34,18 @@ static u32 read_nsacr(void)
 {
 	unsigned int reg;
 
-	asm("mrc p15, 0, %0, c1, c1, 2\n" : "=r"(reg));
+	asm volatile ("mrc p15, 0, %0, c1, c1, 2\n" : "=r"(reg));
 	return reg;
 }
 
 static void write_nsacr(u32 val)
 {
-	asm("mcr p15, 0, %0, c1, c1, 2" : : "r"(val));
+	asm volatile ("mcr p15, 0, %0, c1, c1, 2" : : "r"(val));
 }
 
 static void write_mvbar(u32 val)
 {
-	asm("mcr p15, 0, %0, c12, c0, 1" : : "r"(val));
+	asm volatile ("mcr p15, 0, %0, c12, c0, 1" : : "r"(val));
 }
 
 static int cpu_is_virt_capable(void)
-- 
2.26.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] ARM: sm.c: add the attribute 'volatile' to some asm() statements.
  2020-04-07 15:32 [PATCH 2/2] ARM: sm.c: add the attribute 'volatile' to some asm() statements Giorgio Dal Molin
@ 2020-04-14 10:06 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2020-04-14 10:06 UTC (permalink / raw)
  To: Giorgio Dal Molin; +Cc: barebox

On Tue, Apr 07, 2020 at 05:32:17PM +0200, Giorgio Dal Molin wrote:
> Prevent the compiler to eventually cache register values read/written
> to/from CP15.
> 
> Signed-off-by: Giorgio Dal Molin <giorgio.nicole@arcor.de>
> ---
>  arch/arm/cpu/sm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/arch/arm/cpu/sm.c b/arch/arm/cpu/sm.c
> index cb33d9625..f5a1edbd4 100644
> --- a/arch/arm/cpu/sm.c
> +++ b/arch/arm/cpu/sm.c
> @@ -26,7 +26,7 @@ static unsigned int read_id_pfr1(void)
>  {
>  	unsigned int reg;
>  
> -	asm("mrc p15, 0, %0, c0, c1, 1\n" : "=r"(reg));
> +	asm volatile ("mrc p15, 0, %0, c0, c1, 1\n" : "=r"(reg));
>  	return reg;
>  }
>  
> @@ -34,18 +34,18 @@ static u32 read_nsacr(void)
>  {
>  	unsigned int reg;
>  
> -	asm("mrc p15, 0, %0, c1, c1, 2\n" : "=r"(reg));
> +	asm volatile ("mrc p15, 0, %0, c1, c1, 2\n" : "=r"(reg));
>  	return reg;
>  }
>  
>  static void write_nsacr(u32 val)
>  {
> -	asm("mcr p15, 0, %0, c1, c1, 2" : : "r"(val));
> +	asm volatile ("mcr p15, 0, %0, c1, c1, 2" : : "r"(val));
>  }
>  
>  static void write_mvbar(u32 val)
>  {
> -	asm("mcr p15, 0, %0, c12, c0, 1" : : "r"(val));
> +	asm volatile ("mcr p15, 0, %0, c12, c0, 1" : : "r"(val));
>  }
>  
>  static int cpu_is_virt_capable(void)
> -- 
> 2.26.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-14 10:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 15:32 [PATCH 2/2] ARM: sm.c: add the attribute 'volatile' to some asm() statements Giorgio Dal Molin
2020-04-14 10:06 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox