tags 349765 patch
thanks

On Sat, Jan 28, 2006 at 01:48:21AM -0500, Kyle McMartin wrote:
> > After changing addr to value, compiles fine; prctl -q runs ok now, prctl
> > --unaligned=signal doesn't have any effect.  You say that it's going to be
> > the prctl() function in the kernel that needs further tweaks?

> I suspect this is the problem:

> (linux/prctl.h)
> # define PR_UNALIGN_NOPRINT   1       /* silently fix up unaligned user 
> accesses */
> # define PR_UNALIGN_SIGBUS    2       /* generate SIGBUS on unaligned user 
> access */

> (asm-parisc/processor.h & asm-ia64/processor.h)
> #define PARISC_UAC_NOPRINT    (1UL << 0)      /* see prctl and unaligned.c */
> #define PARISC_UAC_SIGBUS     (1UL << 1)

> IE, NOPRINT is set by 1, and SIGBUS set by 2.

> on alpha, because it's reusing the OSF/1 crap, the order is
> NOPRINT, NOFIX, SIGNAL, ie: 1, 2, 4. 

> I don't know what the best way to fix this is, but something like
> this patch will probably help,

As discussed, I think it's more appropriate to fix this in the kernel, so
that the syscall behavior actually matches what's documented in
linux/prctl.h. :)  So here's a tested patch which does this.  Ugly as sin,
but I'm at a loss for how you'd make this pretty...

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
[EMAIL PROTECTED]                                   http://www.debian.org/
diff --git a/include/asm-alpha/thread_info.h b/include/asm-alpha/thread_info.h
index 69ffd93..011daaf 100644
--- a/include/asm-alpha/thread_info.h
+++ b/include/asm-alpha/thread_info.h
@@ -92,5 +92,27 @@ register struct thread_info *__current_t
 #define _TIF_ALLWORK_MASK      (_TIF_WORK_MASK         \
                                 | _TIF_SYSCALL_TRACE)
 
+#define ALPHA_UAC_SHIFT                6
+#define ALPHA_UAC_MASK         (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
+                                1 << TIF_UAC_SIGBUS)
+
+#define SET_UNALIGN_CTL(task,value)    ({                                   \
+       (task)->thread_info->flags = (((task)->thread_info->flags &          \
+               ~ALPHA_UAC_MASK)                                             \
+               | (((value) << ALPHA_UAC_SHIFT) & (1 << TIF_UAC_NOPRINT))    \
+               | (((value) << ALPHA_UAC_SHIFT + 1) & (1 << TIF_UAC_SIGBUS)) \
+               | (((value) << ALPHA_UAC_SHIFT - 1) & (1 << TIF_UAC_NOFIX)));\
+       0; })
+
+#define GET_UNALIGN_CTL(task,value)    ({                              \
+       put_user(((task)->thread_info->flags & (1 << TIF_UAC_NOPRINT))  \
+                 >> ALPHA_UAC_SHIFT                                    \
+                | ((task)->thread_info->flags & (1 << TIF_UAC_SIGBUS)) \
+                 >> ALPHA_UAC_SHIFT + 1                                \
+                | ((task)->thread_info->flags & (1 << TIF_UAC_NOFIX))  \
+                 >> ALPHA_UAC_SHIFT - 1,                               \
+                (int __user *)(value));                                \
+       })
+
 #endif /* __KERNEL__ */
 #endif /* _ALPHA_THREAD_INFO_H */

Attachment: signature.asc
Description: Digital signature

Reply via email to