arm64: debug: make aarch32 bkpt checking endian clean
The current breakpoint instruction checking code for A32 is not endian clean. Fix this with appropriate byte-swapping when retrieving instructions. Signed-off-by: Matthew Leach <matthew.leach@arm.com> Reviewed-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
This commit is contained in:
parent
6a2e5e521c
commit
2dacab73dc
|
@ -248,7 +248,8 @@ static int brk_handler(unsigned long addr, unsigned int esr,
|
||||||
int aarch32_break_handler(struct pt_regs *regs)
|
int aarch32_break_handler(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
siginfo_t info;
|
siginfo_t info;
|
||||||
unsigned int instr;
|
u32 arm_instr;
|
||||||
|
u16 thumb_instr;
|
||||||
bool bp = false;
|
bool bp = false;
|
||||||
void __user *pc = (void __user *)instruction_pointer(regs);
|
void __user *pc = (void __user *)instruction_pointer(regs);
|
||||||
|
|
||||||
|
@ -257,18 +258,21 @@ int aarch32_break_handler(struct pt_regs *regs)
|
||||||
|
|
||||||
if (compat_thumb_mode(regs)) {
|
if (compat_thumb_mode(regs)) {
|
||||||
/* get 16-bit Thumb instruction */
|
/* get 16-bit Thumb instruction */
|
||||||
get_user(instr, (u16 __user *)pc);
|
get_user(thumb_instr, (u16 __user *)pc);
|
||||||
if (instr == AARCH32_BREAK_THUMB2_LO) {
|
thumb_instr = le16_to_cpu(thumb_instr);
|
||||||
|
if (thumb_instr == AARCH32_BREAK_THUMB2_LO) {
|
||||||
/* get second half of 32-bit Thumb-2 instruction */
|
/* get second half of 32-bit Thumb-2 instruction */
|
||||||
get_user(instr, (u16 __user *)(pc + 2));
|
get_user(thumb_instr, (u16 __user *)(pc + 2));
|
||||||
bp = instr == AARCH32_BREAK_THUMB2_HI;
|
thumb_instr = le16_to_cpu(thumb_instr);
|
||||||
|
bp = thumb_instr == AARCH32_BREAK_THUMB2_HI;
|
||||||
} else {
|
} else {
|
||||||
bp = instr == AARCH32_BREAK_THUMB;
|
bp = thumb_instr == AARCH32_BREAK_THUMB;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* 32-bit ARM instruction */
|
/* 32-bit ARM instruction */
|
||||||
get_user(instr, (u32 __user *)pc);
|
get_user(arm_instr, (u32 __user *)pc);
|
||||||
bp = (instr & ~0xf0000000) == AARCH32_BREAK_ARM;
|
arm_instr = le32_to_cpu(arm_instr);
|
||||||
|
bp = (arm_instr & ~0xf0000000) == AARCH32_BREAK_ARM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bp)
|
if (!bp)
|
||||||
|
|
Loading…
Reference in a new issue