Commit ae26b36f authored by Chris Smart's avatar Chris Smart Committed by Michael Ellerman

powerpc: Send SIGBUS on unaligned copy and paste

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: default avatarChris Smart <chris@distroguy.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 0c63e8b7
...@@ -131,6 +131,8 @@ ...@@ -131,6 +131,8 @@
/* sorted alphabetically */ /* sorted alphabetically */
#define PPC_INST_BHRBE 0x7c00025c #define PPC_INST_BHRBE 0x7c00025c
#define PPC_INST_CLRBHRB 0x7c00035c #define PPC_INST_CLRBHRB 0x7c00035c
#define PPC_INST_COPY 0x7c00060c
#define PPC_INST_COPY_FIRST 0x7c20060c
#define PPC_INST_CP_ABORT 0x7c00068c #define PPC_INST_CP_ABORT 0x7c00068c
#define PPC_INST_DCBA 0x7c0005ec #define PPC_INST_DCBA 0x7c0005ec
#define PPC_INST_DCBA_MASK 0xfc0007fe #define PPC_INST_DCBA_MASK 0xfc0007fe
...@@ -161,6 +163,8 @@ ...@@ -161,6 +163,8 @@
#define PPC_INST_MSGSNDP 0x7c00011c #define PPC_INST_MSGSNDP 0x7c00011c
#define PPC_INST_MTTMR 0x7c0003dc #define PPC_INST_MTTMR 0x7c0003dc
#define PPC_INST_NOP 0x60000000 #define PPC_INST_NOP 0x60000000
#define PPC_INST_PASTE 0x7c00070c
#define PPC_INST_PASTE_LAST 0x7c20070d
#define PPC_INST_POPCNTB 0x7c0000f4 #define PPC_INST_POPCNTB 0x7c0000f4
#define PPC_INST_POPCNTB_MASK 0xfc0007fe #define PPC_INST_POPCNTB_MASK 0xfc0007fe
#define PPC_INST_POPCNTD 0x7c0003f4 #define PPC_INST_POPCNTD 0x7c0003f4
......
...@@ -873,6 +873,20 @@ int fix_alignment(struct pt_regs *regs) ...@@ -873,6 +873,20 @@ int fix_alignment(struct pt_regs *regs)
return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize); return emulate_vsx(addr, reg, areg, regs, flags, nb, elsize);
} }
#endif #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) == PPC_INST_COPY)
return -EIO;
/* A size of 0 indicates an instruction we don't support, with /* A size of 0 indicates an instruction we don't support, with
* the exception of DCBZ which is handled as a special case here * the exception of DCBZ which is handled as a special case here
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment