[PATCH v3 2/2] powerpc32: fix check_io_access()

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE3693d

2 messages, 2 authors, 2016-07-09 · open the first message on its own page

[PATCH v3 2/2] powerpc32: fix check_io_access()

From: Christophe Leroy <hidden>
Date: 2016-05-17 12:01:47

On processors like the 8xx, the machine check exception can also
happen directly on the load/store instruction itself, so that case
needs to be handled as well

Signed-off-by: Christophe Leroy <redacted>
---
 arch/powerpc/include/asm/ppc-opcode.h |  1 +
 arch/powerpc/kernel/traps.c           | 13 +++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h
index 37e7b9d..5e613b8 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -84,6 +84,7 @@
 /* opcode and xopcode for instructions */
 #define OP_TRAP 3
 #define OP_TRAP_64 2
+#define OP_31		31
 
 #define OP_31_XOP_TRAP      4
 #define OP_31_XOP_LWZX      23
diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index 255f5cc..27f1a36 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -334,6 +334,7 @@ static inline int check_io_access(struct pt_regs *regs)
 
 	if (((msr & 0xffff0000) == 0 || (msr & (0x80000 | 0x40000)))
 	    && (entry = search_exception_tables(regs->nip)) != NULL) {
+		int op, xop;
 		/*
 		 * Check that it's a sync instruction, or somewhere
 		 * in the twi; isync; nop sequence that inb/inw/inl uses.
@@ -346,10 +347,18 @@ static inline int check_io_access(struct pt_regs *regs)
 			nip -= 2;
 		else if (*nip == PPC_INST_ISYNC)
 			--nip;
-		if (*nip == PPC_INST_SYNC || (*nip >> 26) == OP_TRAP) {
+		if (*nip == PPC_INST_SYNC || (*nip >> 26) == OP_TRAP)
+			--nip;
+		op = *nip >> 26;
+		xop = (*nip >> 1) & 0x3ff;
+		if (op == OP_LWZ || op == OP_LBZ || op == OP_STW ||
+		    op == OP_STB || op == OP_LHZ || op == OP_STH ||
+		    (op == OP_31 &&
+		     (xop == OP_31_XOP_LBZX || xop == OP_31_XOP_LHBRX ||
+		      xop == OP_31_XOP_LWBRX || xop == OP_31_XOP_STBX ||
+		      xop == OP_31_XOP_STHBRX || xop == OP_31_XOP_STWBRX))) {
 			unsigned int rb;
 
-			--nip;
 			rb = (*nip >> 11) & 0x1f;
 			printk(KERN_DEBUG "%s bad port %lx at %p\n",
 			       (*nip & 0x100)? "OUT to": "IN from",
-- 
2.1.0

Re: [PATCH v3 2/2] powerpc32: fix check_io_access()

From: Scott Wood <oss@buserror.net>
Date: 2016-07-09 07:13:24

On Tue, 2016-05-17 at 14:01 +0200, Christophe Leroy wrote:
On processors like the 8xx, the machine check exception can also
happen directly on the load/store instruction itself, so that case
needs to be handled as well

Signed-off-by: Christophe Leroy <redacted>
---
What machine checks are happening that this is handling?  Is there still 8xx
code that probes for registers that might not be there?

-Scott
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help