Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/compat 8-byte objects on i386 or arm-oabi are aligned in...



details:   https://anonhg.NetBSD.org/src/rev/33e00a1c5c8c
branches:  trunk
changeset: 461188:33e00a1c5c8c
user:      rin <rin%NetBSD.org@localhost>
date:      Mon Nov 18 12:06:26 2019 +0000

description:
8-byte objects on i386 or arm-oabi are aligned in 4-byte boundary.
Therefore, we must use __attribute__((__aligned__(4))) for them.
netbsd32_{,u}int64 are provided for this purpose. However, we
cannot use it in <compat/sys/siginfo.h> due to circular dependency
b/w <machine/netbsd32_machdep.h>.

In order to distangle it, we choose here to have a duplicate type,
netbsd32_siginfo_uint64, in <compat/sys/siginfo.h>. The equivalence
with netbsd32_uint64 is asserted in <compat/netbsd32/netbsd32.h>.

Now, gdb for i386 works again on amd64 kernel.

Based on patch provided by kamil. Thanks!

XXX
pullup to netbsd-9

diffstat:

 sys/compat/netbsd32/netbsd32.h |   6 +++++-
 sys/compat/sys/siginfo.h       |  13 +++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diffs (54 lines):

diff -r 340e5bbbe864 -r 33e00a1c5c8c sys/compat/netbsd32/netbsd32.h
--- a/sys/compat/netbsd32/netbsd32.h    Mon Nov 18 11:01:41 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32.h    Mon Nov 18 12:06:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32.h,v 1.130 2019/11/18 04:17:08 rin Exp $       */
+/*     $NetBSD: netbsd32.h,v 1.131 2019/11/18 12:06:26 rin Exp $       */
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2015 Matthew R. Green
@@ -162,6 +162,10 @@
 typedef uint64_t netbsd32_uint64 NETBSD32_INT64_ALIGN;
 #undef NETBSD32_INT64_ALIGN
 
+/* Type used in siginfo, avoids circular dependencies between headers. */
+CTASSERT(sizeof(netbsd32_uint64) == sizeof(netbsd32_siginfo_uint64));
+CTASSERT(__alignof__(netbsd32_uint64) == __alignof__(netbsd32_siginfo_uint64));
+
 /*
  * all pointers are netbsd32_pointer_t (defined in <machine/netbsd32_machdep.h>)
  */
diff -r 340e5bbbe864 -r 33e00a1c5c8c sys/compat/sys/siginfo.h
--- a/sys/compat/sys/siginfo.h  Mon Nov 18 11:01:41 2019 +0000
+++ b/sys/compat/sys/siginfo.h  Mon Nov 18 12:06:26 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: siginfo.h,v 1.8 2019/09/30 21:13:33 kamil Exp $         */
+/*     $NetBSD: siginfo.h,v 1.9 2019/11/18 12:06:26 rin Exp $   */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -34,6 +34,15 @@
 
 #ifdef _KERNEL
 
+/* Avoids circular dependency with machine/netbsd32_machdep.h */
+#if defined(__x86_64__) || (defined(__arm__) && defined(__ARM_EABI__))
+#define NETBSD32_SIGINFO_UINT64_ALIGN __attribute__((__aligned__(4)))
+#else
+#define NETBSD32_SIGINFO_UINT64_ALIGN __attribute__((__aligned__(8)))
+#endif
+typedef uint64_t netbsd32_siginfo_uint64 NETBSD32_SIGINFO_UINT64_ALIGN;
+#undef NETBSD32_SIGINFO_UINT64_ALIGN
+
 typedef union sigval32 {
        int sival_int;
        uint32_t sival_ptr;
@@ -73,7 +82,7 @@
                        int     _sysnum;
                        int     _retval[2];
                        int     _error;
-                       uint64_t _args[8]; /* SYS_MAXSYSARGS */
+                       netbsd32_siginfo_uint64 _args[8]; /* SYS_MAXSYSARGS */
                } _syscall;
 
                struct {



Home | Main Index | Thread Index | Old Index