All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] powerpc: Send SIGBUS on unaligned copy and paste
@ 2016-06-09  6:01 Chris Smart
  2016-06-09  6:57 ` Christophe Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Smart @ 2016-06-09  6:01 UTC (permalink / raw)
  To: linuxppc-dev

Calling ISA 3.0 instructions copy, copy_first, paste and paste_last
generates an alignment fault when copying or pasting unaligned
data (128 byte). We catch this and send SIGBUS to the userspace
process that caused it.

We do not emulate these because paste may contain additional metadata
when pasting to a co-processor and paste_last is the synchronisation
point for preceding copy/paste sequences.

Thanks to Michael Neuling <mikey@neuling.org> for his help.

Signed-off-by: Chris Smart <chris@distroguy.com>
---
 arch/powerpc/kernel/align.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
index 8e7cb8e2b21a..fcdf09476eec 100644
--- a/arch/powerpc/kernel/align.c
+++ b/arch/powerpc/kernel/align.c
@@ -875,6 +875,21 @@ int fix_alignment(struct pt_regs *regs)
 		return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize);
 	}
 #endif
+
+	/*
+	 * ISA 3.0 (such as P9) copy, copy_first, paste and paste_last alignment
+	 * check.
+	 *
+	 * Send a SIGBUS to the process that caused the fault.
+	 *
+	 * We do not emulate these because paste may contain additional metadata
+	 * when pasting to a co-processor. Furthermore, paste_last is the
+	 * synchronisation point for preceding copy/paste sequences.
+	 */
+	if ((instruction & 0xfc0006fe) == 0x7c00060c){
+		return -EIO;
+	}
+
 	/* A size of 0 indicates an instruction we don't support, with
 	 * the exception of DCBZ which is handled as a special case here
 	 */
-- 
2.7.4

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

* Re: [PATCH 1/2] powerpc: Send SIGBUS on unaligned copy and paste
  2016-06-09  6:01 [PATCH 1/2] powerpc: Send SIGBUS on unaligned copy and paste Chris Smart
@ 2016-06-09  6:57 ` Christophe Leroy
  2016-06-14  1:50   ` Chris Smart
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe Leroy @ 2016-06-09  6:57 UTC (permalink / raw)
  To: Chris Smart, linuxppc-dev


Le 09/06/2016 à 08:01, Chris Smart a écrit :
> Calling ISA 3.0 instructions copy, copy_first, paste and paste_last
> generates an alignment fault when copying or pasting unaligned
> data (128 byte). We catch this and send SIGBUS to the userspace
> process that caused it.
>
> We do not emulate these because paste may contain additional metadata
> when pasting to a co-processor and paste_last is the synchronisation
> point for preceding copy/paste sequences.
>
> Thanks to Michael Neuling <mikey@neuling.org> for his help.
>
> Signed-off-by: Chris Smart <chris@distroguy.com>
> ---
> arch/powerpc/kernel/align.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c
> index 8e7cb8e2b21a..fcdf09476eec 100644
> --- a/arch/powerpc/kernel/align.c
> +++ b/arch/powerpc/kernel/align.c
> @@ -875,6 +875,21 @@ int fix_alignment(struct pt_regs *regs)
>         return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize);
>     }
> #endif
> +
> +    /*
> +     * ISA 3.0 (such as P9) copy, copy_first, paste and paste_last 
> alignment
> +     * check.
> +     *
> +     * Send a SIGBUS to the process that caused the fault.
> +     *
> +     * We do not emulate these because paste may contain additional 
> metadata
> +     * when pasting to a co-processor. Furthermore, paste_last is the
> +     * synchronisation point for preceding copy/paste sequences.
> +     */
> +    if ((instruction & 0xfc0006fe) == 0x7c00060c){

Can you define corresponding instruction and mask in 
arch/powerpc/include/asm/ppc-opcode.h
and use symbolic names here instead of raw values ?

Christophe

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

* Re: [PATCH 1/2] powerpc: Send SIGBUS on unaligned copy and paste
  2016-06-09  6:57 ` Christophe Leroy
@ 2016-06-14  1:50   ` Chris Smart
  0 siblings, 0 replies; 3+ messages in thread
From: Chris Smart @ 2016-06-14  1:50 UTC (permalink / raw)
  To: linuxppc-dev

On Thu, Jun 09, 2016 at 08:57:50AM +0200, Christophe Leroy wrote:
>
>Le 09/06/2016 à 08:01, Chris Smart a écrit :
>>Calling ISA 3.0 instructions copy, copy_first, paste and paste_last
>>generates an alignment fault when copying or pasting unaligned
>>data (128 byte). We catch this and send SIGBUS to the userspace
>>process that caused it.
>>

[snip]

>>+    if ((instruction & 0xfc0006fe) == 0x7c00060c){
>
>Can you define corresponding instruction and mask in 
>arch/powerpc/include/asm/ppc-opcode.h
>and use symbolic names here instead of raw values ?
>

Yep, thanks. Will look at doing this for V2.

Cheers,
-c

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

end of thread, other threads:[~2016-06-14  1:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09  6:01 [PATCH 1/2] powerpc: Send SIGBUS on unaligned copy and paste Chris Smart
2016-06-09  6:57 ` Christophe Leroy
2016-06-14  1:50   ` Chris Smart

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.