qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] NetBSD/arm build fix
@ 2020-05-12  6:48 Nick Hudson
  2020-05-13 16:25 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Nick Hudson @ 2020-05-12  6:48 UTC (permalink / raw)
  To: qemu-devel
  Cc: Nick Hudson, Paolo Bonzini, Kamil Rytarowski, Riku Voipio,
	Richard Henderson

Fix building on NetBSD/arm by extracting the FSR value from the
correct siginfo_t field.

Signed-off-by: Nick Hudson <skrll@netbsd.org>
---
 accel/tcg/user-exec.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 52359949df..3637626456 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -517,6 +517,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 
 #if defined(__NetBSD__)
 #include <ucontext.h>
+#include <sys/siginfo.h>
 #endif
 
 int cpu_signal_handler(int host_signum, void *pinfo,
@@ -525,6 +526,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
     siginfo_t *info = pinfo;
 #if defined(__NetBSD__)
     ucontext_t *uc = puc;
+    siginfo_t *si = pinfo;
 #else
     ucontext_t *uc = puc;
 #endif
@@ -539,10 +541,18 @@ int cpu_signal_handler(int host_signum, void *pinfo,
     pc = uc->uc_mcontext.arm_pc;
 #endif
 
+#if defined(__NetBSD__)
+    /* siginfo_t::si_trap is the FSR value, in which bit 11 is WnR
+     * (assuming a v6 or later processor; on v5 we will always report
+     * this as a read).
+     */
+    is_write = extract32(si->si_trap, 11, 1);
+#else
     /* error_code is the FSR value, in which bit 11 is WnR (assuming a v6 or
      * later processor; on v5 we will always report this as a read).
      */
     is_write = extract32(uc->uc_mcontext.error_code, 11, 1);
+#endif
     return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask);
 }
 
-- 
2.17.1



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

* Re: [PATCH 1/1] NetBSD/arm build fix
  2020-05-12  6:48 [PATCH 1/1] NetBSD/arm build fix Nick Hudson
@ 2020-05-13 16:25 ` Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2020-05-13 16:25 UTC (permalink / raw)
  To: Nick Hudson, qemu-devel
  Cc: Paolo Bonzini, Kamil Rytarowski, Riku Voipio, Richard Henderson

On 5/11/20 11:48 PM, Nick Hudson wrote:
>  
> +#if defined(__NetBSD__)
> +    /* siginfo_t::si_trap is the FSR value, in which bit 11 is WnR
> +     * (assuming a v6 or later processor; on v5 we will always report
> +     * this as a read).
> +     */
> +    is_write = extract32(si->si_trap, 11, 1);
> +#else
>      /* error_code is the FSR value, in which bit 11 is WnR (assuming a v6 or
>       * later processor; on v5 we will always report this as a read).
>       */
>      is_write = extract32(uc->uc_mcontext.error_code, 11, 1);
> +#endif

While this works, I think it might be a bit clearer as


    uint32_t fsr;

#ifdef __NetBSD__
    fsr = si->si_trap;
#else
    fsr = uc->uc_mcontext.error_code;
#endif
    /*
     * In the FSR, bit 11 is WnR, assuming a v6 or
     * later processor.  On v5 we will always report
     * this as a read, which will fail later.
     */
    is_write = extract32(fsr, 11, 1);


r~


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

end of thread, other threads:[~2020-05-13 16:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-12  6:48 [PATCH 1/1] NetBSD/arm build fix Nick Hudson
2020-05-13 16:25 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).