[PATCH 2/4] tcg: Additional Trap type for FreeBSD

imp@freebsd.org posted 4 patches 4 years, 11 months ago
Maintainers: Riku Voipio <riku.voipio@iki.fi>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>
There is a newer version of this series
[PATCH 2/4] tcg: Additional Trap type for FreeBSD
Posted by imp@freebsd.org 4 years, 11 months ago
From: Sean Bruno <sbruno@freebsd.org>

FreeBSD can generate a trap 0xc as well as 0xe when writing to a
read-only page.

Signed-off-by: Juergen Lock <nox@FreeBSD.org>
[imp rewored commit message for clarity]
Signed-off-by: Warner Losh <imp@FreeBSD.org>
---
 accel/tcg/user-exec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
index 4ebe25461a..1f5befa9f9 100644
--- a/accel/tcg/user-exec.c
+++ b/accel/tcg/user-exec.c
@@ -343,7 +343,13 @@ int cpu_signal_handler(int host_signum, void *pinfo,
 
     pc = PC_sig(uc);
     return handle_cpu_signal(pc, info,
-                             TRAP_sig(uc) == 0xe ? (ERROR_sig(uc) >> 1) & 1 : 0,
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+                             (TRAP_sig(uc) == 0xe ||
+                              TRAP_sig(uc) == 0xc) ?
+#else
+                             TRAP_sig(uc) == 0xe ?
+#endif
+                             (ERROR_sig(uc) >> 1) & 1 : 0,
                              &MASK_sig(uc));
 }
 
-- 
2.22.1


Re: [PATCH 2/4] tcg: Additional Trap type for FreeBSD
Posted by Warner Losh 4 years, 11 months ago
Again, this turns out to be bogus, for reasons I enumerated the first time
it sent...

Warner

On Sat, Dec 19, 2020 at 1:54 PM <imp@freebsd.org> wrote:

> From: Sean Bruno <sbruno@freebsd.org>
>
> FreeBSD can generate a trap 0xc as well as 0xe when writing to a
> read-only page.
>
> Signed-off-by: Juergen Lock <nox@FreeBSD.org>
> [imp rewored commit message for clarity]
> Signed-off-by: Warner Losh <imp@FreeBSD.org>
> ---
>  accel/tcg/user-exec.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
> index 4ebe25461a..1f5befa9f9 100644
> --- a/accel/tcg/user-exec.c
> +++ b/accel/tcg/user-exec.c
> @@ -343,7 +343,13 @@ int cpu_signal_handler(int host_signum, void *pinfo,
>
>      pc = PC_sig(uc);
>      return handle_cpu_signal(pc, info,
> -                             TRAP_sig(uc) == 0xe ? (ERROR_sig(uc) >> 1) &
> 1 : 0,
> +#if defined(__FreeBSD__) || defined(__DragonFly__)
> +                             (TRAP_sig(uc) == 0xe ||
> +                              TRAP_sig(uc) == 0xc) ?
> +#else
> +                             TRAP_sig(uc) == 0xe ?
> +#endif
> +                             (ERROR_sig(uc) >> 1) & 1 : 0,
>                               &MASK_sig(uc));
>  }
>
> --
> 2.22.1
>
>
>