[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 08/41] linux-user/host/ppc: Populate host_signal.h
From: |
Warner Losh |
Subject: |
Re: [PATCH v2 08/41] linux-user/host/ppc: Populate host_signal.h |
Date: |
Sun, 19 Sep 2021 13:34:28 -0600 |
> On Sep 18, 2021, at 12:44 PM, Richard Henderson
> <richard.henderson@linaro.org> wrote:
>
> Split host_signal_pc and host_signal_write out of user-exec.c.
> Drop the *BSD code, to be re-created under bsd-user/ later.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/host/ppc/host-signal.h | 25 ++++++++-
> linux-user/host/ppc64/host-signal.h | 2 +-
> accel/tcg/user-exec.c | 79 +----------------------------
> 3 files changed, 26 insertions(+), 80 deletions(-)
This is going to be a little work for me, but I’ll be able to snag most of it
from
the - lines in this patch. It’s a better structure, to be honest, since we were
building user-exec.c for some platforms that never really had bsd-user
and a natural consequence of this patch will stop that.
Reviewed-by: Warner Losh <imp@bsdimp.com>
> diff --git a/linux-user/host/ppc/host-signal.h
> b/linux-user/host/ppc/host-signal.h
> index f4b4d65031..e09756c691 100644
> --- a/linux-user/host/ppc/host-signal.h
> +++ b/linux-user/host/ppc/host-signal.h
> @@ -1 +1,24 @@
> -#define HOST_SIGNAL_PLACEHOLDER
> +/*
> + * host-signal.h: signal info dependent on the host architecture
> + *
> + * Copyright (C) 2021 Linaro Limited
> + *
> + * This work is licensed under the terms of the GNU GPL, version 2 or later.
> + * See the COPYING file in the top-level directory.
> + */
> +
> +#ifndef PPC_HOST_SIGNAL_H
> +#define PPC_HOST_SIGNAL_H
> +
> +static inline uintptr_t host_signal_pc(ucontext_t *uc)
> +{
> + return uc->uc_mcontext.regs->nip;
> +}
> +
> +static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
> +{
> + return uc->uc_mcontext.regs->trap != 0x400
> + && (uc->uc_mcontext.regs->dsisr & 0x02000000);
> +}
> +
> +#endif
> diff --git a/linux-user/host/ppc64/host-signal.h
> b/linux-user/host/ppc64/host-signal.h
> index f4b4d65031..a353c22a90 100644
> --- a/linux-user/host/ppc64/host-signal.h
> +++ b/linux-user/host/ppc64/host-signal.h
> @@ -1 +1 @@
> -#define HOST_SIGNAL_PLACEHOLDER
> +#include "../ppc/host-signal.h"
> diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c
> index b5d06183db..e9e530e2e1 100644
> --- a/accel/tcg/user-exec.c
> +++ b/accel/tcg/user-exec.c
> @@ -255,84 +255,7 @@ void *probe_access(CPUArchState *env, target_ulong addr,
> int size,
> return size ? g2h(env_cpu(env), addr) : NULL;
> }
>
> -#if defined(_ARCH_PPC)
> -
> -/***********************************************************************
> - * signal context platform-specific definitions
> - * From Wine
> - */
> -#ifdef linux
> -/* All Registers access - only for local access */
> -#define REG_sig(reg_name, context) \
> - ((context)->uc_mcontext.regs->reg_name)
> -/* Gpr Registers access */
> -#define GPR_sig(reg_num, context) REG_sig(gpr[reg_num], context)
> -/* Program counter */
> -#define IAR_sig(context) REG_sig(nip, context)
> -/* Machine State Register (Supervisor) */
> -#define MSR_sig(context) REG_sig(msr, context)
> -/* Count register */
> -#define CTR_sig(context) REG_sig(ctr, context)
> -/* User's integer exception register */
> -#define XER_sig(context) REG_sig(xer, context)
> -/* Link register */
> -#define LR_sig(context) REG_sig(link, context)
> -/* Condition register */
> -#define CR_sig(context) REG_sig(ccr, context)
> -
> -/* Float Registers access */
> -#define FLOAT_sig(reg_num, context) \
> - (((double *)((char *)((context)->uc_mcontext.regs + 48 * 4)))[reg_num])
> -#define FPSCR_sig(context) \
> - (*(int *)((char *)((context)->uc_mcontext.regs + (48 + 32 * 2) * 4)))
> -/* Exception Registers access */
> -#define DAR_sig(context) REG_sig(dar, context)
> -#define DSISR_sig(context) REG_sig(dsisr, context)
> -#define TRAP_sig(context) REG_sig(trap, context)
> -#endif /* linux */
> -
> -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> -#include <ucontext.h>
> -#define IAR_sig(context) ((context)->uc_mcontext.mc_srr0)
> -#define MSR_sig(context) ((context)->uc_mcontext.mc_srr1)
> -#define CTR_sig(context) ((context)->uc_mcontext.mc_ctr)
> -#define XER_sig(context) ((context)->uc_mcontext.mc_xer)
> -#define LR_sig(context) ((context)->uc_mcontext.mc_lr)
> -#define CR_sig(context) ((context)->uc_mcontext.mc_cr)
> -/* Exception Registers access */
> -#define DAR_sig(context) ((context)->uc_mcontext.mc_dar)
> -#define DSISR_sig(context) ((context)->uc_mcontext.mc_dsisr)
> -#define TRAP_sig(context) ((context)->uc_mcontext.mc_exc)
> -#endif /* __FreeBSD__|| __FreeBSD_kernel__ */
> -
> -int cpu_signal_handler(int host_signum, void *pinfo,
> - void *puc)
> -{
> - siginfo_t *info = pinfo;
> -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> - ucontext_t *uc = puc;
> -#else
> - ucontext_t *uc = puc;
> -#endif
> - unsigned long pc;
> - int is_write;
> -
> - pc = IAR_sig(uc);
> - is_write = 0;
> -#if 0
> - /* ppc 4xx case */
> - if (DSISR_sig(uc) & 0x00800000) {
> - is_write = 1;
> - }
> -#else
> - if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) {
> - is_write = 1;
> - }
> -#endif
> - return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask);
> -}
> -
> -#elif defined(__alpha__)
> +#if defined(__alpha__)
>
> int cpu_signal_handler(int host_signum, void *pinfo,
> void *puc)
> --
> 2.25.1
>
>
- [PATCH v2 00/41] linux-user: Streamline handling of SIGSEGV, Richard Henderson, 2021/09/18
- [PATCH v2 01/41] accel/tcg: Split out adjust_signal_pc, Richard Henderson, 2021/09/18
- [PATCH v2 03/41] accel/tcg: Split out handle_sigsegv_accerr_write, Richard Henderson, 2021/09/18
- [PATCH v2 02/41] accel/tcg: Move clear_helper_retaddr to cpu loop, Richard Henderson, 2021/09/18
- [PATCH v2 05/41] configure: Merge riscv32 and riscv64 host architectures, Richard Henderson, 2021/09/18
- [PATCH v2 04/41] accel/tcg: Fold cpu_exit_tb_from_sighandler into caller, Richard Henderson, 2021/09/18
- [PATCH v2 08/41] linux-user/host/ppc: Populate host_signal.h, Richard Henderson, 2021/09/18
- Re: [PATCH v2 08/41] linux-user/host/ppc: Populate host_signal.h,
Warner Losh <=
- [PATCH v2 06/41] linux-user: Reorg handling for SIGSEGV, Richard Henderson, 2021/09/18
- [PATCH v2 10/41] linux-user/host/sparc: Populate host_signal.h, Richard Henderson, 2021/09/18
- [PATCH v2 07/41] linux-user/host/x86: Populate host_signal.h, Richard Henderson, 2021/09/18
- [PATCH v2 09/41] linux-user/host/alpha: Populate host_signal.h, Richard Henderson, 2021/09/18