* [PATCH] m68k/coldfire: flush cache when creating the signal stack frame
@ 2013-06-05 11:42 Alexander Stein
2013-07-04 5:54 ` Alexander Stein
2013-07-30 6:41 ` Greg Ungerer
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Stein @ 2013-06-05 11:42 UTC (permalink / raw)
To: Geert Uytterhoeven, Greg Ungerer; +Cc: linux-m68k, Alexander Stein
When the signal stack frame is created, it must be flushed in order to
make sure the cache fetches the correct data.
Without cache flush the icache might pick up old cached data from an older
signal stack frame if the signal is raised again very fast.
In case of copyback the data cache muist be pushed first, but is untested.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
---
arch/m68k/kernel/signal.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
index 2a16df3..57fd286 100644
--- a/arch/m68k/kernel/signal.c
+++ b/arch/m68k/kernel/signal.c
@@ -50,6 +50,7 @@
#include <asm/pgtable.h>
#include <asm/traps.h>
#include <asm/ucontext.h>
+#include <asm/cacheflush.h>
#ifdef CONFIG_MMU
@@ -181,6 +182,13 @@ static inline void push_cache (unsigned long vaddr)
asm volatile ("movec %0,%%caar\n\t"
"movec %1,%%cacr"
: : "r" (vaddr + 4), "r" (temp));
+ } else {
+ /* CPU_IS_COLDFIRE */
+#if defined(CONFIG_CACHE_COPYBACK)
+ flush_cf_dcache(0, DCACHE_MAX_ADDR);
+#endif
+ /* Invalidate instruction cache for the pushed bytes */
+ clear_cf_icache(vaddr, vaddr + 8);
}
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k/coldfire: flush cache when creating the signal stack frame
2013-06-05 11:42 [PATCH] m68k/coldfire: flush cache when creating the signal stack frame Alexander Stein
@ 2013-07-04 5:54 ` Alexander Stein
2013-07-30 6:41 ` Greg Ungerer
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2013-07-04 5:54 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Greg Ungerer, linux-m68k
Any feedback on this?
On Wednesday 05 June 2013 13:42:39, Alexander Stein wrote:
> When the signal stack frame is created, it must be flushed in order to
> make sure the cache fetches the correct data.
> Without cache flush the icache might pick up old cached data from an older
> signal stack frame if the signal is raised again very fast.
> In case of copyback the data cache muist be pushed first, but is untested.
>
> Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
> ---
> arch/m68k/kernel/signal.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
> index 2a16df3..57fd286 100644
> --- a/arch/m68k/kernel/signal.c
> +++ b/arch/m68k/kernel/signal.c
> @@ -50,6 +50,7 @@
> #include <asm/pgtable.h>
> #include <asm/traps.h>
> #include <asm/ucontext.h>
> +#include <asm/cacheflush.h>
>
> #ifdef CONFIG_MMU
>
> @@ -181,6 +182,13 @@ static inline void push_cache (unsigned long vaddr)
> asm volatile ("movec %0,%%caar\n\t"
> "movec %1,%%cacr"
> : : "r" (vaddr + 4), "r" (temp));
> + } else {
> + /* CPU_IS_COLDFIRE */
> +#if defined(CONFIG_CACHE_COPYBACK)
> + flush_cf_dcache(0, DCACHE_MAX_ADDR);
> +#endif
> + /* Invalidate instruction cache for the pushed bytes */
> + clear_cf_icache(vaddr, vaddr + 8);
> }
> }
>
>
--
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
Am Windrad 2
08468 Heinsdorfergrund
Tel.: 03765 38600-1156
Fax: 03765 38600-4100
Email: alexander.stein@systec-electronic.com
Website: www.systec-electronic.com
Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Chemnitz, HRB 28082
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k/coldfire: flush cache when creating the signal stack frame
2013-06-05 11:42 [PATCH] m68k/coldfire: flush cache when creating the signal stack frame Alexander Stein
2013-07-04 5:54 ` Alexander Stein
@ 2013-07-30 6:41 ` Greg Ungerer
2013-07-30 14:12 ` Alexander Stein
1 sibling, 1 reply; 4+ messages in thread
From: Greg Ungerer @ 2013-07-30 6:41 UTC (permalink / raw)
To: Alexander Stein; +Cc: Geert Uytterhoeven, linux-m68k
Hi Alexander,
On 05/06/13 21:42, Alexander Stein wrote:
> When the signal stack frame is created, it must be flushed in order to
> make sure the cache fetches the correct data.
> Without cache flush the icache might pick up old cached data from an older
> signal stack frame if the signal is raised again very fast.
> In case of copyback the data cache muist be pushed first, but is untested.
>
> Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Sorry for the delay.
I haven't been able to actually test it, I can't get the M5475 to
boot in copyback cache mode at the moment. I need to debug it and
figure out why it is broken.
For now I think the best is if I push it into for-next on the
m68knommu git tree.
(Aside it looks like the clear_cf_icache call here is a bit bogus.
It takes cache line number args, not virtual addresses - it works
here because clear_cf_cache invalidates the whole icache... :-(
Regards
Greg
> ---
> arch/m68k/kernel/signal.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c
> index 2a16df3..57fd286 100644
> --- a/arch/m68k/kernel/signal.c
> +++ b/arch/m68k/kernel/signal.c
> @@ -50,6 +50,7 @@
> #include <asm/pgtable.h>
> #include <asm/traps.h>
> #include <asm/ucontext.h>
> +#include <asm/cacheflush.h>
>
> #ifdef CONFIG_MMU
>
> @@ -181,6 +182,13 @@ static inline void push_cache (unsigned long vaddr)
> asm volatile ("movec %0,%%caar\n\t"
> "movec %1,%%cacr"
> : : "r" (vaddr + 4), "r" (temp));
> + } else {
> + /* CPU_IS_COLDFIRE */
> +#if defined(CONFIG_CACHE_COPYBACK)
> + flush_cf_dcache(0, DCACHE_MAX_ADDR);
> +#endif
> + /* Invalidate instruction cache for the pushed bytes */
> + clear_cf_icache(vaddr, vaddr + 8);
> }
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] m68k/coldfire: flush cache when creating the signal stack frame
2013-07-30 6:41 ` Greg Ungerer
@ 2013-07-30 14:12 ` Alexander Stein
0 siblings, 0 replies; 4+ messages in thread
From: Alexander Stein @ 2013-07-30 14:12 UTC (permalink / raw)
To: Greg Ungerer; +Cc: Geert Uytterhoeven, linux-m68k
Hello Greg,
On Tuesday 30 July 2013 16:41:43, Greg Ungerer wrote:
> Hi Alexander,
>
> On 05/06/13 21:42, Alexander Stein wrote:
> > When the signal stack frame is created, it must be flushed in order to
> > make sure the cache fetches the correct data.
> > Without cache flush the icache might pick up old cached data from an older
> > signal stack frame if the signal is raised again very fast.
> > In case of copyback the data cache muist be pushed first, but is untested.
> >
> > Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
>
> Sorry for the delay.
>
> I haven't been able to actually test it, I can't get the M5475 to
> boot in copyback cache mode at the moment. I need to debug it and
> figure out why it is broken.
>
> For now I think the best is if I push it into for-next on the
> m68knommu git tree.
>
> (Aside it looks like the clear_cf_icache call here is a bit bogus.
> It takes cache line number args, not virtual addresses - it works
> here because clear_cf_cache invalidates the whole icache... :-(
Yep, the problem is that IIRC coldfire can only invalidate the whole cache, or single cache lines where I think it is impossible to find out which one to invalidate.
Best regards,
Alexander
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-07-30 14:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-05 11:42 [PATCH] m68k/coldfire: flush cache when creating the signal stack frame Alexander Stein
2013-07-04 5:54 ` Alexander Stein
2013-07-30 6:41 ` Greg Ungerer
2013-07-30 14:12 ` Alexander Stein
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox