* [PATCH] Fix sparc64 build with CONFIG_COMPAT=n
@ 2004-07-10 3:47 ` Roland Dreier
0 siblings, 0 replies; 8+ messages in thread
From: Roland Dreier @ 2004-07-10 3:47 UTC (permalink / raw)
To: davem, ultralinux; +Cc: linux-kernel
--=-=-
Right now sparc64 has achieved the impressive feat of not compiling
with allnoconfig (in fact the very first source file, init/main.c,
won't build).
This is because various structures and so on use types that are only
defined if CONFIG_COMPAT is on, but allnoconfig sets
CONFIG_SPARC32_COMPAT and therefore CONFIG_COMPAT to n. I'm including
two possible solutions: one trivial one that forces
CONFIG_SPARC32_COMPAT to y, and one that actually tries to make the
CONFIG_COMPAT=n case work.
I don't actually have any hardware to try this on since I only
discovered the problem testing my driver for portability by
cross-compiling (I use allnoconfig to make my build as quick as
possible). In fact I'm not sure if anyone has a full 64-bit userspace
for sparc64. Therefore the first patch is probably the best fix, but
I leave it up to the experts.
I'm including the simple fix inline and attaching the big fix.
Thanks,
Roland
Index: linux-2.6.7-sparc64/arch/sparc64/Kconfig
=================================--- linux-2.6.7-sparc64.orig/arch/sparc64/Kconfig 2004-07-08 20:07:28.000000000 -0700
+++ linux-2.6.7-sparc64/arch/sparc64/Kconfig 2004-07-09 20:43:11.000000000 -0700
@@ -348,7 +348,8 @@
module will be called openpromfs. If unsure, choose M.
config SPARC32_COMPAT
- bool "Kernel support for Linux/Sparc 32bit binary compatibility"
+ bool "Kernel support for Linux/Sparc 32bit binary compatibility" if BROKEN
+ default y
help
This allows you to run 32-bit binaries on your Ultra.
Everybody wants this; say Y.
--=-=-Content-Disposition: inline; filename=sparc64-compat.diff
Index: linux-2.6.7-sparc64/arch/sparc64/Kconfig
=================================--- linux-2.6.7-sparc64.orig/arch/sparc64/Kconfig 2004-07-08 20:07:28.000000000 -0700
+++ linux-2.6.7-sparc64/arch/sparc64/Kconfig 2004-07-09 20:00:34.000000000 -0700
@@ -382,6 +382,7 @@
config SUNOS_EMUL
bool "SunOS binary emulation"
+ depends on BINFMT_AOUT32
help
This allows you to run most SunOS binaries. If you want to do this,
say Y here and place appropriate files in /usr/gnemul/sunos. See
@@ -391,7 +392,7 @@
config SOLARIS_EMUL
tristate "Solaris binary emulation (EXPERIMENTAL)"
- depends on EXPERIMENTAL
+ depends on SPARC32_COMPAT && EXPERIMENTAL
help
This is experimental code which will enable you to run (many)
Solaris binaries on your SPARC Linux machine.
Index: linux-2.6.7-sparc64/arch/sparc64/kernel/process.c
=================================--- linux-2.6.7-sparc64.orig/arch/sparc64/kernel/process.c 2004-06-15 22:19:22.000000000 -0700
+++ linux-2.6.7-sparc64/arch/sparc64/kernel/process.c 2004-07-09 19:55:23.000000000 -0700
@@ -588,10 +588,14 @@
clone_flags &= ~CLONE_IDLETASK;
+
+#ifdef CONFIG_SPARC32_COMPAT
if (test_thread_flag(TIF_32BIT)) {
parent_tid_ptr = compat_ptr(regs->u_regs[UREG_I2]);
child_tid_ptr = compat_ptr(regs->u_regs[UREG_I4]);
- } else {
+ } else
+#endif /* CONFIG_SPARC32_COMPAT */
+ {
parent_tid_ptr = (int __user *) regs->u_regs[UREG_I2];
child_tid_ptr = (int __user *) regs->u_regs[UREG_I4];
}
Index: linux-2.6.7-sparc64/include/asm-sparc64/compat.h
=================================--- linux-2.6.7-sparc64.orig/include/asm-sparc64/compat.h 2004-06-15 22:19:37.000000000 -0700
+++ linux-2.6.7-sparc64/include/asm-sparc64/compat.h 2004-07-09 19:50:39.000000000 -0700
@@ -96,6 +96,78 @@
int f_spare[5];
};
+struct __new_sigaction32 {
+ unsigned sa_handler;
+ unsigned int sa_flags;
+ unsigned sa_restorer; /* not used by Linux/SPARC yet */
+ compat_sigset_t sa_mask;
+};
+
+struct __old_sigaction32 {
+ unsigned sa_handler;
+ compat_old_sigset_t sa_mask;
+ unsigned int sa_flags;
+ unsigned sa_restorer; /* not used by Linux/SPARC yet */
+};
+
+typedef struct sigaltstack32 {
+ u32 ss_sp;
+ int ss_flags;
+ compat_size_t ss_size;
+} stack_t32;
+
+typedef struct siginfo32 {
+ int si_signo;
+ int si_errno;
+ int si_code;
+
+ union {
+ int _pad[SI_PAD_SIZE32];
+
+ /* kill() */
+ struct {
+ compat_pid_t _pid; /* sender's pid */
+ unsigned int _uid; /* sender's uid */
+ } _kill;
+
+ /* POSIX.1b timers */
+ struct {
+ timer_t _tid; /* timer id */
+ int _overrun; /* overrun count */
+ sigval_t32 _sigval; /* same as below */
+ int _sys_private; /* not to be passed to user */
+ } _timer;
+
+ /* POSIX.1b signals */
+ struct {
+ compat_pid_t _pid; /* sender's pid */
+ unsigned int _uid; /* sender's uid */
+ sigval_t32 _sigval;
+ } _rt;
+
+ /* SIGCHLD */
+ struct {
+ compat_pid_t _pid; /* which child */
+ unsigned int _uid; /* sender's uid */
+ int _status; /* exit code */
+ compat_clock_t _utime;
+ compat_clock_t _stime;
+ } _sigchld;
+
+ /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
+ struct {
+ u32 _addr; /* faulting insn/memory ref. */
+ int _trapno;
+ } _sigfault;
+
+ /* SIGPOLL */
+ struct {
+ int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
+ int _fd;
+ } _sigpoll;
+ } _sifields;
+} siginfo_t32;
+
#define COMPAT_RLIM_INFINITY 0x7fffffff
typedef u32 compat_old_sigset_t;
Index: linux-2.6.7-sparc64/include/asm-sparc64/siginfo.h
=================================--- linux-2.6.7-sparc64.orig/include/asm-sparc64/siginfo.h 2004-06-15 22:19:43.000000000 -0700
+++ linux-2.6.7-sparc64/include/asm-sparc64/siginfo.h 2004-07-09 19:54:12.000000000 -0700
@@ -21,58 +21,6 @@
u32 sival_ptr;
} sigval_t32;
-typedef struct siginfo32 {
- int si_signo;
- int si_errno;
- int si_code;
-
- union {
- int _pad[SI_PAD_SIZE32];
-
- /* kill() */
- struct {
- compat_pid_t _pid; /* sender's pid */
- unsigned int _uid; /* sender's uid */
- } _kill;
-
- /* POSIX.1b timers */
- struct {
- timer_t _tid; /* timer id */
- int _overrun; /* overrun count */
- sigval_t32 _sigval; /* same as below */
- int _sys_private; /* not to be passed to user */
- } _timer;
-
- /* POSIX.1b signals */
- struct {
- compat_pid_t _pid; /* sender's pid */
- unsigned int _uid; /* sender's uid */
- sigval_t32 _sigval;
- } _rt;
-
- /* SIGCHLD */
- struct {
- compat_pid_t _pid; /* which child */
- unsigned int _uid; /* sender's uid */
- int _status; /* exit code */
- compat_clock_t _utime;
- compat_clock_t _stime;
- } _sigchld;
-
- /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
- struct {
- u32 _addr; /* faulting insn/memory ref. */
- int _trapno;
- } _sigfault;
-
- /* SIGPOLL */
- struct {
- int _band; /* POLL_IN, POLL_OUT, POLL_MSG */
- int _fd;
- } _sigpoll;
- } _sifields;
-} siginfo_t32;
-
#endif /* __KERNEL__ */
#define SI_NOINFO 32767 /* no information in siginfo_t */
@@ -85,6 +33,7 @@
#ifdef __KERNEL__
+#ifdef CONFIG_SPARC32_COMPAT
typedef struct sigevent32 {
sigval_t32 sigev_value;
int sigev_signo;
@@ -100,6 +49,7 @@
} sigevent_t32;
extern int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from);
+#endif /* CONFIG_SPARC32_COMPAT */
#endif /* __KERNEL__ */
Index: linux-2.6.7-sparc64/include/asm-sparc64/signal.h
=================================--- linux-2.6.7-sparc64.orig/include/asm-sparc64/signal.h 2004-06-15 22:19:02.000000000 -0700
+++ linux-2.6.7-sparc64/include/asm-sparc64/signal.h 2004-07-09 20:24:15.000000000 -0700
@@ -9,6 +9,7 @@
#include <linux/personality.h>
#include <linux/types.h>
#include <linux/compat.h>
+#include <linux/compiler.h> /* For __user */
#endif
#endif
@@ -203,13 +204,6 @@
};
#ifdef __KERNEL__
-struct __new_sigaction32 {
- unsigned sa_handler;
- unsigned int sa_flags;
- unsigned sa_restorer; /* not used by Linux/SPARC yet */
- compat_sigset_t sa_mask;
-};
-
struct k_sigaction {
struct __new_sigaction sa;
void __user *ka_restorer;
@@ -223,15 +217,6 @@
void (*sa_restorer)(void); /* not used by Linux/SPARC yet */
};
-#ifdef __KERNEL__
-struct __old_sigaction32 {
- unsigned sa_handler;
- compat_old_sigset_t sa_mask;
- unsigned int sa_flags;
- unsigned sa_restorer; /* not used by Linux/SPARC yet */
-};
-#endif
-
typedef struct sigaltstack {
void *ss_sp;
int ss_flags;
@@ -239,12 +224,6 @@
} stack_t;
#ifdef __KERNEL__
-typedef struct sigaltstack32 {
- u32 ss_sp;
- int ss_flags;
- compat_size_t ss_size;
-} stack_t32;
-
struct signal_deliver_cookie {
int restart_syscall;
unsigned long orig_i0;
--=-=-=--
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH] Fix sparc64 build with CONFIG_COMPAT=n @ 2004-07-10 3:47 ` Roland Dreier 0 siblings, 0 replies; 8+ messages in thread From: Roland Dreier @ 2004-07-10 3:47 UTC (permalink / raw) To: davem, ultralinux; +Cc: linux-kernel [-- Attachment #1: Type: text/plain, Size: 1576 bytes --] Right now sparc64 has achieved the impressive feat of not compiling with allnoconfig (in fact the very first source file, init/main.c, won't build). This is because various structures and so on use types that are only defined if CONFIG_COMPAT is on, but allnoconfig sets CONFIG_SPARC32_COMPAT and therefore CONFIG_COMPAT to n. I'm including two possible solutions: one trivial one that forces CONFIG_SPARC32_COMPAT to y, and one that actually tries to make the CONFIG_COMPAT=n case work. I don't actually have any hardware to try this on since I only discovered the problem testing my driver for portability by cross-compiling (I use allnoconfig to make my build as quick as possible). In fact I'm not sure if anyone has a full 64-bit userspace for sparc64. Therefore the first patch is probably the best fix, but I leave it up to the experts. I'm including the simple fix inline and attaching the big fix. Thanks, Roland Index: linux-2.6.7-sparc64/arch/sparc64/Kconfig =================================================================== --- linux-2.6.7-sparc64.orig/arch/sparc64/Kconfig 2004-07-08 20:07:28.000000000 -0700 +++ linux-2.6.7-sparc64/arch/sparc64/Kconfig 2004-07-09 20:43:11.000000000 -0700 @@ -348,7 +348,8 @@ module will be called openpromfs. If unsure, choose M. config SPARC32_COMPAT - bool "Kernel support for Linux/Sparc 32bit binary compatibility" + bool "Kernel support for Linux/Sparc 32bit binary compatibility" if BROKEN + default y help This allows you to run 32-bit binaries on your Ultra. Everybody wants this; say Y. [-- Attachment #2: sparc64-compat.diff --] [-- Type: text/plain, Size: 6876 bytes --] Index: linux-2.6.7-sparc64/arch/sparc64/Kconfig =================================================================== --- linux-2.6.7-sparc64.orig/arch/sparc64/Kconfig 2004-07-08 20:07:28.000000000 -0700 +++ linux-2.6.7-sparc64/arch/sparc64/Kconfig 2004-07-09 20:00:34.000000000 -0700 @@ -382,6 +382,7 @@ config SUNOS_EMUL bool "SunOS binary emulation" + depends on BINFMT_AOUT32 help This allows you to run most SunOS binaries. If you want to do this, say Y here and place appropriate files in /usr/gnemul/sunos. See @@ -391,7 +392,7 @@ config SOLARIS_EMUL tristate "Solaris binary emulation (EXPERIMENTAL)" - depends on EXPERIMENTAL + depends on SPARC32_COMPAT && EXPERIMENTAL help This is experimental code which will enable you to run (many) Solaris binaries on your SPARC Linux machine. Index: linux-2.6.7-sparc64/arch/sparc64/kernel/process.c =================================================================== --- linux-2.6.7-sparc64.orig/arch/sparc64/kernel/process.c 2004-06-15 22:19:22.000000000 -0700 +++ linux-2.6.7-sparc64/arch/sparc64/kernel/process.c 2004-07-09 19:55:23.000000000 -0700 @@ -588,10 +588,14 @@ clone_flags &= ~CLONE_IDLETASK; + +#ifdef CONFIG_SPARC32_COMPAT if (test_thread_flag(TIF_32BIT)) { parent_tid_ptr = compat_ptr(regs->u_regs[UREG_I2]); child_tid_ptr = compat_ptr(regs->u_regs[UREG_I4]); - } else { + } else +#endif /* CONFIG_SPARC32_COMPAT */ + { parent_tid_ptr = (int __user *) regs->u_regs[UREG_I2]; child_tid_ptr = (int __user *) regs->u_regs[UREG_I4]; } Index: linux-2.6.7-sparc64/include/asm-sparc64/compat.h =================================================================== --- linux-2.6.7-sparc64.orig/include/asm-sparc64/compat.h 2004-06-15 22:19:37.000000000 -0700 +++ linux-2.6.7-sparc64/include/asm-sparc64/compat.h 2004-07-09 19:50:39.000000000 -0700 @@ -96,6 +96,78 @@ int f_spare[5]; }; +struct __new_sigaction32 { + unsigned sa_handler; + unsigned int sa_flags; + unsigned sa_restorer; /* not used by Linux/SPARC yet */ + compat_sigset_t sa_mask; +}; + +struct __old_sigaction32 { + unsigned sa_handler; + compat_old_sigset_t sa_mask; + unsigned int sa_flags; + unsigned sa_restorer; /* not used by Linux/SPARC yet */ +}; + +typedef struct sigaltstack32 { + u32 ss_sp; + int ss_flags; + compat_size_t ss_size; +} stack_t32; + +typedef struct siginfo32 { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[SI_PAD_SIZE32]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + sigval_t32 _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + sigval_t32 _sigval; + } _rt; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ + struct { + u32 _addr; /* faulting insn/memory ref. */ + int _trapno; + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} siginfo_t32; + #define COMPAT_RLIM_INFINITY 0x7fffffff typedef u32 compat_old_sigset_t; Index: linux-2.6.7-sparc64/include/asm-sparc64/siginfo.h =================================================================== --- linux-2.6.7-sparc64.orig/include/asm-sparc64/siginfo.h 2004-06-15 22:19:43.000000000 -0700 +++ linux-2.6.7-sparc64/include/asm-sparc64/siginfo.h 2004-07-09 19:54:12.000000000 -0700 @@ -21,58 +21,6 @@ u32 sival_ptr; } sigval_t32; -typedef struct siginfo32 { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[SI_PAD_SIZE32]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - sigval_t32 _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - sigval_t32 _sigval; - } _rt; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ - struct { - u32 _addr; /* faulting insn/memory ref. */ - int _trapno; - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} siginfo_t32; - #endif /* __KERNEL__ */ #define SI_NOINFO 32767 /* no information in siginfo_t */ @@ -85,6 +33,7 @@ #ifdef __KERNEL__ +#ifdef CONFIG_SPARC32_COMPAT typedef struct sigevent32 { sigval_t32 sigev_value; int sigev_signo; @@ -100,6 +49,7 @@ } sigevent_t32; extern int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from); +#endif /* CONFIG_SPARC32_COMPAT */ #endif /* __KERNEL__ */ Index: linux-2.6.7-sparc64/include/asm-sparc64/signal.h =================================================================== --- linux-2.6.7-sparc64.orig/include/asm-sparc64/signal.h 2004-06-15 22:19:02.000000000 -0700 +++ linux-2.6.7-sparc64/include/asm-sparc64/signal.h 2004-07-09 20:24:15.000000000 -0700 @@ -9,6 +9,7 @@ #include <linux/personality.h> #include <linux/types.h> #include <linux/compat.h> +#include <linux/compiler.h> /* For __user */ #endif #endif @@ -203,13 +204,6 @@ }; #ifdef __KERNEL__ -struct __new_sigaction32 { - unsigned sa_handler; - unsigned int sa_flags; - unsigned sa_restorer; /* not used by Linux/SPARC yet */ - compat_sigset_t sa_mask; -}; - struct k_sigaction { struct __new_sigaction sa; void __user *ka_restorer; @@ -223,15 +217,6 @@ void (*sa_restorer)(void); /* not used by Linux/SPARC yet */ }; -#ifdef __KERNEL__ -struct __old_sigaction32 { - unsigned sa_handler; - compat_old_sigset_t sa_mask; - unsigned int sa_flags; - unsigned sa_restorer; /* not used by Linux/SPARC yet */ -}; -#endif - typedef struct sigaltstack { void *ss_sp; int ss_flags; @@ -239,12 +224,6 @@ } stack_t; #ifdef __KERNEL__ -typedef struct sigaltstack32 { - u32 ss_sp; - int ss_flags; - compat_size_t ss_size; -} stack_t32; - struct signal_deliver_cookie { int restart_syscall; unsigned long orig_i0; ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix sparc64 build with CONFIG_COMPAT=n 2004-07-10 3:47 ` Roland Dreier @ 2004-07-21 3:03 ` David S. Miller -1 siblings, 0 replies; 8+ messages in thread From: David S. Miller @ 2004-07-21 3:03 UTC (permalink / raw) To: Roland Dreier; +Cc: ultralinux, linux-kernel On Fri, 09 Jul 2004 20:47:09 -0700 Roland Dreier <roland@topspin.com> wrote: > I'm including the simple fix inline and attaching the big fix. I like the big fix, and it allowed some cleanups too. I've munged your patch a bit and this is what I'm currently testing. Thanks a lot. === arch/sparc64/Kconfig 1.52 vs edited ==--- 1.52/arch/sparc64/Kconfig 2004-05-24 10:09:14 -07:00 +++ edited/arch/sparc64/Kconfig 2004-07-20 19:49:30 -07:00 @@ -382,6 +382,7 @@ config SUNOS_EMUL bool "SunOS binary emulation" + depends on BINFMT_AOUT32 help This allows you to run most SunOS binaries. If you want to do this, say Y here and place appropriate files in /usr/gnemul/sunos. See @@ -391,7 +392,7 @@ config SOLARIS_EMUL tristate "Solaris binary emulation (EXPERIMENTAL)" - depends on EXPERIMENTAL + depends on SPARC32_COMPAT && EXPERIMENTAL help This is experimental code which will enable you to run (many) Solaris binaries on your SPARC Linux machine. === arch/sparc64/kernel/entry.S 1.34 vs edited ==--- 1.34/arch/sparc64/kernel/entry.S 2004-06-20 12:32:28 -07:00 +++ edited/arch/sparc64/kernel/entry.S 2004-07-20 19:55:29 -07:00 @@ -1496,28 +1496,30 @@ /* SunOS's execv() call only specifies the argv argument, the * environment settings are the same as the calling processes. */ - .globl sunos_execv, sys_execve, sys32_execve + .globl sunos_execv sys_execve: sethi %hi(sparc_execve), %g1 ba,pt %xcc, execve_merge or %g1, %lo(sparc_execve), %g1 +#ifdef CONFIG_COMPAT + .globl sys_execve sunos_execv: stx %g0, [%sp + PTREGS_OFF + PT_V9_I2] + .globl sys32_execve sys32_execve: sethi %hi(sparc32_execve), %g1 or %g1, %lo(sparc32_execve), %g1 +#endif execve_merge: flushw jmpl %g1, %g0 add %sp, PTREGS_OFF, %o0 .globl sys_pipe, sys_sigpause, sys_nis_syscall - .globl sys_sigsuspend, sys_rt_sigsuspend, sys32_rt_sigsuspend + .globl sys_sigsuspend, sys_rt_sigsuspend .globl sys_rt_sigreturn - .globl sys32_sigreturn, sys32_rt_sigreturn - .globl sys32_execve, sys_ptrace - .globl sys_sigaltstack, sys32_sigaltstack - .globl sys32_sigstack + .globl sys_ptrace + .globl sys_sigaltstack .align 32 sys_pipe: ba,pt %xcc, sparc_pipe add %sp, PTREGS_OFF, %o0 @@ -1528,12 +1530,15 @@ add %sp, PTREGS_OFF, %o1 sys_sigaltstack:ba,pt %xcc, do_sigaltstack add %i6, STACK_BIAS, %o2 +#ifdef CONFIG_COMPAT + .globl sys32_sigstack sys32_sigstack: ba,pt %xcc, do_sys32_sigstack mov %i6, %o2 + .globl sys32_sigaltstack sys32_sigaltstack: ba,pt %xcc, do_sys32_sigaltstack mov %i6, %o2 - +#endif .align 32 sys_sigsuspend: add %sp, PTREGS_OFF, %o0 call do_sigsuspend @@ -1544,31 +1549,40 @@ call do_rt_sigsuspend add %o7, 1f-.-4, %o7 nop +#ifdef CONFIG_COMPAT + .globl sys32_rt_sigsuspend sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */ srl %o0, 0, %o0 add %sp, PTREGS_OFF, %o2 call do_rt_sigsuspend32 add %o7, 1f-.-4, %o7 +#endif /* NOTE: %o0 has a correct value already */ sys_sigpause: add %sp, PTREGS_OFF, %o1 call do_sigpause add %o7, 1f-.-4, %o7 nop +#ifdef CONFIG_COMPAT + .globl sys32_sigreturn sys32_sigreturn: add %sp, PTREGS_OFF, %o0 call do_sigreturn32 add %o7, 1f-.-4, %o7 nop +#endif sys_rt_sigreturn: add %sp, PTREGS_OFF, %o0 call do_rt_sigreturn add %o7, 1f-.-4, %o7 nop +#ifdef CONFIG_COMPAT + .globl sys32_rt_sigreturn sys32_rt_sigreturn: add %sp, PTREGS_OFF, %o0 call do_rt_sigreturn32 add %o7, 1f-.-4, %o7 nop +#endif sys_ptrace: add %sp, PTREGS_OFF, %o0 call do_ptrace add %o7, 1f-.-4, %o7 === arch/sparc64/kernel/process.c 1.55 vs edited ==--- 1.55/arch/sparc64/kernel/process.c 2004-06-01 21:42:33 -07:00 +++ edited/arch/sparc64/kernel/process.c 2004-07-20 19:13:30 -07:00 @@ -12,6 +12,7 @@ #include <stdarg.h> +#include <linux/config.h> #include <linux/errno.h> #include <linux/module.h> #include <linux/sched.h> @@ -588,10 +589,13 @@ clone_flags &= ~CLONE_IDLETASK; +#ifdef CONFIG_COMPAT if (test_thread_flag(TIF_32BIT)) { parent_tid_ptr = compat_ptr(regs->u_regs[UREG_I2]); child_tid_ptr = compat_ptr(regs->u_regs[UREG_I4]); - } else { + } else +#endif + { parent_tid_ptr = (int __user *) regs->u_regs[UREG_I2]; child_tid_ptr = (int __user *) regs->u_regs[UREG_I4]; } === arch/sparc64/kernel/signal32.c 1.38 vs edited ==--- 1.38/arch/sparc64/kernel/signal32.c 2004-07-13 05:56:55 -07:00 +++ edited/arch/sparc64/kernel/signal32.c 2004-07-20 19:12:25 -07:00 @@ -59,6 +59,63 @@ unsigned int extramask[_COMPAT_NSIG_WORDS - 1]; }; +typedef union sigval32 { + int sival_int; + u32 sival_ptr; +} sigval_t32; + +typedef struct siginfo32 { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[SI_PAD_SIZE32]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + sigval_t32 _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + sigval_t32 _sigval; + } _rt; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ + struct { + u32 _addr; /* faulting insn/memory ref. */ + int _trapno; + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} siginfo_t32; + /* * And the new one, intended to be used for Linux applications only * (we have enough in there to work with clone). @@ -76,6 +133,12 @@ __siginfo_fpu_t fpu_state; }; +typedef struct sigaltstack32 { + u32 ss_sp; + int ss_flags; + compat_size_t ss_size; +} stack_t32; + struct rt_signal_frame32 { struct sparc_stackf32 ss; siginfo_t32 info; @@ -95,7 +158,7 @@ #define NF_ALIGNEDSZ (((sizeof(struct new_signal_frame32) + 7) & (~7))) #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 7) & (~7))) -int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from) +static int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from) { int err; @@ -1370,5 +1433,106 @@ __put_user(uoss.ss_flags, &((stack_t32 __user *)(long)uossa)->ss_flags) || __put_user(uoss.ss_size, &((stack_t32 __user *)(long)uossa)->ss_size))) return -EFAULT; + return ret; +} + +asmlinkage long sys32_rt_sigtimedwait(compat_sigset_t __user *uthese, + siginfo_t32 __user *uinfo, + struct compat_timespec __user *uts, + compat_size_t sigsetsize) +{ + int ret, sig; + sigset_t these; + compat_sigset_t these32; + struct timespec ts; + siginfo_t info; + long timeout = 0; + + /* XXX: Don't preclude handling different sized sigset_t's. */ + if (sigsetsize != sizeof(sigset_t)) + return -EINVAL; + + if (copy_from_user (&these32, uthese, sizeof(compat_sigset_t))) + return -EFAULT; + + switch (_NSIG_WORDS) { + case 4: these.sig[3] = these32.sig[6] | (((long)these32.sig[7]) << 32); + case 3: these.sig[2] = these32.sig[4] | (((long)these32.sig[5]) << 32); + case 2: these.sig[1] = these32.sig[2] | (((long)these32.sig[3]) << 32); + case 1: these.sig[0] = these32.sig[0] | (((long)these32.sig[1]) << 32); + } + + /* + * Invert the set of allowed signals to get those we + * want to block. + */ + sigdelsetmask(&these, sigmask(SIGKILL)|sigmask(SIGSTOP)); + signotset(&these); + + if (uts) { + if (get_compat_timespec(&ts, uts)) + return -EINVAL; + if (ts.tv_nsec >= 1000000000L || ts.tv_nsec < 0 + || ts.tv_sec < 0) + return -EINVAL; + } + + spin_lock_irq(¤t->sighand->siglock); + sig = dequeue_signal(current, &these, &info); + if (!sig) { + timeout = MAX_SCHEDULE_TIMEOUT; + if (uts) + timeout = (timespec_to_jiffies(&ts) + + (ts.tv_sec || ts.tv_nsec)); + + if (timeout) { + /* None ready -- temporarily unblock those we're + * interested while we are sleeping in so that we'll + * be awakened when they arrive. */ + current->real_blocked = current->blocked; + sigandsets(¤t->blocked, ¤t->blocked, &these); + recalc_sigpending(); + spin_unlock_irq(¤t->sighand->siglock); + + current->state = TASK_INTERRUPTIBLE; + timeout = schedule_timeout(timeout); + + spin_lock_irq(¤t->sighand->siglock); + sig = dequeue_signal(current, &these, &info); + current->blocked = current->real_blocked; + siginitset(¤t->real_blocked, 0); + recalc_sigpending(); + } + } + spin_unlock_irq(¤t->sighand->siglock); + + if (sig) { + ret = sig; + if (uinfo) { + if (copy_siginfo_to_user32(uinfo, &info)) + ret = -EFAULT; + } + } else { + ret = -EAGAIN; + if (timeout) + ret = -EINTR; + } + + return ret; +} + +asmlinkage long compat_sys_rt_sigqueueinfo(int pid, int sig, + siginfo_t32 __user *uinfo) +{ + siginfo_t info; + int ret; + mm_segment_t old_fs = get_fs(); + + if (copy_from_user (&info, uinfo, 3*sizeof(int)) || + copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE)) + return -EFAULT; + set_fs (KERNEL_DS); + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info); + set_fs (old_fs); return ret; } === arch/sparc64/kernel/sys_sparc32.c 1.103 vs edited ==--- 1.103/arch/sparc64/kernel/sys_sparc32.c 2004-07-13 05:57:10 -07:00 +++ edited/arch/sparc64/kernel/sys_sparc32.c 2004-07-20 19:12:04 -07:00 @@ -1176,106 +1176,19 @@ return ret; } -asmlinkage long sys32_rt_sigtimedwait(compat_sigset_t __user *uthese, - siginfo_t32 __user *uinfo, - struct compat_timespec __user *uts, - compat_size_t sigsetsize) -{ - int ret, sig; - sigset_t these; - compat_sigset_t these32; - struct timespec ts; - siginfo_t info; - long timeout = 0; - - /* XXX: Don't preclude handling different sized sigset_t's. */ - if (sigsetsize != sizeof(sigset_t)) - return -EINVAL; - - if (copy_from_user (&these32, uthese, sizeof(compat_sigset_t))) - return -EFAULT; - - switch (_NSIG_WORDS) { - case 4: these.sig[3] = these32.sig[6] | (((long)these32.sig[7]) << 32); - case 3: these.sig[2] = these32.sig[4] | (((long)these32.sig[5]) << 32); - case 2: these.sig[1] = these32.sig[2] | (((long)these32.sig[3]) << 32); - case 1: these.sig[0] = these32.sig[0] | (((long)these32.sig[1]) << 32); - } - - /* - * Invert the set of allowed signals to get those we - * want to block. - */ - sigdelsetmask(&these, sigmask(SIGKILL)|sigmask(SIGSTOP)); - signotset(&these); - - if (uts) { - if (get_compat_timespec(&ts, uts)) - return -EINVAL; - if (ts.tv_nsec >= 1000000000L || ts.tv_nsec < 0 - || ts.tv_sec < 0) - return -EINVAL; - } - - spin_lock_irq(¤t->sighand->siglock); - sig = dequeue_signal(current, &these, &info); - if (!sig) { - timeout = MAX_SCHEDULE_TIMEOUT; - if (uts) - timeout = (timespec_to_jiffies(&ts) - + (ts.tv_sec || ts.tv_nsec)); - - if (timeout) { - /* None ready -- temporarily unblock those we're - * interested while we are sleeping in so that we'll - * be awakened when they arrive. */ - current->real_blocked = current->blocked; - sigandsets(¤t->blocked, ¤t->blocked, &these); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); - - current->state = TASK_INTERRUPTIBLE; - timeout = schedule_timeout(timeout); - - spin_lock_irq(¤t->sighand->siglock); - sig = dequeue_signal(current, &these, &info); - current->blocked = current->real_blocked; - siginitset(¤t->real_blocked, 0); - recalc_sigpending(); - } - } - spin_unlock_irq(¤t->sighand->siglock); - - if (sig) { - ret = sig; - if (uinfo) { - if (copy_siginfo_to_user32(uinfo, &info)) - ret = -EFAULT; - } - } else { - ret = -EAGAIN; - if (timeout) - ret = -EINTR; - } - - return ret; -} +struct __old_sigaction32 { + unsigned sa_handler; + compat_old_sigset_t sa_mask; + unsigned int sa_flags; + unsigned sa_restorer; /* not used by Linux/SPARC yet */ +}; -asmlinkage long compat_sys_rt_sigqueueinfo(int pid, int sig, - siginfo_t32 __user *uinfo) -{ - siginfo_t info; - int ret; - mm_segment_t old_fs = get_fs(); - - if (copy_from_user (&info, uinfo, 3*sizeof(int)) || - copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE)) - return -EFAULT; - set_fs (KERNEL_DS); - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info); - set_fs (old_fs); - return ret; -} +struct __new_sigaction32 { + unsigned sa_handler; + unsigned int sa_flags; + unsigned sa_restorer; /* not used by Linux/SPARC yet */ + compat_sigset_t sa_mask; +}; asmlinkage long compat_sys_sigaction(int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact) @@ -1831,6 +1744,20 @@ sys_timer_create(clockid_t which_clock, struct sigevent __user *timer_event_spec, timer_t __user *created_timer_id); + +typedef struct sigevent32 { + sigval_t32 sigev_value; + int sigev_signo; + int sigev_notify; + union { + int _pad[SIGEV_PAD_SIZE32]; + + struct { + u32 _function; + u32 _attribute; /* really pthread_attr_t */ + } _sigev_thread; + } _sigev_un; +} sigevent_t32; long sys32_timer_create(u32 clock, struct sigevent32 __user *se32, === arch/sparc64/kernel/systbls.S 1.60 vs edited ==--- 1.60/arch/sparc64/kernel/systbls.S 2004-06-01 21:42:33 -07:00 +++ edited/arch/sparc64/kernel/systbls.S 2004-07-20 19:56:06 -07:00 @@ -15,6 +15,7 @@ .text .align 4 +#ifdef CONFIG_COMPAT /* First, the 32-bit Linux native syscall table. */ .globl sys_call_table32 @@ -77,6 +78,8 @@ .word sys_mq_timedsend, sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, sys_ni_syscall /*280*/ .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall +#endif /* CONFIG_COMPAT */ + /* Now the 64-bit native Linux syscall table. */ .align 4 @@ -85,7 +88,7 @@ sys_call_table: /*0*/ .word sys_restart_syscall, sparc_exit, sys_fork, sys_read, sys_write /*5*/ .word sys_open, sys_close, sys_wait4, sys_creat, sys_link -/*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys_chown, sys_mknod +/*10*/ .word sys_unlink, sys_nis_syscall, sys_chdir, sys_chown, sys_mknod /*15*/ .word sys_chmod, sys_lchown, sparc_brk, sys_perfctr, sys_lseek /*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid /*25*/ .word sys_nis_syscall, sys_ptrace, sys_alarm, sys_sigaltstack, sys_nis_syscall === include/asm-sparc64/siginfo.h 1.15 vs edited ==--- 1.15/include/asm-sparc64/siginfo.h 2004-05-31 16:25:29 -07:00 +++ edited/include/asm-sparc64/siginfo.h 2004-07-20 19:12:32 -07:00 @@ -12,69 +12,6 @@ #include <asm-generic/siginfo.h> -#ifdef __KERNEL__ - -#include <linux/compat.h> - -typedef union sigval32 { - int sival_int; - u32 sival_ptr; -} sigval_t32; - -typedef struct siginfo32 { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[SI_PAD_SIZE32]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - sigval_t32 _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - sigval_t32 _sigval; - } _rt; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ - struct { - u32 _addr; /* faulting insn/memory ref. */ - int _trapno; - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} siginfo_t32; - -#endif /* __KERNEL__ */ - #define SI_NOINFO 32767 /* no information in siginfo_t */ /* @@ -82,25 +19,5 @@ */ #define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */ #define NSIGEMT 1 - -#ifdef __KERNEL__ - -typedef struct sigevent32 { - sigval_t32 sigev_value; - int sigev_signo; - int sigev_notify; - union { - int _pad[SIGEV_PAD_SIZE32]; - - struct { - u32 _function; - u32 _attribute; /* really pthread_attr_t */ - } _sigev_thread; - } _sigev_un; -} sigevent_t32; - -extern int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from); - -#endif /* __KERNEL__ */ #endif === include/asm-sparc64/signal.h 1.14 vs edited ==--- 1.14/include/asm-sparc64/signal.h 2004-07-13 05:51:54 -07:00 +++ edited/include/asm-sparc64/signal.h 2004-07-20 19:09:41 -07:00 @@ -8,7 +8,6 @@ #ifndef __ASSEMBLY__ #include <linux/personality.h> #include <linux/types.h> -#include <linux/compat.h> #endif #endif @@ -208,13 +207,6 @@ }; #ifdef __KERNEL__ -struct __new_sigaction32 { - unsigned sa_handler; - unsigned int sa_flags; - unsigned sa_restorer; /* not used by Linux/SPARC yet */ - compat_sigset_t sa_mask; -}; - struct k_sigaction { struct __new_sigaction sa; void __user *ka_restorer; @@ -228,15 +220,6 @@ void (*sa_restorer)(void); /* not used by Linux/SPARC yet */ }; -#ifdef __KERNEL__ -struct __old_sigaction32 { - unsigned sa_handler; - compat_old_sigset_t sa_mask; - unsigned int sa_flags; - unsigned sa_restorer; /* not used by Linux/SPARC yet */ -}; -#endif - typedef struct sigaltstack { void __user *ss_sp; int ss_flags; @@ -244,12 +227,6 @@ } stack_t; #ifdef __KERNEL__ -typedef struct sigaltstack32 { - u32 ss_sp; - int ss_flags; - compat_size_t ss_size; -} stack_t32; - struct signal_deliver_cookie { int restart_syscall; unsigned long orig_i0; === include/asm-sparc64/ttable.h 1.8 vs edited ==--- 1.8/include/asm-sparc64/ttable.h 2003-08-18 01:08:52 -07:00 +++ edited/include/asm-sparc64/ttable.h 2004-07-20 19:51:24 -07:00 @@ -123,7 +123,11 @@ #else #define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall) #endif +#ifdef CONFIG_COMPAT #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32) +#else +#define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110) +#endif #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64) #define GETCC_TRAP TRAP(getcc) #define SETCC_TRAP TRAP(setcc) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix sparc64 build with CONFIG_COMPAT=n @ 2004-07-21 3:03 ` David S. Miller 0 siblings, 0 replies; 8+ messages in thread From: David S. Miller @ 2004-07-21 3:03 UTC (permalink / raw) To: Roland Dreier; +Cc: ultralinux, linux-kernel On Fri, 09 Jul 2004 20:47:09 -0700 Roland Dreier <roland@topspin.com> wrote: > I'm including the simple fix inline and attaching the big fix. I like the big fix, and it allowed some cleanups too. I've munged your patch a bit and this is what I'm currently testing. Thanks a lot. ===== arch/sparc64/Kconfig 1.52 vs edited ===== --- 1.52/arch/sparc64/Kconfig 2004-05-24 10:09:14 -07:00 +++ edited/arch/sparc64/Kconfig 2004-07-20 19:49:30 -07:00 @@ -382,6 +382,7 @@ config SUNOS_EMUL bool "SunOS binary emulation" + depends on BINFMT_AOUT32 help This allows you to run most SunOS binaries. If you want to do this, say Y here and place appropriate files in /usr/gnemul/sunos. See @@ -391,7 +392,7 @@ config SOLARIS_EMUL tristate "Solaris binary emulation (EXPERIMENTAL)" - depends on EXPERIMENTAL + depends on SPARC32_COMPAT && EXPERIMENTAL help This is experimental code which will enable you to run (many) Solaris binaries on your SPARC Linux machine. ===== arch/sparc64/kernel/entry.S 1.34 vs edited ===== --- 1.34/arch/sparc64/kernel/entry.S 2004-06-20 12:32:28 -07:00 +++ edited/arch/sparc64/kernel/entry.S 2004-07-20 19:55:29 -07:00 @@ -1496,28 +1496,30 @@ /* SunOS's execv() call only specifies the argv argument, the * environment settings are the same as the calling processes. */ - .globl sunos_execv, sys_execve, sys32_execve + .globl sunos_execv sys_execve: sethi %hi(sparc_execve), %g1 ba,pt %xcc, execve_merge or %g1, %lo(sparc_execve), %g1 +#ifdef CONFIG_COMPAT + .globl sys_execve sunos_execv: stx %g0, [%sp + PTREGS_OFF + PT_V9_I2] + .globl sys32_execve sys32_execve: sethi %hi(sparc32_execve), %g1 or %g1, %lo(sparc32_execve), %g1 +#endif execve_merge: flushw jmpl %g1, %g0 add %sp, PTREGS_OFF, %o0 .globl sys_pipe, sys_sigpause, sys_nis_syscall - .globl sys_sigsuspend, sys_rt_sigsuspend, sys32_rt_sigsuspend + .globl sys_sigsuspend, sys_rt_sigsuspend .globl sys_rt_sigreturn - .globl sys32_sigreturn, sys32_rt_sigreturn - .globl sys32_execve, sys_ptrace - .globl sys_sigaltstack, sys32_sigaltstack - .globl sys32_sigstack + .globl sys_ptrace + .globl sys_sigaltstack .align 32 sys_pipe: ba,pt %xcc, sparc_pipe add %sp, PTREGS_OFF, %o0 @@ -1528,12 +1530,15 @@ add %sp, PTREGS_OFF, %o1 sys_sigaltstack:ba,pt %xcc, do_sigaltstack add %i6, STACK_BIAS, %o2 +#ifdef CONFIG_COMPAT + .globl sys32_sigstack sys32_sigstack: ba,pt %xcc, do_sys32_sigstack mov %i6, %o2 + .globl sys32_sigaltstack sys32_sigaltstack: ba,pt %xcc, do_sys32_sigaltstack mov %i6, %o2 - +#endif .align 32 sys_sigsuspend: add %sp, PTREGS_OFF, %o0 call do_sigsuspend @@ -1544,31 +1549,40 @@ call do_rt_sigsuspend add %o7, 1f-.-4, %o7 nop +#ifdef CONFIG_COMPAT + .globl sys32_rt_sigsuspend sys32_rt_sigsuspend: /* NOTE: %o0,%o1 have a correct value already */ srl %o0, 0, %o0 add %sp, PTREGS_OFF, %o2 call do_rt_sigsuspend32 add %o7, 1f-.-4, %o7 +#endif /* NOTE: %o0 has a correct value already */ sys_sigpause: add %sp, PTREGS_OFF, %o1 call do_sigpause add %o7, 1f-.-4, %o7 nop +#ifdef CONFIG_COMPAT + .globl sys32_sigreturn sys32_sigreturn: add %sp, PTREGS_OFF, %o0 call do_sigreturn32 add %o7, 1f-.-4, %o7 nop +#endif sys_rt_sigreturn: add %sp, PTREGS_OFF, %o0 call do_rt_sigreturn add %o7, 1f-.-4, %o7 nop +#ifdef CONFIG_COMPAT + .globl sys32_rt_sigreturn sys32_rt_sigreturn: add %sp, PTREGS_OFF, %o0 call do_rt_sigreturn32 add %o7, 1f-.-4, %o7 nop +#endif sys_ptrace: add %sp, PTREGS_OFF, %o0 call do_ptrace add %o7, 1f-.-4, %o7 ===== arch/sparc64/kernel/process.c 1.55 vs edited ===== --- 1.55/arch/sparc64/kernel/process.c 2004-06-01 21:42:33 -07:00 +++ edited/arch/sparc64/kernel/process.c 2004-07-20 19:13:30 -07:00 @@ -12,6 +12,7 @@ #include <stdarg.h> +#include <linux/config.h> #include <linux/errno.h> #include <linux/module.h> #include <linux/sched.h> @@ -588,10 +589,13 @@ clone_flags &= ~CLONE_IDLETASK; +#ifdef CONFIG_COMPAT if (test_thread_flag(TIF_32BIT)) { parent_tid_ptr = compat_ptr(regs->u_regs[UREG_I2]); child_tid_ptr = compat_ptr(regs->u_regs[UREG_I4]); - } else { + } else +#endif + { parent_tid_ptr = (int __user *) regs->u_regs[UREG_I2]; child_tid_ptr = (int __user *) regs->u_regs[UREG_I4]; } ===== arch/sparc64/kernel/signal32.c 1.38 vs edited ===== --- 1.38/arch/sparc64/kernel/signal32.c 2004-07-13 05:56:55 -07:00 +++ edited/arch/sparc64/kernel/signal32.c 2004-07-20 19:12:25 -07:00 @@ -59,6 +59,63 @@ unsigned int extramask[_COMPAT_NSIG_WORDS - 1]; }; +typedef union sigval32 { + int sival_int; + u32 sival_ptr; +} sigval_t32; + +typedef struct siginfo32 { + int si_signo; + int si_errno; + int si_code; + + union { + int _pad[SI_PAD_SIZE32]; + + /* kill() */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + } _kill; + + /* POSIX.1b timers */ + struct { + timer_t _tid; /* timer id */ + int _overrun; /* overrun count */ + sigval_t32 _sigval; /* same as below */ + int _sys_private; /* not to be passed to user */ + } _timer; + + /* POSIX.1b signals */ + struct { + compat_pid_t _pid; /* sender's pid */ + unsigned int _uid; /* sender's uid */ + sigval_t32 _sigval; + } _rt; + + /* SIGCHLD */ + struct { + compat_pid_t _pid; /* which child */ + unsigned int _uid; /* sender's uid */ + int _status; /* exit code */ + compat_clock_t _utime; + compat_clock_t _stime; + } _sigchld; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ + struct { + u32 _addr; /* faulting insn/memory ref. */ + int _trapno; + } _sigfault; + + /* SIGPOLL */ + struct { + int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ + int _fd; + } _sigpoll; + } _sifields; +} siginfo_t32; + /* * And the new one, intended to be used for Linux applications only * (we have enough in there to work with clone). @@ -76,6 +133,12 @@ __siginfo_fpu_t fpu_state; }; +typedef struct sigaltstack32 { + u32 ss_sp; + int ss_flags; + compat_size_t ss_size; +} stack_t32; + struct rt_signal_frame32 { struct sparc_stackf32 ss; siginfo_t32 info; @@ -95,7 +158,7 @@ #define NF_ALIGNEDSZ (((sizeof(struct new_signal_frame32) + 7) & (~7))) #define RT_ALIGNEDSZ (((sizeof(struct rt_signal_frame32) + 7) & (~7))) -int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from) +static int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from) { int err; @@ -1370,5 +1433,106 @@ __put_user(uoss.ss_flags, &((stack_t32 __user *)(long)uossa)->ss_flags) || __put_user(uoss.ss_size, &((stack_t32 __user *)(long)uossa)->ss_size))) return -EFAULT; + return ret; +} + +asmlinkage long sys32_rt_sigtimedwait(compat_sigset_t __user *uthese, + siginfo_t32 __user *uinfo, + struct compat_timespec __user *uts, + compat_size_t sigsetsize) +{ + int ret, sig; + sigset_t these; + compat_sigset_t these32; + struct timespec ts; + siginfo_t info; + long timeout = 0; + + /* XXX: Don't preclude handling different sized sigset_t's. */ + if (sigsetsize != sizeof(sigset_t)) + return -EINVAL; + + if (copy_from_user (&these32, uthese, sizeof(compat_sigset_t))) + return -EFAULT; + + switch (_NSIG_WORDS) { + case 4: these.sig[3] = these32.sig[6] | (((long)these32.sig[7]) << 32); + case 3: these.sig[2] = these32.sig[4] | (((long)these32.sig[5]) << 32); + case 2: these.sig[1] = these32.sig[2] | (((long)these32.sig[3]) << 32); + case 1: these.sig[0] = these32.sig[0] | (((long)these32.sig[1]) << 32); + } + + /* + * Invert the set of allowed signals to get those we + * want to block. + */ + sigdelsetmask(&these, sigmask(SIGKILL)|sigmask(SIGSTOP)); + signotset(&these); + + if (uts) { + if (get_compat_timespec(&ts, uts)) + return -EINVAL; + if (ts.tv_nsec >= 1000000000L || ts.tv_nsec < 0 + || ts.tv_sec < 0) + return -EINVAL; + } + + spin_lock_irq(¤t->sighand->siglock); + sig = dequeue_signal(current, &these, &info); + if (!sig) { + timeout = MAX_SCHEDULE_TIMEOUT; + if (uts) + timeout = (timespec_to_jiffies(&ts) + + (ts.tv_sec || ts.tv_nsec)); + + if (timeout) { + /* None ready -- temporarily unblock those we're + * interested while we are sleeping in so that we'll + * be awakened when they arrive. */ + current->real_blocked = current->blocked; + sigandsets(¤t->blocked, ¤t->blocked, &these); + recalc_sigpending(); + spin_unlock_irq(¤t->sighand->siglock); + + current->state = TASK_INTERRUPTIBLE; + timeout = schedule_timeout(timeout); + + spin_lock_irq(¤t->sighand->siglock); + sig = dequeue_signal(current, &these, &info); + current->blocked = current->real_blocked; + siginitset(¤t->real_blocked, 0); + recalc_sigpending(); + } + } + spin_unlock_irq(¤t->sighand->siglock); + + if (sig) { + ret = sig; + if (uinfo) { + if (copy_siginfo_to_user32(uinfo, &info)) + ret = -EFAULT; + } + } else { + ret = -EAGAIN; + if (timeout) + ret = -EINTR; + } + + return ret; +} + +asmlinkage long compat_sys_rt_sigqueueinfo(int pid, int sig, + siginfo_t32 __user *uinfo) +{ + siginfo_t info; + int ret; + mm_segment_t old_fs = get_fs(); + + if (copy_from_user (&info, uinfo, 3*sizeof(int)) || + copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE)) + return -EFAULT; + set_fs (KERNEL_DS); + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info); + set_fs (old_fs); return ret; } ===== arch/sparc64/kernel/sys_sparc32.c 1.103 vs edited ===== --- 1.103/arch/sparc64/kernel/sys_sparc32.c 2004-07-13 05:57:10 -07:00 +++ edited/arch/sparc64/kernel/sys_sparc32.c 2004-07-20 19:12:04 -07:00 @@ -1176,106 +1176,19 @@ return ret; } -asmlinkage long sys32_rt_sigtimedwait(compat_sigset_t __user *uthese, - siginfo_t32 __user *uinfo, - struct compat_timespec __user *uts, - compat_size_t sigsetsize) -{ - int ret, sig; - sigset_t these; - compat_sigset_t these32; - struct timespec ts; - siginfo_t info; - long timeout = 0; - - /* XXX: Don't preclude handling different sized sigset_t's. */ - if (sigsetsize != sizeof(sigset_t)) - return -EINVAL; - - if (copy_from_user (&these32, uthese, sizeof(compat_sigset_t))) - return -EFAULT; - - switch (_NSIG_WORDS) { - case 4: these.sig[3] = these32.sig[6] | (((long)these32.sig[7]) << 32); - case 3: these.sig[2] = these32.sig[4] | (((long)these32.sig[5]) << 32); - case 2: these.sig[1] = these32.sig[2] | (((long)these32.sig[3]) << 32); - case 1: these.sig[0] = these32.sig[0] | (((long)these32.sig[1]) << 32); - } - - /* - * Invert the set of allowed signals to get those we - * want to block. - */ - sigdelsetmask(&these, sigmask(SIGKILL)|sigmask(SIGSTOP)); - signotset(&these); - - if (uts) { - if (get_compat_timespec(&ts, uts)) - return -EINVAL; - if (ts.tv_nsec >= 1000000000L || ts.tv_nsec < 0 - || ts.tv_sec < 0) - return -EINVAL; - } - - spin_lock_irq(¤t->sighand->siglock); - sig = dequeue_signal(current, &these, &info); - if (!sig) { - timeout = MAX_SCHEDULE_TIMEOUT; - if (uts) - timeout = (timespec_to_jiffies(&ts) - + (ts.tv_sec || ts.tv_nsec)); - - if (timeout) { - /* None ready -- temporarily unblock those we're - * interested while we are sleeping in so that we'll - * be awakened when they arrive. */ - current->real_blocked = current->blocked; - sigandsets(¤t->blocked, ¤t->blocked, &these); - recalc_sigpending(); - spin_unlock_irq(¤t->sighand->siglock); - - current->state = TASK_INTERRUPTIBLE; - timeout = schedule_timeout(timeout); - - spin_lock_irq(¤t->sighand->siglock); - sig = dequeue_signal(current, &these, &info); - current->blocked = current->real_blocked; - siginitset(¤t->real_blocked, 0); - recalc_sigpending(); - } - } - spin_unlock_irq(¤t->sighand->siglock); - - if (sig) { - ret = sig; - if (uinfo) { - if (copy_siginfo_to_user32(uinfo, &info)) - ret = -EFAULT; - } - } else { - ret = -EAGAIN; - if (timeout) - ret = -EINTR; - } - - return ret; -} +struct __old_sigaction32 { + unsigned sa_handler; + compat_old_sigset_t sa_mask; + unsigned int sa_flags; + unsigned sa_restorer; /* not used by Linux/SPARC yet */ +}; -asmlinkage long compat_sys_rt_sigqueueinfo(int pid, int sig, - siginfo_t32 __user *uinfo) -{ - siginfo_t info; - int ret; - mm_segment_t old_fs = get_fs(); - - if (copy_from_user (&info, uinfo, 3*sizeof(int)) || - copy_from_user (info._sifields._pad, uinfo->_sifields._pad, SI_PAD_SIZE)) - return -EFAULT; - set_fs (KERNEL_DS); - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *) &info); - set_fs (old_fs); - return ret; -} +struct __new_sigaction32 { + unsigned sa_handler; + unsigned int sa_flags; + unsigned sa_restorer; /* not used by Linux/SPARC yet */ + compat_sigset_t sa_mask; +}; asmlinkage long compat_sys_sigaction(int sig, struct old_sigaction32 __user *act, struct old_sigaction32 __user *oact) @@ -1831,6 +1744,20 @@ sys_timer_create(clockid_t which_clock, struct sigevent __user *timer_event_spec, timer_t __user *created_timer_id); + +typedef struct sigevent32 { + sigval_t32 sigev_value; + int sigev_signo; + int sigev_notify; + union { + int _pad[SIGEV_PAD_SIZE32]; + + struct { + u32 _function; + u32 _attribute; /* really pthread_attr_t */ + } _sigev_thread; + } _sigev_un; +} sigevent_t32; long sys32_timer_create(u32 clock, struct sigevent32 __user *se32, ===== arch/sparc64/kernel/systbls.S 1.60 vs edited ===== --- 1.60/arch/sparc64/kernel/systbls.S 2004-06-01 21:42:33 -07:00 +++ edited/arch/sparc64/kernel/systbls.S 2004-07-20 19:56:06 -07:00 @@ -15,6 +15,7 @@ .text .align 4 +#ifdef CONFIG_COMPAT /* First, the 32-bit Linux native syscall table. */ .globl sys_call_table32 @@ -77,6 +78,8 @@ .word sys_mq_timedsend, sys_mq_timedreceive, compat_sys_mq_notify, compat_sys_mq_getsetattr, sys_ni_syscall /*280*/ .word sys_ni_syscall, sys_ni_syscall, sys_ni_syscall +#endif /* CONFIG_COMPAT */ + /* Now the 64-bit native Linux syscall table. */ .align 4 @@ -85,7 +88,7 @@ sys_call_table: /*0*/ .word sys_restart_syscall, sparc_exit, sys_fork, sys_read, sys_write /*5*/ .word sys_open, sys_close, sys_wait4, sys_creat, sys_link -/*10*/ .word sys_unlink, sunos_execv, sys_chdir, sys_chown, sys_mknod +/*10*/ .word sys_unlink, sys_nis_syscall, sys_chdir, sys_chown, sys_mknod /*15*/ .word sys_chmod, sys_lchown, sparc_brk, sys_perfctr, sys_lseek /*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid /*25*/ .word sys_nis_syscall, sys_ptrace, sys_alarm, sys_sigaltstack, sys_nis_syscall ===== include/asm-sparc64/siginfo.h 1.15 vs edited ===== --- 1.15/include/asm-sparc64/siginfo.h 2004-05-31 16:25:29 -07:00 +++ edited/include/asm-sparc64/siginfo.h 2004-07-20 19:12:32 -07:00 @@ -12,69 +12,6 @@ #include <asm-generic/siginfo.h> -#ifdef __KERNEL__ - -#include <linux/compat.h> - -typedef union sigval32 { - int sival_int; - u32 sival_ptr; -} sigval_t32; - -typedef struct siginfo32 { - int si_signo; - int si_errno; - int si_code; - - union { - int _pad[SI_PAD_SIZE32]; - - /* kill() */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - } _kill; - - /* POSIX.1b timers */ - struct { - timer_t _tid; /* timer id */ - int _overrun; /* overrun count */ - sigval_t32 _sigval; /* same as below */ - int _sys_private; /* not to be passed to user */ - } _timer; - - /* POSIX.1b signals */ - struct { - compat_pid_t _pid; /* sender's pid */ - unsigned int _uid; /* sender's uid */ - sigval_t32 _sigval; - } _rt; - - /* SIGCHLD */ - struct { - compat_pid_t _pid; /* which child */ - unsigned int _uid; /* sender's uid */ - int _status; /* exit code */ - compat_clock_t _utime; - compat_clock_t _stime; - } _sigchld; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */ - struct { - u32 _addr; /* faulting insn/memory ref. */ - int _trapno; - } _sigfault; - - /* SIGPOLL */ - struct { - int _band; /* POLL_IN, POLL_OUT, POLL_MSG */ - int _fd; - } _sigpoll; - } _sifields; -} siginfo_t32; - -#endif /* __KERNEL__ */ - #define SI_NOINFO 32767 /* no information in siginfo_t */ /* @@ -82,25 +19,5 @@ */ #define EMT_TAGOVF (__SI_FAULT|1) /* tag overflow */ #define NSIGEMT 1 - -#ifdef __KERNEL__ - -typedef struct sigevent32 { - sigval_t32 sigev_value; - int sigev_signo; - int sigev_notify; - union { - int _pad[SIGEV_PAD_SIZE32]; - - struct { - u32 _function; - u32 _attribute; /* really pthread_attr_t */ - } _sigev_thread; - } _sigev_un; -} sigevent_t32; - -extern int copy_siginfo_to_user32(siginfo_t32 __user *to, siginfo_t *from); - -#endif /* __KERNEL__ */ #endif ===== include/asm-sparc64/signal.h 1.14 vs edited ===== --- 1.14/include/asm-sparc64/signal.h 2004-07-13 05:51:54 -07:00 +++ edited/include/asm-sparc64/signal.h 2004-07-20 19:09:41 -07:00 @@ -8,7 +8,6 @@ #ifndef __ASSEMBLY__ #include <linux/personality.h> #include <linux/types.h> -#include <linux/compat.h> #endif #endif @@ -208,13 +207,6 @@ }; #ifdef __KERNEL__ -struct __new_sigaction32 { - unsigned sa_handler; - unsigned int sa_flags; - unsigned sa_restorer; /* not used by Linux/SPARC yet */ - compat_sigset_t sa_mask; -}; - struct k_sigaction { struct __new_sigaction sa; void __user *ka_restorer; @@ -228,15 +220,6 @@ void (*sa_restorer)(void); /* not used by Linux/SPARC yet */ }; -#ifdef __KERNEL__ -struct __old_sigaction32 { - unsigned sa_handler; - compat_old_sigset_t sa_mask; - unsigned int sa_flags; - unsigned sa_restorer; /* not used by Linux/SPARC yet */ -}; -#endif - typedef struct sigaltstack { void __user *ss_sp; int ss_flags; @@ -244,12 +227,6 @@ } stack_t; #ifdef __KERNEL__ -typedef struct sigaltstack32 { - u32 ss_sp; - int ss_flags; - compat_size_t ss_size; -} stack_t32; - struct signal_deliver_cookie { int restart_syscall; unsigned long orig_i0; ===== include/asm-sparc64/ttable.h 1.8 vs edited ===== --- 1.8/include/asm-sparc64/ttable.h 2003-08-18 01:08:52 -07:00 +++ edited/include/asm-sparc64/ttable.h 2004-07-20 19:51:24 -07:00 @@ -123,7 +123,11 @@ #else #define SUNOS_SYSCALL_TRAP TRAP(sunos_syscall) #endif +#ifdef CONFIG_COMPAT #define LINUX_32BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall32, sys_call_table32) +#else +#define LINUX_32BIT_SYSCALL_TRAP BTRAP(0x110) +#endif #define LINUX_64BIT_SYSCALL_TRAP SYSCALL_TRAP(linux_sparc_syscall, sys_call_table64) #define GETCC_TRAP TRAP(getcc) #define SETCC_TRAP TRAP(setcc) ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix sparc64 build with CONFIG_COMPAT=n 2004-07-21 3:03 ` David S. Miller @ 2004-07-21 20:43 ` Roland Dreier -1 siblings, 0 replies; 8+ messages in thread From: Roland Dreier @ 2004-07-21 20:43 UTC (permalink / raw) To: David S. Miller; +Cc: ultralinux, linux-kernel David> I like the big fix, and it allowed some cleanups too. I've David> munged your patch a bit and this is what I'm currently David> testing. Cool, my allnoconfig compile tests thank you. Just out of curiousity, is there any practical use for sparc64 without CONFIG_COMPAT? My impression was that everyone used 32-bit userspace (except for possibly a few executables). - R. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix sparc64 build with CONFIG_COMPAT=n @ 2004-07-21 20:43 ` Roland Dreier 0 siblings, 0 replies; 8+ messages in thread From: Roland Dreier @ 2004-07-21 20:43 UTC (permalink / raw) To: David S. Miller; +Cc: ultralinux, linux-kernel David> I like the big fix, and it allowed some cleanups too. I've David> munged your patch a bit and this is what I'm currently David> testing. Cool, my allnoconfig compile tests thank you. Just out of curiousity, is there any practical use for sparc64 without CONFIG_COMPAT? My impression was that everyone used 32-bit userspace (except for possibly a few executables). - R. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix sparc64 build with CONFIG_COMPAT=n 2004-07-21 20:43 ` Roland Dreier @ 2004-07-21 21:47 ` David S. Miller -1 siblings, 0 replies; 8+ messages in thread From: David S. Miller @ 2004-07-21 21:47 UTC (permalink / raw) To: Roland Dreier; +Cc: ultralinux, linux-kernel On Wed, 21 Jul 2004 13:43:53 -0700 Roland Dreier <roland@topspin.com> wrote: > Just out of curiousity, is there any practical use for sparc64 without > CONFIG_COMPAT? My impression was that everyone used 32-bit userspace > (except for possibly a few executables). Someone could build a 64-bit pure system. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] Fix sparc64 build with CONFIG_COMPAT=n @ 2004-07-21 21:47 ` David S. Miller 0 siblings, 0 replies; 8+ messages in thread From: David S. Miller @ 2004-07-21 21:47 UTC (permalink / raw) To: Roland Dreier; +Cc: ultralinux, linux-kernel On Wed, 21 Jul 2004 13:43:53 -0700 Roland Dreier <roland@topspin.com> wrote: > Just out of curiousity, is there any practical use for sparc64 without > CONFIG_COMPAT? My impression was that everyone used 32-bit userspace > (except for possibly a few executables). Someone could build a 64-bit pure system. ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-07-21 21:51 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2004-07-10 3:47 [PATCH] Fix sparc64 build with CONFIG_COMPAT=n Roland Dreier 2004-07-10 3:47 ` Roland Dreier 2004-07-21 3:03 ` David S. Miller 2004-07-21 3:03 ` David S. Miller 2004-07-21 20:43 ` Roland Dreier 2004-07-21 20:43 ` Roland Dreier 2004-07-21 21:47 ` David S. Miller 2004-07-21 21:47 ` David S. Miller
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.