Skip to content

Commit

Permalink
MN10300: Don't do misalignment handling for userspace
Browse files Browse the repository at this point in the history
Don't do misalignment handling for userspace misalignment faults: just
generate an appropriate SIGBUS instead.

Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
dhowells authored and torvalds committed Nov 12, 2008
1 parent bd9384a commit 58a4748
Showing 1 changed file with 23 additions and 29 deletions.
52 changes: 23 additions & 29 deletions arch/mn10300/mm/misalignment.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,11 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code)
void *address;
unsigned tmp, npop, dispsz, loop;

/* we don't fix up userspace misalignment faults */
if (user_mode(regs))
sp = regs->sp;
else
sp = (unsigned long) regs + sizeof(*regs);
goto bus_error;

sp = (unsigned long) regs + sizeof(*regs);

kdebug("==>misalignment({pc=%lx,sp=%lx})", regs->pc, sp);

Expand Down Expand Up @@ -386,15 +387,15 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code)
}

/* didn't manage to find a fixup */
if (!user_mode(regs))
printk(KERN_CRIT "MISALIGN: %lx: unsupported instruction %x\n",
regs->pc, opcode);
printk(KERN_CRIT "MISALIGN: %lx: unsupported instruction %x\n",
regs->pc, opcode);

failed:
set_fs(seg);
if (die_if_no_fixup("misalignment error", regs, code))
return;

bus_error:
info.si_signo = SIGBUS;
info.si_errno = 0;
info.si_code = BUS_ADRALN;
Expand All @@ -404,31 +405,27 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code)

/* error reading opcodes */
fetch_error:
if (!user_mode(regs))
printk(KERN_CRIT
"MISALIGN: %p: fault whilst reading instruction data\n",
pc);
printk(KERN_CRIT
"MISALIGN: %p: fault whilst reading instruction data\n",
pc);
goto failed;

bad_addr_mode:
if (!user_mode(regs))
printk(KERN_CRIT
"MISALIGN: %lx: unsupported addressing mode %x\n",
regs->pc, opcode);
printk(KERN_CRIT
"MISALIGN: %lx: unsupported addressing mode %x\n",
regs->pc, opcode);
goto failed;

bad_reg_mode:
if (!user_mode(regs))
printk(KERN_CRIT
"MISALIGN: %lx: unsupported register mode %x\n",
regs->pc, opcode);
printk(KERN_CRIT
"MISALIGN: %lx: unsupported register mode %x\n",
regs->pc, opcode);
goto failed;

unsupported_instruction:
if (!user_mode(regs))
printk(KERN_CRIT
"MISALIGN: %lx: unsupported instruction %x (%s)\n",
regs->pc, opcode, pop->name);
printk(KERN_CRIT
"MISALIGN: %lx: unsupported instruction %x (%s)\n",
regs->pc, opcode, pop->name);
goto failed;

transfer_failed:
Expand Down Expand Up @@ -476,16 +473,14 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code)
kdebug("disp=%lx", disp);

set_fs(KERNEL_XDS);
if (fixup || regs->epsw & EPSW_nSL)
if (fixup)
set_fs(seg);

tmp = (pop->params[0] ^ pop->params[1]) & 0x80000000;
if (!tmp) {
if (!user_mode(regs))
printk(KERN_CRIT
"MISALIGN: %lx:"
" insn not move to/from memory %x\n",
regs->pc, opcode);
printk(KERN_CRIT
"MISALIGN: %lx: insn not move to/from memory %x\n",
regs->pc, opcode);
goto failed;
}

Expand Down Expand Up @@ -548,7 +543,6 @@ asmlinkage void misalignment(struct pt_regs *regs, enum exception_code code)
misalignment_MOV_Lcc(regs, opcode);

set_fs(seg);
return;
}

/*
Expand Down

0 comments on commit 58a4748

Please sign in to comment.