Skip to contentSkip to conversation

powerpc: Send SIGBUS on unaligned copy and paste

PATCH Superseded Chris Smart 2 participants 3 messages Jun 9, 2016 – Jun 14, 2016 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 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 <[email protected]> for his help.

---
arch/powerpc/kernel/align.c | 15 +++++++++++++++

1 file changed, 15 insertions(+)
arch/powerpc/kernel/align.c +0 -0
index 8e7cb8e2b21a..fcdf09476eec 100644
@@ -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
	 */
Signature · 1 line
2.7.4
#1 lore raw
Quoted 34 lines · Chris Smart

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 <[email protected]> for his help.

---
arch/powerpc/kernel/align.c | 15 +++++++++++++++

1 file changed, 15 insertions(+)
arch/powerpc/kernel/align.c +3 -0
index 8e7cb8e2b21a..fcdf09476eec 100644
@@ -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

arch/powerpc/kernel/align.c +5 -0
+     * check.
+     *
+     * Send a SIGBUS to the process that caused the fault.
+     *
+     * We do not emulate these because paste may contain additional 

metadata

arch/powerpc/kernel/align.c

Quoted 4 lines
arch/powerpc/kernel/align.c +4 -0
+     * 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

#2 lore raw
Quoted 7 lines · Christophe Leroy
Quoted 5 lines · Chris Smart

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]

Quoted 5 lines
Quoted 1 line

+ 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