lkml.org 
[lkml]   [2017]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 09/16] ARM: Check condition code before trying to handle an UNDEF
Date
As indicated in the ARMv7 ARM in B1.9.2, an instruction that
would cause an UNDEF can trap even if it fails its condition
code. Yes, this is annoying.

Add a arm_check_condition call before trying to handle an
UNDEF, and move the PC by the right amount if the condition
check fails.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
arch/arm/kernel/traps.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index 948c648fea00..ca51e80a60b6 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -462,6 +462,19 @@ asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
instr = __mem_to_opcode_arm(instr);
}

+ /*
+ * An UNDEF is allowed to trap even when failing its condition
+ * code (see B1.9.2 in the ARMv7 ARM).
+ */
+ if (arm_check_condition(instr, regs->ARM_cpsr) == ARM_OPCODE_CONDTEST_FAIL) {
+ if (thumb_mode(regs) && !is_wide_instruction(instr))
+ regs->ARM_pc += 2;
+ else
+ regs->ARM_pc +=4;
+
+ return;
+ }
+
if (call_undef_hook(regs, instr) == 0)
return;

--
2.11.0
\
 
 \ /
  Last update: 2017-07-21 19:18    [W:0.512 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site