summaryrefslogtreecommitdiffstats
path: root/arch/sh/mm
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2010-02-23 12:56:30 +0900
committerPaul Mundt <lethal@linux-sh.org>2010-02-23 12:56:30 +0900
commit94ea5e449ae834af058ef005d16a8ad44fcf13d6 (patch)
tree4152e5cc7cd5535452b2cd074b6ba041abc7c301 /arch/sh/mm
parent7c1b2c6890a1a033dde4f6991c0a1fcd69cf58ce (diff)
downloadop-kernel-dev-94ea5e449ae834af058ef005d16a8ad44fcf13d6.zip
op-kernel-dev-94ea5e449ae834af058ef005d16a8ad44fcf13d6.tar.gz
sh: wire up SET/GET_UNALIGN_CTL.
This hooks up the SET/GET_UNALIGN_CTL knobs cribbing the bulk of it from the PPC and ia64 implementations. The thread flags happen to be the logical inverse of what the global fault mode is set to, so this works out pretty cleanly. By default the global fault mode is used, with tasks now being able to override their own settings via prctl(). Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/mm')
-rw-r--r--arch/sh/mm/alignment.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/arch/sh/mm/alignment.c b/arch/sh/mm/alignment.c
index 00fb9e3..b2595b8 100644
--- a/arch/sh/mm/alignment.c
+++ b/arch/sh/mm/alignment.c
@@ -14,6 +14,7 @@
#include <linux/proc_fs.h>
#include <linux/uaccess.h>
#include <asm/alignment.h>
+#include <asm/processor.h>
static unsigned long se_user;
static unsigned long se_sys;
@@ -59,9 +60,36 @@ void inc_unaligned_kernel_access(void)
se_sys++;
}
+/*
+ * This defaults to the global policy which can be set from the command
+ * line, while processes can overload their preferences via prctl().
+ */
unsigned int unaligned_user_action(void)
{
- return se_usermode;
+ unsigned int action = se_usermode;
+
+ if (current->thread.flags & SH_THREAD_UAC_SIGBUS) {
+ action &= ~UM_FIXUP;
+ action |= UM_SIGNAL;
+ }
+
+ if (current->thread.flags & SH_THREAD_UAC_NOPRINT)
+ action &= ~UM_WARN;
+
+ return action;
+}
+
+int get_unalign_ctl(struct task_struct *tsk, unsigned long addr)
+{
+ return put_user(tsk->thread.flags & SH_THREAD_UAC_MASK,
+ (unsigned int __user *)addr);
+}
+
+int set_unalign_ctl(struct task_struct *tsk, unsigned int val)
+{
+ tsk->thread.flags = (tsk->thread.flags & ~SH_THREAD_UAC_MASK) |
+ (val & SH_THREAD_UAC_MASK);
+ return 0;
}
void unaligned_fixups_notify(struct task_struct *tsk, insn_size_t insn,
OpenPOWER on IntegriCloud