2019-07-03 00:31:33

by Alistair Francis

[permalink] [raw]
Subject: [PATCH 0/2] RISC-V: Handle the siginfo_t offset problem

In the RISC-V 32-bit glibc port [1] the siginfo_t struct in the kernel
doesn't line up with the struct in glibc. In glibc world the _sifields
union is 8 byte alligned (although I can't figure out why) while in the
kernel wordl the _sifields union is 4 bytes alligned. This results in
information being lost in the waitid syscall.

This doesn't seem to be a great fix, but it is somewhat similar to what
x32 does (which has 64-bit time_t like RV32) and I can't figure out why
the two allignments are different.

1: https://github.com/alistair23/glibc/commits/alistair/rv32.next

Alistair Francis (2):
uapi/asm-generic: Allow defining a custom __SIGINFO struct
riscv/include/uapi: Define a custom __SIGINFO struct for RV32

arch/riscv/include/uapi/asm/siginfo.h | 32 +++++++++++++++++++++++++++
include/uapi/asm-generic/siginfo.h | 32 ++++++++++++++-------------
2 files changed, 49 insertions(+), 15 deletions(-)
create mode 100644 arch/riscv/include/uapi/asm/siginfo.h

--
2.22.0


2019-07-03 00:32:12

by Alistair Francis

[permalink] [raw]
Subject: [PATCH 1/2] uapi/asm-generic: Allow defining a custom __SIGINFO struct

Allow defining a custom __SIGINFO struct. This allows architectures to
apply their own padding and allignment requirements to the struct. This
is similar to the __ARCH_SI_ATTRIBUTES #define that already exists, but
applies to the __SIGINFO struct instead of the siginfo_t struct.

Signed-off-by: Alistair Francis <[email protected]>
---
include/uapi/asm-generic/siginfo.h | 32 ++++++++++++++++--------------
1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/include/uapi/asm-generic/siginfo.h b/include/uapi/asm-generic/siginfo.h
index cb3d6c267181..09b0a1abac14 100644
--- a/include/uapi/asm-generic/siginfo.h
+++ b/include/uapi/asm-generic/siginfo.h
@@ -108,23 +108,25 @@ union __sifields {
} _sigsys;
};

-#ifndef __ARCH_HAS_SWAPPED_SIGINFO
-#define __SIGINFO \
-struct { \
- int si_signo; \
- int si_errno; \
- int si_code; \
- union __sifields _sifields; \
+#ifndef __SIGINFO
+# ifndef __ARCH_HAS_SWAPPED_SIGINFO
+# define __SIGINFO \
+struct { \
+ int si_signo; \
+ int si_errno; \
+ int si_code; \
+ union __sifields _sifields __ARCH_SI_ATTRIBUTES; \
}
-#else
-#define __SIGINFO \
-struct { \
- int si_signo; \
- int si_code; \
- int si_errno; \
- union __sifields _sifields; \
+# else
+# define __SIGINFO \
+struct { \
+ int si_signo; \
+ int si_code; \
+ int si_errno; \
+ union __sifields _sifields __ARCH_SI_ATTRIBUTES; \
}
-#endif /* __ARCH_HAS_SWAPPED_SIGINFO */
+# endif /* __ARCH_HAS_SWAPPED_SIGINFO */
+#endif /* __SIGINFO */

typedef struct siginfo {
union {
--
2.22.0

2019-07-03 08:33:50

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH 1/2] uapi/asm-generic: Allow defining a custom __SIGINFO struct

On Wed, Jul 3, 2019 at 2:21 AM Alistair Francis
<[email protected]> wrote:
>
> Allow defining a custom __SIGINFO struct. This allows architectures to
> apply their own padding and allignment requirements to the struct. This
> is similar to the __ARCH_SI_ATTRIBUTES #define that already exists, but
> applies to the __SIGINFO struct instead of the siginfo_t struct.
>
> Signed-off-by: Alistair Francis <[email protected]>

I don't think there should be another special case for rv32 here,
we already have too many exceptions for architectures that
were different for no good reason.

Please keep the same definition that everything else has.

Arnd