All of lore.kernel.org
 help / color / mirror / Atom feed
* struct sigcontext for N32 userland
@ 2007-02-12 15:51 Atsushi Nemoto
  2007-02-13  8:27 ` Franck Bui-Huu
  0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2007-02-12 15:51 UTC (permalink / raw)
  To: linux-mips

If N32 userland refers asm-mips/sigcontext.h, struct sigcontext cause
some troubles.

#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32

struct sigcontext {
	unsigned long	sc_regs[32];
...


The kernel use 64-bit for sc_regs[0], and both N32/N64 userland
expects it was 64-bit.  But size of 'long' on N32 is actually 32-bit.
So this definition make some confusion.

glibc has its own sigcontext.h and it uses 'unsigned long long' for
sc_regs, so no real problem with glibc.

Should we use 'unsigned long long' here as glibc does?

Or should we have separate definition just for N32 userland?  (kernel
does not use #if _MIPS_SIM == _MIPS_SIM_NABI32 block anyway since
kernel itself is compiled as n64)

Or should we make struct sigcontext private to kernel and do not
export for userland at all?

Or ... do nothing?

---
Atsushi Nemoto

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: struct sigcontext for N32 userland
  2007-02-12 15:51 struct sigcontext for N32 userland Atsushi Nemoto
@ 2007-02-13  8:27 ` Franck Bui-Huu
  2007-02-13 11:38   ` Ralf Baechle
  0 siblings, 1 reply; 5+ messages in thread
From: Franck Bui-Huu @ 2007-02-13  8:27 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-mips

On 2/12/07, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> If N32 userland refers asm-mips/sigcontext.h, struct sigcontext cause
> some troubles.
>
> #if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
>
> struct sigcontext {
>         unsigned long   sc_regs[32];
> ...
>
>
> The kernel use 64-bit for sc_regs[0], and both N32/N64 userland
> expects it was 64-bit.  But size of 'long' on N32 is actually 32-bit.
> So this definition make some confusion.
>
> glibc has its own sigcontext.h and it uses 'unsigned long long' for
> sc_regs, so no real problem with glibc.
>

Just out of curiosity, for what purpose does the glibc use sigcontext ?


-- 
               Franck

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: struct sigcontext for N32 userland
  2007-02-13  8:27 ` Franck Bui-Huu
@ 2007-02-13 11:38   ` Ralf Baechle
  2007-02-17 15:12     ` Atsushi Nemoto
  0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2007-02-13 11:38 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: Atsushi Nemoto, linux-mips

On Tue, Feb 13, 2007 at 09:27:20AM +0100, Franck Bui-Huu wrote:

> On 2/12/07, Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> >If N32 userland refers asm-mips/sigcontext.h, struct sigcontext cause
> >some troubles.
> >
> >#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
> >
> >struct sigcontext {
> >        unsigned long   sc_regs[32];
> >...
> >
> >
> >The kernel use 64-bit for sc_regs[0], and both N32/N64 userland
> >expects it was 64-bit.  But size of 'long' on N32 is actually 32-bit.
> >So this definition make some confusion.
> >
> >glibc has its own sigcontext.h and it uses 'unsigned long long' for
> >sc_regs, so no real problem with glibc.

Looks like a case for __u32, __u64 then.

> Just out of curiosity, for what purpose does the glibc use sigcontext ?

Afair it doesn't use sigcontext itself but makes it available to
applications through <signal.h>.  Typical users are virtual machines,
JITs, debuggers, user space virtual memory.

  Ralf

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: struct sigcontext for N32 userland
  2007-02-13 11:38   ` Ralf Baechle
@ 2007-02-17 15:12     ` Atsushi Nemoto
  2007-02-19 15:38       ` Ralf Baechle
  0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2007-02-17 15:12 UTC (permalink / raw)
  To: ralf; +Cc: vagabon.xyz, linux-mips

On Tue, 13 Feb 2007 11:38:26 +0000, Ralf Baechle <ralf@linux-mips.org> wrote:
> > >The kernel use 64-bit for sc_regs[0], and both N32/N64 userland
> > >expects it was 64-bit.  But size of 'long' on N32 is actually 32-bit.
> > >So this definition make some confusion.
> > >
> > >glibc has its own sigcontext.h and it uses 'unsigned long long' for
> > >sc_regs, so no real problem with glibc.
> 
> Looks like a case for __u32, __u64 then.

Then how about this?

Subject: export proper struct sigcontext to userland on N32

The kernel use 64-bit for sc_regs[0], and both N32/N64 userland
expects it was 64-bit.  But size of 'long' on N32 is actually 32-bit.
So this definition make some confusion.  Use __u32 and __u64 for
N32/N64 sigcontext to get rid of this confusion.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/include/asm-mips/sigcontext.h b/include/asm-mips/sigcontext.h
index 3c175a7..9729474 100644
--- a/include/asm-mips/sigcontext.h
+++ b/include/asm-mips/sigcontext.h
@@ -42,6 +42,7 @@ struct sigcontext {
 
 #if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32
 
+#include <linux/posix_types.h>
 /*
  * Keep this struct definition in sync with the sigcontext fragment
  * in arch/mips/tools/offset.c
@@ -53,27 +54,25 @@ struct sigcontext {
  * entries, add sc_dsp and sc_reserved for padding.  No prisoners.
  */
 struct sigcontext {
-	unsigned long	sc_regs[32];
-	unsigned long	sc_fpregs[32];
-	unsigned long	sc_mdhi;
-	unsigned long	sc_hi1;
-	unsigned long	sc_hi2;
-	unsigned long	sc_hi3;
-	unsigned long	sc_mdlo;
-	unsigned long	sc_lo1;
-	unsigned long	sc_lo2;
-	unsigned long	sc_lo3;
-	unsigned long	sc_pc;
-	unsigned int	sc_fpc_csr;
-	unsigned int	sc_used_math;
-	unsigned int	sc_dsp;
-	unsigned int	sc_reserved;
+	__u64	sc_regs[32];
+	__u64	sc_fpregs[32];
+	__u64	sc_mdhi;
+	__u64	sc_hi1;
+	__u64	sc_hi2;
+	__u64	sc_hi3;
+	__u64	sc_mdlo;
+	__u64	sc_lo1;
+	__u64	sc_lo2;
+	__u64	sc_lo3;
+	__u64	sc_pc;
+	__u32	sc_fpc_csr;
+	__u32	sc_used_math;
+	__u32	sc_dsp;
+	__u32	sc_reserved;
 };
 
 #ifdef __KERNEL__
 
-#include <linux/posix_types.h>
-
 struct sigcontext32 {
 	__u32		sc_regmask;	/* Unused */
 	__u32		sc_status;	/* Unused */

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: struct sigcontext for N32 userland
  2007-02-17 15:12     ` Atsushi Nemoto
@ 2007-02-19 15:38       ` Ralf Baechle
  0 siblings, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2007-02-19 15:38 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: vagabon.xyz, linux-mips

On Sun, Feb 18, 2007 at 12:12:57AM +0900, Atsushi Nemoto wrote:

> > Looks like a case for __u32, __u64 then.
> 
> Then how about this?
> 
> Subject: export proper struct sigcontext to userland on N32

Looks good, applied.

Thanks,

  Ralf

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-02-19 15:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-12 15:51 struct sigcontext for N32 userland Atsushi Nemoto
2007-02-13  8:27 ` Franck Bui-Huu
2007-02-13 11:38   ` Ralf Baechle
2007-02-17 15:12     ` Atsushi Nemoto
2007-02-19 15:38       ` Ralf Baechle

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.