Skip to content

Commit

Permalink
sh: Make is_valid_bugaddr() more intelligent on nommu.
Browse files Browse the repository at this point in the history
Currently is_valid_bugaddr() is true for anything >= PAGE_OFFSET, which
happens to be 0 on nommu configurations. Make this a bit smarter by just
reading in the opcode and comparing it against the trap type that we
already know. Follows the logic from avr32.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Paul Mundt committed May 19, 2008
1 parent bfd3c7a commit 9a33fc2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion arch/sh/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/kdebug.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/uaccess.h>
#include <asm/system.h>

#ifdef CONFIG_BUG
Expand All @@ -21,7 +22,14 @@ static void handle_BUG(struct pt_regs *regs)

int is_valid_bugaddr(unsigned long addr)
{
return addr >= PAGE_OFFSET;
unsigned short opcode;

if (addr < PAGE_OFFSET)
return 0;
if (probe_kernel_address((u16 *)addr, opcode))
return 0;

return opcode == TRAPA_BUG_OPCODE;
}
#endif

Expand Down

0 comments on commit 9a33fc2

Please sign in to comment.