All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] linux-user: Fixes for sparc64 host
@ 2022-02-08  7:12 Richard Henderson
  2022-02-08  7:12 ` [PATCH 1/5] common-user/host/sparc64: Fix safe_syscall_base Richard Henderson
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Richard Henderson @ 2022-02-08  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Brown bag time, since both of these problems are my fault, and I
ostensibly tested them.  Ho hum.  Anyway, this brings linux-test
back to working.


r~


Richard Henderson (5):
  common-user/host/sparc64: Fix safe_syscall_base
  linux-user: Introduce host_signal_mask
  linux-user: Introduce host_sigcontext
  linux-user: Move sparc/host-signal.h to sparc64/host-signal.h
  linux-user/include/host/sparc64: Fix host_sigcontext

 linux-user/include/host/aarch64/host-signal.h | 16 +++--
 linux-user/include/host/alpha/host-signal.h   | 14 +++-
 linux-user/include/host/arm/host-signal.h     | 14 +++-
 linux-user/include/host/i386/host-signal.h    | 14 +++-
 .../include/host/loongarch64/host-signal.h    | 14 +++-
 linux-user/include/host/mips/host-signal.h    | 14 +++-
 linux-user/include/host/ppc/host-signal.h     | 14 +++-
 linux-user/include/host/riscv/host-signal.h   | 14 +++-
 linux-user/include/host/s390/host-signal.h    | 14 +++-
 linux-user/include/host/sparc/host-signal.h   | 63 ------------------
 linux-user/include/host/sparc64/host-signal.h | 65 ++++++++++++++++++-
 linux-user/include/host/x86_64/host-signal.h  | 14 +++-
 linux-user/signal.c                           | 22 +++----
 common-user/host/sparc64/safe-syscall.inc.S   |  5 +-
 14 files changed, 188 insertions(+), 109 deletions(-)
 delete mode 100644 linux-user/include/host/sparc/host-signal.h

-- 
2.25.1



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

* [PATCH 1/5] common-user/host/sparc64: Fix safe_syscall_base
  2022-02-08  7:12 [PATCH 0/5] linux-user: Fixes for sparc64 host Richard Henderson
@ 2022-02-08  7:12 ` Richard Henderson
  2022-02-08  7:12 ` [PATCH 2/5] linux-user: Introduce host_signal_mask Richard Henderson
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Richard Henderson @ 2022-02-08  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Use the "retl" instead of "ret" instruction alias, since we
do not allocate a register window in this function.

Fix the offset to the first stacked parameter, which lies
beyond the register window save area.

Fixes: 95c021dac835 ("linux-user/host/sparc64: Add safe-syscall.inc.S")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 common-user/host/sparc64/safe-syscall.inc.S | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/common-user/host/sparc64/safe-syscall.inc.S b/common-user/host/sparc64/safe-syscall.inc.S
index a2f2b9c967..c7be8f2d25 100644
--- a/common-user/host/sparc64/safe-syscall.inc.S
+++ b/common-user/host/sparc64/safe-syscall.inc.S
@@ -24,7 +24,8 @@
         .type   safe_syscall_end, @function
 
 #define STACK_BIAS  2047
-#define PARAM(N)    STACK_BIAS + N*8
+#define WINDOW_SIZE 16 * 8
+#define PARAM(N)    STACK_BIAS + WINDOW_SIZE + N * 8
 
         /*
          * This is the entry point for making a system call. The calling
@@ -74,7 +75,7 @@ safe_syscall_end:
         /* code path for having successfully executed the syscall */
         bcs,pn  %xcc, 1f
          nop
-        ret
+        retl
          nop
 
         /* code path when we didn't execute the syscall */
-- 
2.25.1



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

* [PATCH 2/5] linux-user: Introduce host_signal_mask
  2022-02-08  7:12 [PATCH 0/5] linux-user: Fixes for sparc64 host Richard Henderson
  2022-02-08  7:12 ` [PATCH 1/5] common-user/host/sparc64: Fix safe_syscall_base Richard Henderson
@ 2022-02-08  7:12 ` Richard Henderson
  2022-02-08 10:39   ` Philippe Mathieu-Daudé via
  2022-02-08 10:59   ` Peter Maydell
  2022-02-08  7:12 ` [PATCH 3/5] linux-user: Introduce host_sigcontext Richard Henderson
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 16+ messages in thread
From: Richard Henderson @ 2022-02-08  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Do not directly access the uc_sigmask member.
This is preparation for a sparc64 fix.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/include/host/aarch64/host-signal.h  |  5 +++++
 linux-user/include/host/alpha/host-signal.h    |  5 +++++
 linux-user/include/host/arm/host-signal.h      |  5 +++++
 linux-user/include/host/i386/host-signal.h     |  5 +++++
 .../include/host/loongarch64/host-signal.h     |  5 +++++
 linux-user/include/host/mips/host-signal.h     |  5 +++++
 linux-user/include/host/ppc/host-signal.h      |  5 +++++
 linux-user/include/host/riscv/host-signal.h    |  5 +++++
 linux-user/include/host/s390/host-signal.h     |  5 +++++
 linux-user/include/host/sparc/host-signal.h    |  5 +++++
 linux-user/include/host/x86_64/host-signal.h   |  5 +++++
 linux-user/signal.c                            | 18 ++++++++----------
 12 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h
index 9770b36dc1..76ab078069 100644
--- a/linux-user/include/host/aarch64/host-signal.h
+++ b/linux-user/include/host/aarch64/host-signal.h
@@ -40,6 +40,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.pc = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     struct _aarch64_ctx *hdr;
diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h
index f4c942948a..a44d670f2b 100644
--- a/linux-user/include/host/alpha/host-signal.h
+++ b/linux-user/include/host/alpha/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.sc_pc = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     uint32_t *pc = (uint32_t *)host_signal_pc(uc);
diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include/host/arm/host-signal.h
index 6c095773c0..bbeb4ffefb 100644
--- a/linux-user/include/host/arm/host-signal.h
+++ b/linux-user/include/host/arm/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.arm_pc = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     /*
diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/include/host/i386/host-signal.h
index abe1ece5c9..fd36f06bda 100644
--- a/linux-user/include/host/i386/host-signal.h
+++ b/linux-user/include/host/i386/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.gregs[REG_EIP] = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h
index 7effa24251..a9dfe0c688 100644
--- a/linux-user/include/host/loongarch64/host-signal.h
+++ b/linux-user/include/host/loongarch64/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.__pc = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc);
diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/include/host/mips/host-signal.h
index c666ed8c3f..ff840dd491 100644
--- a/linux-user/include/host/mips/host-signal.h
+++ b/linux-user/include/host/mips/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.pc = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 #if defined(__misp16) || defined(__mips_micromips)
 #error "Unsupported encoding"
 #endif
diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h
index 1d8e658ff7..730a321d98 100644
--- a/linux-user/include/host/ppc/host-signal.h
+++ b/linux-user/include/host/ppc/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.regs->nip = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     return uc->uc_mcontext.regs->trap != 0x400
diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/include/host/riscv/host-signal.h
index a4f170efb0..aceae544f2 100644
--- a/linux-user/include/host/riscv/host-signal.h
+++ b/linux-user/include/host/riscv/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.__gregs[REG_PC] = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     /*
diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h
index a524f2ab00..e454cea54a 100644
--- a/linux-user/include/host/s390/host-signal.h
+++ b/linux-user/include/host/s390/host-signal.h
@@ -21,6 +21,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.psw.addr = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h
index 7342936071..158918f2ec 100644
--- a/linux-user/include/host/sparc/host-signal.h
+++ b/linux-user/include/host/sparc/host-signal.h
@@ -29,6 +29,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
 #endif
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     uint32_t insn = *(uint32_t *)host_signal_pc(uc);
diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/include/host/x86_64/host-signal.h
index c71d597eb2..d64d076625 100644
--- a/linux-user/include/host/x86_64/host-signal.h
+++ b/linux-user/include/host/x86_64/host-signal.h
@@ -20,6 +20,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
     uc->uc_mcontext.gregs[REG_RIP] = pc;
 }
 
+static inline void *host_signal_mask(ucontext_t *uc)
+{
+    return &uc->uc_sigmask;
+}
+
 static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
 {
     return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 32854bb375..0c61459d4a 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -820,6 +820,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
     int guest_sig;
     uintptr_t pc = 0;
     bool sync_sig = false;
+    void *sigmask = host_signal_mask(uc);
 
     /*
      * Non-spoofed SIGSEGV and SIGBUS are synchronous, and need special
@@ -849,8 +850,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
             if (info->si_code == SEGV_ACCERR && h2g_valid(host_addr)) {
                 /* If this was a write to a TB protected page, restart. */
                 if (is_write &&
-                    handle_sigsegv_accerr_write(cpu, &uc->uc_sigmask,
-                                                pc, guest_addr)) {
+                    handle_sigsegv_accerr_write(cpu, sigmask, pc, guest_addr)) {
                     return;
                 }
 
@@ -865,10 +865,10 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
                 }
             }
 
-            sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
+            sigprocmask(SIG_SETMASK, sigmask, NULL);
             cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc);
         } else {
-            sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
+            sigprocmask(SIG_SETMASK, sigmask, NULL);
             if (info->si_code == BUS_ADRALN) {
                 cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc);
             }
@@ -909,17 +909,15 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
      * now and it getting out to the main loop. Signals will be
      * unblocked again in process_pending_signals().
      *
-     * WARNING: we cannot use sigfillset() here because the uc_sigmask
+     * WARNING: we cannot use sigfillset() here because the sigmask
      * field is a kernel sigset_t, which is much smaller than the
      * libc sigset_t which sigfillset() operates on. Using sigfillset()
      * would write 0xff bytes off the end of the structure and trash
      * data on the struct.
-     * We can't use sizeof(uc->uc_sigmask) either, because the libc
-     * headers define the struct field with the wrong (too large) type.
      */
-    memset(&uc->uc_sigmask, 0xff, SIGSET_T_SIZE);
-    sigdelset(&uc->uc_sigmask, SIGSEGV);
-    sigdelset(&uc->uc_sigmask, SIGBUS);
+    memset(sigmask, 0xff, SIGSET_T_SIZE);
+    sigdelset(sigmask, SIGSEGV);
+    sigdelset(sigmask, SIGBUS);
 
     /* interrupt the virtual CPU as soon as possible */
     cpu_exit(thread_cpu);
-- 
2.25.1



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

* [PATCH 3/5] linux-user: Introduce host_sigcontext
  2022-02-08  7:12 [PATCH 0/5] linux-user: Fixes for sparc64 host Richard Henderson
  2022-02-08  7:12 ` [PATCH 1/5] common-user/host/sparc64: Fix safe_syscall_base Richard Henderson
  2022-02-08  7:12 ` [PATCH 2/5] linux-user: Introduce host_signal_mask Richard Henderson
@ 2022-02-08  7:12 ` Richard Henderson
  2022-02-08 10:40   ` Philippe Mathieu-Daudé via
  2022-02-08 11:06   ` Peter Maydell
  2022-02-08  7:12 ` [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Richard Henderson
  2022-02-08  7:12 ` [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext Richard Henderson
  4 siblings, 2 replies; 16+ messages in thread
From: Richard Henderson @ 2022-02-08  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Do not directly access ucontext_t as the third signal parameter.
This is preparation for a sparc64 fix.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/include/host/aarch64/host-signal.h     | 13 ++++++++-----
 linux-user/include/host/alpha/host-signal.h       | 11 +++++++----
 linux-user/include/host/arm/host-signal.h         | 11 +++++++----
 linux-user/include/host/i386/host-signal.h        | 11 +++++++----
 linux-user/include/host/loongarch64/host-signal.h | 11 +++++++----
 linux-user/include/host/mips/host-signal.h        | 11 +++++++----
 linux-user/include/host/ppc/host-signal.h         | 11 +++++++----
 linux-user/include/host/riscv/host-signal.h       | 11 +++++++----
 linux-user/include/host/s390/host-signal.h        | 11 +++++++----
 linux-user/include/host/sparc/host-signal.h       | 11 +++++++----
 linux-user/include/host/x86_64/host-signal.h      | 11 +++++++----
 linux-user/signal.c                               |  4 ++--
 12 files changed, 80 insertions(+), 47 deletions(-)

diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h
index 76ab078069..be079684a2 100644
--- a/linux-user/include/host/aarch64/host-signal.h
+++ b/linux-user/include/host/aarch64/host-signal.h
@@ -11,6 +11,9 @@
 #ifndef AARCH64_HOST_SIGNAL_H
 #define AARCH64_HOST_SIGNAL_H
 
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
 /* Pre-3.16 kernel headers don't have these, so provide fallback definitions */
 #ifndef ESR_MAGIC
 #define ESR_MAGIC 0x45535201
@@ -20,7 +23,7 @@ struct esr_context {
 };
 #endif
 
-static inline struct _aarch64_ctx *first_ctx(ucontext_t *uc)
+static inline struct _aarch64_ctx *first_ctx(host_sigcontext *uc)
 {
     return (struct _aarch64_ctx *)&uc->uc_mcontext.__reserved;
 }
@@ -30,22 +33,22 @@ static inline struct _aarch64_ctx *next_ctx(struct _aarch64_ctx *hdr)
     return (struct _aarch64_ctx *)((char *)hdr + hdr->size);
 }
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.pc;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.pc = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     struct _aarch64_ctx *hdr;
     uint32_t insn;
diff --git a/linux-user/include/host/alpha/host-signal.h b/linux-user/include/host/alpha/host-signal.h
index a44d670f2b..4f9e2abc4b 100644
--- a/linux-user/include/host/alpha/host-signal.h
+++ b/linux-user/include/host/alpha/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef ALPHA_HOST_SIGNAL_H
 #define ALPHA_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.sc_pc;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.sc_pc = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     uint32_t *pc = (uint32_t *)host_signal_pc(uc);
     uint32_t insn = *pc;
diff --git a/linux-user/include/host/arm/host-signal.h b/linux-user/include/host/arm/host-signal.h
index bbeb4ffefb..faba496d24 100644
--- a/linux-user/include/host/arm/host-signal.h
+++ b/linux-user/include/host/arm/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef ARM_HOST_SIGNAL_H
 #define ARM_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.arm_pc;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.arm_pc = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     /*
      * In the FSR, bit 11 is WnR, assuming a v6 or
diff --git a/linux-user/include/host/i386/host-signal.h b/linux-user/include/host/i386/host-signal.h
index fd36f06bda..e2b64f077f 100644
--- a/linux-user/include/host/i386/host-signal.h
+++ b/linux-user/include/host/i386/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef I386_HOST_SIGNAL_H
 #define I386_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.gregs[REG_EIP];
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.gregs[REG_EIP] = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
         && (uc->uc_mcontext.gregs[REG_ERR] & 0x2);
diff --git a/linux-user/include/host/loongarch64/host-signal.h b/linux-user/include/host/loongarch64/host-signal.h
index a9dfe0c688..d33c3fc03e 100644
--- a/linux-user/include/host/loongarch64/host-signal.h
+++ b/linux-user/include/host/loongarch64/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef LOONGARCH64_HOST_SIGNAL_H
 #define LOONGARCH64_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.__pc;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.__pc = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     const uint32_t *pinsn = (const uint32_t *)host_signal_pc(uc);
     uint32_t insn = pinsn[0];
diff --git a/linux-user/include/host/mips/host-signal.h b/linux-user/include/host/mips/host-signal.h
index ff840dd491..0dbc5cecfd 100644
--- a/linux-user/include/host/mips/host-signal.h
+++ b/linux-user/include/host/mips/host-signal.h
@@ -11,17 +11,20 @@
 #ifndef MIPS_HOST_SIGNAL_H
 #define MIPS_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.pc;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.pc = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
@@ -30,7 +33,7 @@ static inline void *host_signal_mask(ucontext_t *uc)
 #error "Unsupported encoding"
 #endif
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     uint32_t insn = *(uint32_t *)host_signal_pc(uc);
 
diff --git a/linux-user/include/host/ppc/host-signal.h b/linux-user/include/host/ppc/host-signal.h
index 730a321d98..b80384d135 100644
--- a/linux-user/include/host/ppc/host-signal.h
+++ b/linux-user/include/host/ppc/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef PPC_HOST_SIGNAL_H
 #define PPC_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.regs->nip;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.regs->nip = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     return uc->uc_mcontext.regs->trap != 0x400
         && (uc->uc_mcontext.regs->dsisr & 0x02000000);
diff --git a/linux-user/include/host/riscv/host-signal.h b/linux-user/include/host/riscv/host-signal.h
index aceae544f2..decacb2325 100644
--- a/linux-user/include/host/riscv/host-signal.h
+++ b/linux-user/include/host/riscv/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef RISCV_HOST_SIGNAL_H
 #define RISCV_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.__gregs[REG_PC];
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.__gregs[REG_PC] = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     /*
      * Detect store by reading the instruction at the program counter.
diff --git a/linux-user/include/host/s390/host-signal.h b/linux-user/include/host/s390/host-signal.h
index e454cea54a..6f191e64d7 100644
--- a/linux-user/include/host/s390/host-signal.h
+++ b/linux-user/include/host/s390/host-signal.h
@@ -11,22 +11,25 @@
 #ifndef S390_HOST_SIGNAL_H
 #define S390_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.psw.addr;
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.psw.addr = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     uint16_t *pinsn = (uint16_t *)host_signal_pc(uc);
 
diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h
index 158918f2ec..871b6bb269 100644
--- a/linux-user/include/host/sparc/host-signal.h
+++ b/linux-user/include/host/sparc/host-signal.h
@@ -11,7 +11,10 @@
 #ifndef SPARC_HOST_SIGNAL_H
 #define SPARC_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
 #ifdef __arch64__
     return uc->uc_mcontext.mc_gregs[MC_PC];
@@ -20,7 +23,7 @@ static inline uintptr_t host_signal_pc(ucontext_t *uc)
 #endif
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
 #ifdef __arch64__
     uc->uc_mcontext.mc_gregs[MC_PC] = pc;
@@ -29,12 +32,12 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
 #endif
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     uint32_t insn = *(uint32_t *)host_signal_pc(uc);
 
diff --git a/linux-user/include/host/x86_64/host-signal.h b/linux-user/include/host/x86_64/host-signal.h
index d64d076625..5a7627fedc 100644
--- a/linux-user/include/host/x86_64/host-signal.h
+++ b/linux-user/include/host/x86_64/host-signal.h
@@ -10,22 +10,25 @@
 #ifndef X86_64_HOST_SIGNAL_H
 #define X86_64_HOST_SIGNAL_H
 
-static inline uintptr_t host_signal_pc(ucontext_t *uc)
+/* The third argument to a SA_SIGINFO handler is ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
 {
     return uc->uc_mcontext.gregs[REG_RIP];
 }
 
-static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
 {
     uc->uc_mcontext.gregs[REG_RIP] = pc;
 }
 
-static inline void *host_signal_mask(ucontext_t *uc)
+static inline void *host_signal_mask(host_sigcontext *uc)
 {
     return &uc->uc_sigmask;
 }
 
-static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
 {
     return uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe
         && (uc->uc_mcontext.gregs[REG_ERR] & 0x2);
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 0c61459d4a..27a0ff30e9 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -800,7 +800,7 @@ void queue_signal(CPUArchState *env, int sig, int si_type,
 /* Adjust the signal context to rewind out of safe-syscall if we're in it */
 static inline void rewind_if_in_safe_syscall(void *puc)
 {
-    ucontext_t *uc = (ucontext_t *)puc;
+    host_sigcontext *uc = (host_sigcontext *)puc;
     uintptr_t pcreg = host_signal_pc(uc);
 
     if (pcreg > (uintptr_t)safe_syscall_start
@@ -815,7 +815,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
     CPUState *cpu = env_cpu(env);
     TaskState *ts = cpu->opaque;
     target_siginfo_t tinfo;
-    ucontext_t *uc = puc;
+    host_sigcontext *uc = puc;
     struct emulated_sigtable *k;
     int guest_sig;
     uintptr_t pc = 0;
-- 
2.25.1



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

* [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h
  2022-02-08  7:12 [PATCH 0/5] linux-user: Fixes for sparc64 host Richard Henderson
                   ` (2 preceding siblings ...)
  2022-02-08  7:12 ` [PATCH 3/5] linux-user: Introduce host_sigcontext Richard Henderson
@ 2022-02-08  7:12 ` Richard Henderson
  2022-02-08 10:40   ` Philippe Mathieu-Daudé via
  2022-02-08 11:01   ` Peter Maydell
  2022-02-08  7:12 ` [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext Richard Henderson
  4 siblings, 2 replies; 16+ messages in thread
From: Richard Henderson @ 2022-02-08  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

We do not support sparc32 as a host, so there's no point in
sparc64 redirecting to sparc.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/include/host/sparc/host-signal.h   | 71 -------------------
 linux-user/include/host/sparc64/host-signal.h | 64 ++++++++++++++++-
 2 files changed, 63 insertions(+), 72 deletions(-)
 delete mode 100644 linux-user/include/host/sparc/host-signal.h

diff --git a/linux-user/include/host/sparc/host-signal.h b/linux-user/include/host/sparc/host-signal.h
deleted file mode 100644
index 871b6bb269..0000000000
--- a/linux-user/include/host/sparc/host-signal.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * host-signal.h: signal info dependent on the host architecture
- *
- * Copyright (c) 2003-2005 Fabrice Bellard
- * Copyright (c) 2021 Linaro Limited
- *
- * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
- * See the COPYING file in the top-level directory.
- */
-
-#ifndef SPARC_HOST_SIGNAL_H
-#define SPARC_HOST_SIGNAL_H
-
-/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */
-typedef ucontext_t host_sigcontext;
-
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
-{
-#ifdef __arch64__
-    return uc->uc_mcontext.mc_gregs[MC_PC];
-#else
-    return uc->uc_mcontext.gregs[REG_PC];
-#endif
-}
-
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
-{
-#ifdef __arch64__
-    uc->uc_mcontext.mc_gregs[MC_PC] = pc;
-#else
-    uc->uc_mcontext.gregs[REG_PC] = pc;
-#endif
-}
-
-static inline void *host_signal_mask(host_sigcontext *uc)
-{
-    return &uc->uc_sigmask;
-}
-
-static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-{
-    uint32_t insn = *(uint32_t *)host_signal_pc(uc);
-
-    if ((insn >> 30) == 3) {
-        switch ((insn >> 19) & 0x3f) {
-        case 0x05: /* stb */
-        case 0x15: /* stba */
-        case 0x06: /* sth */
-        case 0x16: /* stha */
-        case 0x04: /* st */
-        case 0x14: /* sta */
-        case 0x07: /* std */
-        case 0x17: /* stda */
-        case 0x0e: /* stx */
-        case 0x1e: /* stxa */
-        case 0x24: /* stf */
-        case 0x34: /* stfa */
-        case 0x27: /* stdf */
-        case 0x37: /* stdfa */
-        case 0x26: /* stqf */
-        case 0x36: /* stqfa */
-        case 0x25: /* stfsr */
-        case 0x3c: /* casa */
-        case 0x3e: /* casxa */
-            return true;
-        }
-    }
-    return false;
-}
-
-#endif
diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/include/host/sparc64/host-signal.h
index 1191fe2d40..f8a8a4908d 100644
--- a/linux-user/include/host/sparc64/host-signal.h
+++ b/linux-user/include/host/sparc64/host-signal.h
@@ -1 +1,63 @@
-#include "../sparc/host-signal.h"
+/*
+ * host-signal.h: signal info dependent on the host architecture
+ *
+ * Copyright (c) 2003-2005 Fabrice Bellard
+ * Copyright (c) 2021 Linaro Limited
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#ifndef SPARC64_HOST_SIGNAL_H
+#define SPARC64_HOST_SIGNAL_H
+
+/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */
+typedef ucontext_t host_sigcontext;
+
+static inline uintptr_t host_signal_pc(host_sigcontext *uc)
+{
+    return uc->uc_mcontext.mc_gregs[MC_PC];
+}
+
+static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
+{
+    uc->uc_mcontext.mc_gregs[MC_PC] = pc;
+}
+
+static inline void *host_signal_mask(host_sigcontext *uc)
+{
+    return &uc->uc_sigmask;
+}
+
+static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
+{
+    uint32_t insn = *(uint32_t *)host_signal_pc(uc);
+
+    if ((insn >> 30) == 3) {
+        switch ((insn >> 19) & 0x3f) {
+        case 0x05: /* stb */
+        case 0x15: /* stba */
+        case 0x06: /* sth */
+        case 0x16: /* stha */
+        case 0x04: /* st */
+        case 0x14: /* sta */
+        case 0x07: /* std */
+        case 0x17: /* stda */
+        case 0x0e: /* stx */
+        case 0x1e: /* stxa */
+        case 0x24: /* stf */
+        case 0x34: /* stfa */
+        case 0x27: /* stdf */
+        case 0x37: /* stdfa */
+        case 0x26: /* stqf */
+        case 0x36: /* stqfa */
+        case 0x25: /* stfsr */
+        case 0x3c: /* casa */
+        case 0x3e: /* casxa */
+            return true;
+        }
+    }
+    return false;
+}
+
+#endif
-- 
2.25.1



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

* [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext
  2022-02-08  7:12 [PATCH 0/5] linux-user: Fixes for sparc64 host Richard Henderson
                   ` (3 preceding siblings ...)
  2022-02-08  7:12 ` [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Richard Henderson
@ 2022-02-08  7:12 ` Richard Henderson
  2022-02-08 11:14   ` Peter Maydell
  4 siblings, 1 reply; 16+ messages in thread
From: Richard Henderson @ 2022-02-08  7:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: laurent

Sparc64 is unique on linux in *not* passing ucontext_t as
the third argument to a SA_SIGINFO handler.  It passes the
old struct sigcontext instead.t log

Fixes: 8b5bd461935b ("linux-user/host/sparc: Populate host_signal.h")
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 linux-user/include/host/sparc64/host-signal.h | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/linux-user/include/host/sparc64/host-signal.h b/linux-user/include/host/sparc64/host-signal.h
index f8a8a4908d..64957c2bca 100644
--- a/linux-user/include/host/sparc64/host-signal.h
+++ b/linux-user/include/host/sparc64/host-signal.h
@@ -11,22 +11,23 @@
 #ifndef SPARC64_HOST_SIGNAL_H
 #define SPARC64_HOST_SIGNAL_H
 
-/* FIXME: the third argument to a SA_SIGINFO handler is *not* ucontext_t. */
-typedef ucontext_t host_sigcontext;
+/* The third argument to a SA_SIGINFO handler is struct sigcontext.  */
+typedef struct sigcontext host_sigcontext;
 
-static inline uintptr_t host_signal_pc(host_sigcontext *uc)
+static inline uintptr_t host_signal_pc(host_sigcontext *sc)
 {
-    return uc->uc_mcontext.mc_gregs[MC_PC];
+    return sc->sigc_regs.tpc;
 }
 
-static inline void host_signal_set_pc(host_sigcontext *uc, uintptr_t pc)
+static inline void host_signal_set_pc(host_sigcontext *sc, uintptr_t pc)
 {
-    uc->uc_mcontext.mc_gregs[MC_PC] = pc;
+    sc->sigc_regs.tpc = pc;
+    sc->sigc_regs.tnpc = pc + 4;
 }
 
-static inline void *host_signal_mask(host_sigcontext *uc)
+static inline void *host_signal_mask(host_sigcontext *sc)
 {
-    return &uc->uc_sigmask;
+    return &sc->sigc_mask;
 }
 
 static inline bool host_signal_write(siginfo_t *info, host_sigcontext *uc)
-- 
2.25.1



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

* Re: [PATCH 2/5] linux-user: Introduce host_signal_mask
  2022-02-08  7:12 ` [PATCH 2/5] linux-user: Introduce host_signal_mask Richard Henderson
@ 2022-02-08 10:39   ` Philippe Mathieu-Daudé via
  2022-02-08 10:59   ` Peter Maydell
  1 sibling, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-08 10:39 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: laurent

On 8/2/22 08:12, Richard Henderson wrote:
> Do not directly access the uc_sigmask member.
> This is preparation for a sparc64 fix.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/include/host/aarch64/host-signal.h  |  5 +++++
>   linux-user/include/host/alpha/host-signal.h    |  5 +++++
>   linux-user/include/host/arm/host-signal.h      |  5 +++++
>   linux-user/include/host/i386/host-signal.h     |  5 +++++
>   .../include/host/loongarch64/host-signal.h     |  5 +++++
>   linux-user/include/host/mips/host-signal.h     |  5 +++++
>   linux-user/include/host/ppc/host-signal.h      |  5 +++++
>   linux-user/include/host/riscv/host-signal.h    |  5 +++++
>   linux-user/include/host/s390/host-signal.h     |  5 +++++
>   linux-user/include/host/sparc/host-signal.h    |  5 +++++
>   linux-user/include/host/x86_64/host-signal.h   |  5 +++++
>   linux-user/signal.c                            | 18 ++++++++----------
>   12 files changed, 63 insertions(+), 10 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


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

* Re: [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h
  2022-02-08  7:12 ` [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Richard Henderson
@ 2022-02-08 10:40   ` Philippe Mathieu-Daudé via
  2022-02-08 11:01   ` Peter Maydell
  1 sibling, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-08 10:40 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: laurent

On 8/2/22 08:12, Richard Henderson wrote:
> We do not support sparc32 as a host, so there's no point in
> sparc64 redirecting to sparc.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/include/host/sparc/host-signal.h   | 71 -------------------
>   linux-user/include/host/sparc64/host-signal.h | 64 ++++++++++++++++-
>   2 files changed, 63 insertions(+), 72 deletions(-)
>   delete mode 100644 linux-user/include/host/sparc/host-signal.h

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


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

* Re: [PATCH 3/5] linux-user: Introduce host_sigcontext
  2022-02-08  7:12 ` [PATCH 3/5] linux-user: Introduce host_sigcontext Richard Henderson
@ 2022-02-08 10:40   ` Philippe Mathieu-Daudé via
  2022-02-08 11:06   ` Peter Maydell
  1 sibling, 0 replies; 16+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-02-08 10:40 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: laurent

On 8/2/22 08:12, Richard Henderson wrote:
> Do not directly access ucontext_t as the third signal parameter.
> This is preparation for a sparc64 fix.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>   linux-user/include/host/aarch64/host-signal.h     | 13 ++++++++-----
>   linux-user/include/host/alpha/host-signal.h       | 11 +++++++----
>   linux-user/include/host/arm/host-signal.h         | 11 +++++++----
>   linux-user/include/host/i386/host-signal.h        | 11 +++++++----
>   linux-user/include/host/loongarch64/host-signal.h | 11 +++++++----
>   linux-user/include/host/mips/host-signal.h        | 11 +++++++----
>   linux-user/include/host/ppc/host-signal.h         | 11 +++++++----
>   linux-user/include/host/riscv/host-signal.h       | 11 +++++++----
>   linux-user/include/host/s390/host-signal.h        | 11 +++++++----
>   linux-user/include/host/sparc/host-signal.h       | 11 +++++++----
>   linux-user/include/host/x86_64/host-signal.h      | 11 +++++++----
>   linux-user/signal.c                               |  4 ++--
>   12 files changed, 80 insertions(+), 47 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


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

* Re: [PATCH 2/5] linux-user: Introduce host_signal_mask
  2022-02-08  7:12 ` [PATCH 2/5] linux-user: Introduce host_signal_mask Richard Henderson
  2022-02-08 10:39   ` Philippe Mathieu-Daudé via
@ 2022-02-08 10:59   ` Peter Maydell
  2022-02-08 11:17     ` Richard Henderson
  1 sibling, 1 reply; 16+ messages in thread
From: Peter Maydell @ 2022-02-08 10:59 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, Laurent

On Tue, 8 Feb 2022 at 08:03, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Do not directly access the uc_sigmask member.
> This is preparation for a sparc64 fix.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/include/host/aarch64/host-signal.h  |  5 +++++
>  linux-user/include/host/alpha/host-signal.h    |  5 +++++
>  linux-user/include/host/arm/host-signal.h      |  5 +++++
>  linux-user/include/host/i386/host-signal.h     |  5 +++++
>  .../include/host/loongarch64/host-signal.h     |  5 +++++
>  linux-user/include/host/mips/host-signal.h     |  5 +++++
>  linux-user/include/host/ppc/host-signal.h      |  5 +++++
>  linux-user/include/host/riscv/host-signal.h    |  5 +++++
>  linux-user/include/host/s390/host-signal.h     |  5 +++++
>  linux-user/include/host/sparc/host-signal.h    |  5 +++++
>  linux-user/include/host/x86_64/host-signal.h   |  5 +++++
>  linux-user/signal.c                            | 18 ++++++++----------
>  12 files changed, 63 insertions(+), 10 deletions(-)
>
> diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h
> index 9770b36dc1..76ab078069 100644
> --- a/linux-user/include/host/aarch64/host-signal.h
> +++ b/linux-user/include/host/aarch64/host-signal.h
> @@ -40,6 +40,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
>      uc->uc_mcontext.pc = pc;
>  }
>
> +static inline void *host_signal_mask(ucontext_t *uc)
> +{
> +    return &uc->uc_sigmask;
> +}

Why void* rather than sigset_t* ?

thanks
-- PMM


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

* Re: [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h
  2022-02-08  7:12 ` [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Richard Henderson
  2022-02-08 10:40   ` Philippe Mathieu-Daudé via
@ 2022-02-08 11:01   ` Peter Maydell
  2022-02-08 11:19     ` Richard Henderson
  1 sibling, 1 reply; 16+ messages in thread
From: Peter Maydell @ 2022-02-08 11:01 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, Laurent

On Tue, 8 Feb 2022 at 08:17, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> We do not support sparc32 as a host, so there's no point in
> sparc64 redirecting to sparc.

Where do we enforce that ? I couldn't see anything in
configure or meson.build that forbids linux-user with
a 32-bit sparc host, but I probably missed it.

thanks
-- PMM


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

* Re: [PATCH 3/5] linux-user: Introduce host_sigcontext
  2022-02-08  7:12 ` [PATCH 3/5] linux-user: Introduce host_sigcontext Richard Henderson
  2022-02-08 10:40   ` Philippe Mathieu-Daudé via
@ 2022-02-08 11:06   ` Peter Maydell
  1 sibling, 0 replies; 16+ messages in thread
From: Peter Maydell @ 2022-02-08 11:06 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, Laurent

On Tue, 8 Feb 2022 at 08:57, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Do not directly access ucontext_t as the third signal parameter.
> This is preparation for a sparc64 fix.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext
  2022-02-08  7:12 ` [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext Richard Henderson
@ 2022-02-08 11:14   ` Peter Maydell
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Maydell @ 2022-02-08 11:14 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, Laurent

On Tue, 8 Feb 2022 at 07:46, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Sparc64 is unique on linux in *not* passing ucontext_t as
> the third argument to a SA_SIGINFO handler.  It passes the
> old struct sigcontext instead.t log

Stray bit of text at the end of the commit message here.

>
> Fixes: 8b5bd461935b ("linux-user/host/sparc: Populate host_signal.h")
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  linux-user/include/host/sparc64/host-signal.h | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>

Otherwise


Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


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

* Re: [PATCH 2/5] linux-user: Introduce host_signal_mask
  2022-02-08 10:59   ` Peter Maydell
@ 2022-02-08 11:17     ` Richard Henderson
  2022-02-08 11:32       ` Peter Maydell
  0 siblings, 1 reply; 16+ messages in thread
From: Richard Henderson @ 2022-02-08 11:17 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Laurent

On 2/8/22 21:59, Peter Maydell wrote:
> On Tue, 8 Feb 2022 at 08:03, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> Do not directly access the uc_sigmask member.
>> This is preparation for a sparc64 fix.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>   linux-user/include/host/aarch64/host-signal.h  |  5 +++++
>>   linux-user/include/host/alpha/host-signal.h    |  5 +++++
>>   linux-user/include/host/arm/host-signal.h      |  5 +++++
>>   linux-user/include/host/i386/host-signal.h     |  5 +++++
>>   .../include/host/loongarch64/host-signal.h     |  5 +++++
>>   linux-user/include/host/mips/host-signal.h     |  5 +++++
>>   linux-user/include/host/ppc/host-signal.h      |  5 +++++
>>   linux-user/include/host/riscv/host-signal.h    |  5 +++++
>>   linux-user/include/host/s390/host-signal.h     |  5 +++++
>>   linux-user/include/host/sparc/host-signal.h    |  5 +++++
>>   linux-user/include/host/x86_64/host-signal.h   |  5 +++++
>>   linux-user/signal.c                            | 18 ++++++++----------
>>   12 files changed, 63 insertions(+), 10 deletions(-)
>>
>> diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h
>> index 9770b36dc1..76ab078069 100644
>> --- a/linux-user/include/host/aarch64/host-signal.h
>> +++ b/linux-user/include/host/aarch64/host-signal.h
>> @@ -40,6 +40,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
>>       uc->uc_mcontext.pc = pc;
>>   }
>>
>> +static inline void *host_signal_mask(ucontext_t *uc)
>> +{
>> +    return &uc->uc_sigmask;
>> +}
> 
> Why void* rather than sigset_t* ?

Because it's not really a sigset_t, even when it is in ucontext_t.
It's a kernel_sigset_t, as per the comment in host_signal_handler.

When it comes to sparc64 in the last patch, the glibc type will turn out to be unsigned long.

Got a better suggestion?


r~


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

* Re: [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h
  2022-02-08 11:01   ` Peter Maydell
@ 2022-02-08 11:19     ` Richard Henderson
  0 siblings, 0 replies; 16+ messages in thread
From: Richard Henderson @ 2022-02-08 11:19 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, Laurent

On 2/8/22 22:01, Peter Maydell wrote:
> On Tue, 8 Feb 2022 at 08:17, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>>
>> We do not support sparc32 as a host, so there's no point in
>> sparc64 redirecting to sparc.
> 
> Where do we enforce that ? I couldn't see anything in
> configure or meson.build that forbids linux-user with
> a 32-bit sparc host, but I probably missed it.

The common-user/host/sparc directory is missing; meson will error out.


r~


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

* Re: [PATCH 2/5] linux-user: Introduce host_signal_mask
  2022-02-08 11:17     ` Richard Henderson
@ 2022-02-08 11:32       ` Peter Maydell
  0 siblings, 0 replies; 16+ messages in thread
From: Peter Maydell @ 2022-02-08 11:32 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel, Laurent

On Tue, 8 Feb 2022 at 11:17, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> On 2/8/22 21:59, Peter Maydell wrote:
> > On Tue, 8 Feb 2022 at 08:03, Richard Henderson
> > <richard.henderson@linaro.org> wrote:
> >>
> >> Do not directly access the uc_sigmask member.
> >> This is preparation for a sparc64 fix.
> >>
> >> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> >> ---
> >>   linux-user/include/host/aarch64/host-signal.h  |  5 +++++
> >>   linux-user/include/host/alpha/host-signal.h    |  5 +++++
> >>   linux-user/include/host/arm/host-signal.h      |  5 +++++
> >>   linux-user/include/host/i386/host-signal.h     |  5 +++++
> >>   .../include/host/loongarch64/host-signal.h     |  5 +++++
> >>   linux-user/include/host/mips/host-signal.h     |  5 +++++
> >>   linux-user/include/host/ppc/host-signal.h      |  5 +++++
> >>   linux-user/include/host/riscv/host-signal.h    |  5 +++++
> >>   linux-user/include/host/s390/host-signal.h     |  5 +++++
> >>   linux-user/include/host/sparc/host-signal.h    |  5 +++++
> >>   linux-user/include/host/x86_64/host-signal.h   |  5 +++++
> >>   linux-user/signal.c                            | 18 ++++++++----------
> >>   12 files changed, 63 insertions(+), 10 deletions(-)
> >>
> >> diff --git a/linux-user/include/host/aarch64/host-signal.h b/linux-user/include/host/aarch64/host-signal.h
> >> index 9770b36dc1..76ab078069 100644
> >> --- a/linux-user/include/host/aarch64/host-signal.h
> >> +++ b/linux-user/include/host/aarch64/host-signal.h
> >> @@ -40,6 +40,11 @@ static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
> >>       uc->uc_mcontext.pc = pc;
> >>   }
> >>
> >> +static inline void *host_signal_mask(ucontext_t *uc)
> >> +{
> >> +    return &uc->uc_sigmask;
> >> +}
> >
> > Why void* rather than sigset_t* ?
>
> Because it's not really a sigset_t, even when it is in ucontext_t.
> It's a kernel_sigset_t, as per the comment in host_signal_handler.

I guess. handle_sigsegv_accerr_write()'s prototype just calls
it a sigset_t, though.

One approach would be to define a typedef for this kernel sigset_t,
and have wrappers for sigdelset() and sigprocmask() which take that
type rather than the libc sigset_t (plus a sigfillset that wrapped
the memset). Then we would avoid the potential bug that the
WARNING comment is talking about, because code wouldn't have
a thing that it could pass to sigfillset() without getting a
compiler complaint about the type. But maybe that's too heavyweight.

For the purposes of this series,
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM


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

end of thread, other threads:[~2022-02-08 13:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-08  7:12 [PATCH 0/5] linux-user: Fixes for sparc64 host Richard Henderson
2022-02-08  7:12 ` [PATCH 1/5] common-user/host/sparc64: Fix safe_syscall_base Richard Henderson
2022-02-08  7:12 ` [PATCH 2/5] linux-user: Introduce host_signal_mask Richard Henderson
2022-02-08 10:39   ` Philippe Mathieu-Daudé via
2022-02-08 10:59   ` Peter Maydell
2022-02-08 11:17     ` Richard Henderson
2022-02-08 11:32       ` Peter Maydell
2022-02-08  7:12 ` [PATCH 3/5] linux-user: Introduce host_sigcontext Richard Henderson
2022-02-08 10:40   ` Philippe Mathieu-Daudé via
2022-02-08 11:06   ` Peter Maydell
2022-02-08  7:12 ` [PATCH 4/5] linux-user: Move sparc/host-signal.h to sparc64/host-signal.h Richard Henderson
2022-02-08 10:40   ` Philippe Mathieu-Daudé via
2022-02-08 11:01   ` Peter Maydell
2022-02-08 11:19     ` Richard Henderson
2022-02-08  7:12 ` [PATCH 5/5] linux-user/include/host/sparc64: Fix host_sigcontext Richard Henderson
2022-02-08 11:14   ` Peter Maydell

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.