Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 58668
b: refs/heads/master
c: 6312e0e
h: refs/heads/master
v: v3
  • Loading branch information
Atsushi Nemoto authored and Ralf Baechle committed Jul 10, 2007
1 parent 87cfa7d commit e39e533
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2db30150fe4fe309c57087c661209c9ea0b5c21b
refs/heads/master: 6312e0ee45236b6882cd26b2ccc167b1b91646fc
16 changes: 16 additions & 0 deletions trunk/arch/mips/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <linux/highmem.h>
#include <linux/console.h>
#include <linux/pfn.h>
#include <linux/debugfs.h>

#include <asm/addrspace.h>
#include <asm/bootinfo.h>
Expand Down Expand Up @@ -574,3 +575,18 @@ __setup("nodsp", dsp_disable);

unsigned long kernelsp[NR_CPUS];
unsigned long fw_arg0, fw_arg1, fw_arg2, fw_arg3;

#ifdef CONFIG_DEBUG_FS
struct dentry *mips_debugfs_dir;
static int __init debugfs_mips(void)
{
struct dentry *d;

d = debugfs_create_dir("mips", NULL);
if (IS_ERR(d))
return PTR_ERR(d);
mips_debugfs_dir = d;
return 0;
}
arch_initcall(debugfs_mips);
#endif
41 changes: 38 additions & 3 deletions trunk/arch/mips/kernel/unaligned.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#include <linux/signal.h>
#include <linux/smp.h>
#include <linux/sched.h>
#include <linux/debugfs.h>
#include <asm/asm.h>
#include <asm/branch.h>
#include <asm/byteorder.h>
Expand All @@ -87,9 +88,18 @@
#define STR(x) __STR(x)
#define __STR(x) #x

#ifdef CONFIG_PROC_FS
unsigned long unaligned_instructions;
enum {
UNALIGNED_ACTION_QUIET,
UNALIGNED_ACTION_SIGNAL,
UNALIGNED_ACTION_SHOW,
};
#ifdef CONFIG_DEBUG_FS
static u32 unaligned_instructions;
static u32 unaligned_action;
#else
#define unaligned_action UNALIGNED_ACTION_QUIET
#endif
extern void show_registers(struct pt_regs *regs);

static inline int emulate_load_store_insn(struct pt_regs *regs,
void __user *addr, unsigned int __user *pc,
Expand Down Expand Up @@ -459,7 +469,7 @@ static inline int emulate_load_store_insn(struct pt_regs *regs,
goto sigill;
}

#ifdef CONFIG_PROC_FS
#ifdef CONFIG_DEBUG_FS
unaligned_instructions++;
#endif

Expand Down Expand Up @@ -516,6 +526,10 @@ asmlinkage void do_ade(struct pt_regs *regs)
pc = (unsigned int __user *) exception_epc(regs);
if (user_mode(regs) && (current->thread.mflags & MF_FIXADE) == 0)
goto sigbus;
if (unaligned_action == UNALIGNED_ACTION_SIGNAL)
goto sigbus;
else if (unaligned_action == UNALIGNED_ACTION_SHOW)
show_registers(regs);

/*
* Do branch emulation only if we didn't forward the exception.
Expand Down Expand Up @@ -546,3 +560,24 @@ asmlinkage void do_ade(struct pt_regs *regs)
* XXX On return from the signal handler we should advance the epc
*/
}

#ifdef CONFIG_DEBUG_FS
extern struct dentry *mips_debugfs_dir;
static int __init debugfs_unaligned(void)
{
struct dentry *d;

if (!mips_debugfs_dir)
return -ENODEV;
d = debugfs_create_u32("unaligned_instructions", S_IRUGO,
mips_debugfs_dir, &unaligned_instructions);
if (IS_ERR(d))
return PTR_ERR(d);
d = debugfs_create_u32("unaligned_action", S_IRUGO | S_IWUSR,
mips_debugfs_dir, &unaligned_action);
if (IS_ERR(d))
return PTR_ERR(d);
return 0;
}
__initcall(debugfs_unaligned);
#endif

0 comments on commit e39e533

Please sign in to comment.