Skip to content

Commit

Permalink
sh: Add unaligned memory access for PC relative intructions
Browse files Browse the repository at this point in the history
This adds unaligned memory access support for the following instructions:
  mov.w @(disp,PC),Rn
  mov.l @(disp,PC),Rn

These instructions are often used on SH2A toolchains.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Phil Edworthy authored and Paul Mundt committed Aug 29, 2011
1 parent 0710b91 commit 34f7145
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions arch/sh/kernel/traps_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,35 @@ static int handle_unaligned_ins(insn_size_t instruction, struct pt_regs *regs,
break;
}
break;

case 9: /* mov.w @(disp,PC),Rn */
srcu = (unsigned char __user *)regs->pc;
srcu += 4;
srcu += (instruction & 0x00FF) << 1;
dst = (unsigned char *)rn;
*(unsigned long *)dst = 0;

#if !defined(__LITTLE_ENDIAN__)
dst += 2;
#endif

if (ma->from(dst, srcu, 2))
goto fetch_fault;
sign_extend(2, dst);
ret = 0;
break;

case 0xd: /* mov.l @(disp,PC),Rn */
srcu = (unsigned char __user *)(regs->pc & ~0x3);
srcu += 4;
srcu += (instruction & 0x00FF) << 2;
dst = (unsigned char *)rn;
*(unsigned long *)dst = 0;

if (ma->from(dst, srcu, 4))
goto fetch_fault;
ret = 0;
break;
}
return ret;

Expand Down Expand Up @@ -496,6 +525,9 @@ int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
}
break;

case 0x9000: /* mov.w @(disp,Rm),Rn */
goto simple;

case 0xA000: /* bra label */
ret = handle_delayslot(regs, instruction, ma);
if (ret==0)
Expand All @@ -509,6 +541,9 @@ int handle_unaligned_access(insn_size_t instruction, struct pt_regs *regs,
regs->pc += SH_PC_12BIT_OFFSET(instruction);
}
break;

case 0xD000: /* mov.l @(disp,Rm),Rn */
goto simple;
}
return ret;

Expand Down

0 comments on commit 34f7145

Please sign in to comment.