From: James Bottomley <James.Bottomley@steeleye.com>
To: PARISC list <parisc-linux@lists.parisc-linux.org>
Cc: parisc-linux-cvs@lists.parisc-linux.org
Subject: [parisc-linux] Re: [parisc-linux-cvs] linux-2.6 jejb
Date: 24 Sep 2003 13:01:16 -0500 [thread overview]
Message-ID: <1064426477.1781.8.camel@mulgrave> (raw)
In-Reply-To: <20030924175431.D51BC49408B@palinux.hppa>
On Wed, 2003-09-24 at 12:54, James Bottomley wrote:
> CVSROOT: /var/cvs
> Module name: linux-2.6
> Changes by: jejb 03/09/24 11:54:31
>
> Modified files:
> . : Makefile
> arch/parisc/kernel: signal.c
> include/asm-parisc: rt_sigframe.h
>
> Log message:
> Make signals work with ELF64 binaries
>
> For those who want to try this at home, there's a mini test suite at
> http://www.parisc-linux.org/~jejb/64bit.tar.gz
>
> NOTE: The signal handler has become really ugly. However, since it's
> completely broken for context returns with ELF32 binaries on ELF64 kernels
> there didn't seem to be a lot of point making it nicer until we tackle that
> problem as well
Index: arch/parisc/kernel/signal.c
===================================================================
RCS file: /var/cvs/linux-2.6/arch/parisc/kernel/signal.c,v
retrieving revision 1.10
diff -u -r1.10 signal.c
--- arch/parisc/kernel/signal.c 19 Sep 2003 01:03:56 -0000 1.10
+++ arch/parisc/kernel/signal.c 24 Sep 2003 17:50:48 -0000
@@ -26,6 +26,7 @@
#include <linux/stddef.h>
#include <linux/compat.h>
#include <linux/elf.h>
+#include <linux/personality.h>
#include <asm/ucontext.h>
#include <asm/rt_sigframe.h>
#include <asm/uaccess.h>
@@ -170,11 +171,17 @@
struct rt_sigframe *frame;
struct siginfo si;
sigset_t set;
- unsigned long usp = regs->gr[30];
+ unsigned long usp = (regs->gr[30] & ~(0x01UL));
+ unsigned long sigframe_size = PARISC_RT_SIGFRAME_SIZE;
+#ifdef __LP64__
+ if(personality(current->personality) == PER_LINUX32)
+ sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
+#endif
+
/* Unwind the user stack to get the rt_sigframe structure. */
frame = (struct rt_sigframe *)
- (usp - PARISC_RT_SIGFRAME_SIZE);
+ (usp - sigframe_size);
DBG(("in sys_rt_sigreturn, frame is %p\n", frame));
if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
@@ -276,11 +283,11 @@
{
struct rt_sigframe *frame;
unsigned long rp, usp;
- Elf32_Addr haddr;
+ unsigned long haddr, sigframe_size;
struct siginfo si;
int err = 0;
- usp = regs->gr[30];
+ usp = (regs->gr[30] & ~(0x01UL));
frame = get_sigframe(ka, usp, sizeof(*frame));
DBG(("setup_rt_frame 1: frame %p info %p\n", frame, info));
@@ -325,25 +332,59 @@
haddr = A(ka->sa.sa_handler);
/* The sa_handler may be a pointer to a function descriptor */
- if (haddr & PA_PLABEL_FDESC) {
- Elf32_Fdesc fdesc;
- Elf32_Fdesc *ufdesc = (Elf32_Fdesc *)A(haddr & ~3);
+#ifdef __LP64__
+ if(personality(current->personality) == PER_LINUX32) {
+#endif
+ if (haddr & PA_PLABEL_FDESC) {
+ Elf32_Fdesc fdesc;
+ Elf32_Fdesc *ufdesc = (Elf32_Fdesc *)A(haddr & ~3);
- err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc));
+ err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc));
+
+ if (err)
+ goto give_sigsegv;
+ haddr = fdesc.addr;
+ regs->gr[19] = fdesc.gp;
+ }
+#ifdef __LP64__
+ } else {
+ Elf64_Fdesc fdesc;
+ Elf64_Fdesc *ufdesc = (Elf64_Fdesc *)A(haddr & ~3);
+
+ err = __copy_from_user(&fdesc, ufdesc, sizeof(fdesc));
+
if (err)
goto give_sigsegv;
-
+
haddr = fdesc.addr;
regs->gr[19] = fdesc.gp;
+ DBG(("64 bit signal, exe=%#lx, r19=%#lx, in_syscall=%d\n",
+ haddr, regs->gr[19], in_syscall));
}
+#endif
/* The syscall return path will create IAOQ values from r31.
*/
- if (in_syscall)
+ sigframe_size = PARISC_RT_SIGFRAME_SIZE;
+#ifdef __LP64__
+ if(personality(current->personality) == PER_LINUX32)
+ sigframe_size = PARISC_RT_SIGFRAME_SIZE32;
+#endif
+ if (in_syscall) {
regs->gr[31] = haddr;
- else {
- regs->gr[0] = USER_PSW;
+#ifdef __LP64__
+ if(personality(current->personality) == PER_LINUX)
+ sigframe_size |= 1;
+#endif
+ } else {
+ unsigned long psw = USER_PSW;
+#ifdef __LP64__
+ if(personality(current->personality) == PER_LINUX)
+ psw |= PSW_W;
+#endif
+
+ regs->gr[0] = psw;
regs->iaoq[0] = haddr | 3;
regs->iaoq[1] = regs->iaoq[0] + 4;
}
@@ -352,11 +393,13 @@
regs->gr[26] = sig; /* signal number */
regs->gr[25] = A(&frame->info); /* siginfo pointer */
regs->gr[24] = A(&frame->uc); /* ucontext pointer */
+
DBG(("making sigreturn frame: %#lx + %#x = %#lx\n",
- regs->gr[30], PARISC_RT_SIGFRAME_SIZE,
- regs->gr[30] + PARISC_RT_SIGFRAME_SIZE));
+ regs->gr[30], sigframe_size,
+ regs->gr[30] + sigframe_size));
/* Raise the user stack pointer to make a proper call frame. */
- regs->gr[30] = (A(frame) + PARISC_RT_SIGFRAME_SIZE);
+ regs->gr[30] = (A(frame) + sigframe_size);
+
DBG(("SIG deliver (%s:%d): frame=0x%p sp=%#lx iaoq=%#lx/%#lx rp=%#lx\n",
current->comm, current->pid, frame, regs->gr[30],
Index: include/asm-parisc/rt_sigframe.h
===================================================================
RCS file: /var/cvs/linux-2.6/include/asm-parisc/rt_sigframe.h,v
retrieving revision 1.1
diff -u -r1.1 rt_sigframe.h
--- include/asm-parisc/rt_sigframe.h 29 Jul 2003 17:02:04 -0000 1.1
+++ include/asm-parisc/rt_sigframe.h 24 Sep 2003 17:51:16 -0000
@@ -13,7 +13,20 @@
* which Linux/parisc uses is sp-20 for the saved return pointer...)
* Then, the stack pointer must be rounded to a cache line (64 bytes).
*/
+#define SIGFRAME32 64
+#define FUNCTIONCALLFRAME32 48
+#define PARISC_RT_SIGFRAME_SIZE32 \
+ (((sizeof(struct rt_sigframe) + FUNCTIONCALLFRAME32) + SIGFRAME32) & -SIGFRAME32)
+
+#ifdef __LP64__
+#define SIGFRAME 128
+#define FUNCTIONCALLFRAME 96
#define PARISC_RT_SIGFRAME_SIZE \
- (((sizeof(struct rt_sigframe) + 48) + 63) & -64)
+ (((sizeof(struct rt_sigframe) + FUNCTIONCALLFRAME) + SIGFRAME) & -SIGFRAME)
+#else
+#define SIGFRAME SIGFRAME32
+#define FUNCTIONCALLFRAME FUNCTIONCALLFRAME32
+#define PARISC_RT_SIGFRAME_SIZE PARISC_RT_SIGFRAME_SIZE32
+#endif
#endif
next parent reply other threads:[~2003-09-24 18:01 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20030924175431.D51BC49408B@palinux.hppa>
2003-09-24 18:01 ` James Bottomley [this message]
[not found] <20040505204811.27F0C4945E4@palinux.hppa>
2004-05-05 20:50 ` [parisc-linux] Re: [parisc-linux-cvs] linux-2.6 jejb James Bottomley
2004-05-06 5:05 ` Randolph Chung
2004-05-06 5:22 ` Randolph Chung
2004-05-06 9:33 ` M. Grabert
2004-05-06 13:25 ` Kyle McMartin
[not found] <20040502161601.DC7C24945C7@palinux.hppa>
2004-05-03 20:51 ` James Bottomley
[not found] <20040501200312.40BB74945E1@palinux.hppa>
2004-05-01 20:09 ` James Bottomley
2004-05-03 8:57 ` Joel Soete
[not found] <20040501160556.D07DC4945CA@palinux.hppa>
2004-05-01 16:13 ` James Bottomley
[not found] <20040430162037.9D2B94945CD@palinux.hppa>
2004-04-30 16:25 ` James Bottomley
[not found] <20040427171140.706074945BD@palinux.hppa>
2004-04-27 17:15 ` James Bottomley
[not found] <20040425145051.10F5C4942B8@palinux.hppa>
2004-04-25 14:55 ` James Bottomley
[not found] <20040414174535.81173494194@palinux.hppa>
2004-04-14 17:53 ` James Bottomley
[not found] <20040412154800.D31F6494194@palinux.hppa>
2004-04-12 15:55 ` James Bottomley
[not found] <20040407004901.031D3494194@palinux.hppa>
2004-04-07 0:54 ` James Bottomley
2004-04-08 6:15 ` Joel Soete
2004-04-08 12:36 ` James Bottomley
[not found] <20040406213446.CB675494194@palinux.hppa>
2004-04-06 21:37 ` James Bottomley
[not found] <20040405174131.84BF1494194@palinux.hppa>
2004-04-06 13:21 ` Carlos O'Donell
2004-04-06 14:18 ` James Bottomley
2004-04-06 15:40 ` Randolph Chung
[not found] <20040405024740.9330F494194@palinux.hppa>
2004-04-05 2:49 ` James Bottomley
2004-04-05 2:54 ` James Bottomley
[not found] <20040320210116.7A727494553@palinux.hppa>
2004-03-20 21:04 ` James Bottomley
2004-03-20 21:10 ` Helge Deller
2004-03-20 21:13 ` Helge Deller
[not found] <20040228212407.DB126494190@palinux.hppa>
2004-02-28 22:21 ` Joel Soete
2004-02-28 22:42 ` James Bottomley
2004-02-29 9:39 ` Joel Soete
2004-03-04 16:39 ` Joel Soete
2004-02-06 7:31 [parisc-linux] " Joel Soete
2004-02-06 17:50 ` Grant Grundler
2004-02-06 18:06 ` bame
2004-02-06 19:16 ` Randolph Chung
2004-02-06 17:08 ` Joel Soete
2004-02-07 6:40 ` Randolph Chung
2004-02-09 7:26 ` Joel Soete
[not found] <20040204182455.1CC11494191@palinux.hppa>
2004-02-05 9:20 ` [parisc-linux] " Randolph Chung
2004-02-05 15:19 ` James Bottomley
2004-02-05 15:29 ` [parisc-linux] " Joel Soete
2004-02-05 20:31 ` Randolph Chung
2004-02-05 18:49 ` Joel Soete
[not found] <20040113155603.CBCC249425A@palinux.hppa>
2004-01-13 15:58 ` [parisc-linux] " James Bottomley
[not found] <20030919010356.148684940A4@palinux.hppa>
2003-09-19 1:06 ` James Bottomley
2003-09-19 11:24 ` Randolph Chung
2003-09-19 14:02 ` James Bottomley
2003-09-19 18:24 ` Jim Hull
[not found] <20030903200300.8B7B7494064@palinux.hppa>
2003-09-03 20:07 ` James Bottomley
[not found] <20030903165113.138BF494064@palinux.hppa>
2003-09-03 16:56 ` James Bottomley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1064426477.1781.8.camel@mulgrave \
--to=james.bottomley@steeleye.com \
--cc=parisc-linux-cvs@lists.parisc-linux.org \
--cc=parisc-linux@lists.parisc-linux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox