sh: Handle unaligned 16-bit instructions on SH-2A.

This adds some sanity checking in the unaligned instruction handler to
verify the instruction size, which enables basic support for 16-bit
fixups on SH-2A parts.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>

+8 -3
+8 -3
arch/sh/kernel/traps_32.c
··· 452 452 u_int rm; 453 453 int ret, index; 454 454 455 + /* 456 + * XXX: We can't handle mixed 16/32-bit instructions yet 457 + */ 458 + if (instruction_size(instruction) != 2) 459 + return -EINVAL; 460 + 455 461 index = (instruction>>8)&15; /* 0x0F00 */ 456 462 rm = regs->regs[index]; 457 463 ··· 625 619 626 620 se_user += 1; 627 621 628 - #ifndef CONFIG_CPU_SH2A 629 622 set_fs(USER_DS); 630 - if (copy_from_user(&instruction, (u16 *)(regs->pc & ~1), 2)) { 623 + if (copy_from_user(&instruction, (insn_size_t *)(regs->pc & ~1), 624 + sizeof(instruction))) { 631 625 set_fs(oldfs); 632 626 goto uspace_segv; 633 627 } ··· 639 633 "in \"%s\" pid=%d pc=0x%p ins=0x%04hx\n", 640 634 current->comm, current->pid, (void *)regs->pc, 641 635 instruction); 642 - #endif 643 636 644 637 if (se_usermode & 2) 645 638 goto fixup;