[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 07/55] target/mips: Implement do_unaligned_access for user
From: |
Peter Maydell |
Subject: |
Re: [PATCH v2 07/55] target/mips: Implement do_unaligned_access for user-only |
Date: |
Thu, 19 Aug 2021 20:33:40 +0100 |
On Tue, 3 Aug 2021 at 05:18, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> linux-user/mips/cpu_loop.c | 20 ++++++++++++++++----
> target/mips/cpu.c | 2 +-
> target/mips/tcg/op_helper.c | 3 +--
> target/mips/tcg/user/tlb_helper.c | 23 +++++++++++------------
> 4 files changed, 29 insertions(+), 19 deletions(-)
>
> diff --git a/linux-user/mips/cpu_loop.c b/linux-user/mips/cpu_loop.c
> index 9d813ece4e..51f4eb65a6 100644
> --- a/linux-user/mips/cpu_loop.c
> +++ b/linux-user/mips/cpu_loop.c
> @@ -158,12 +158,24 @@ done_syscall:
> break;
> case EXCP_TLBL:
> case EXCP_TLBS:
> - case EXCP_AdEL:
> - case EXCP_AdES:
> info.si_signo = TARGET_SIGSEGV;
> info.si_errno = 0;
> - /* XXX: check env->error_code */
> - info.si_code = TARGET_SEGV_MAPERR;
> + info.si_code = (env->error_code & EXCP_TLB_NOMATCH
> + ? TARGET_SEGV_MAPERR : TARGET_SEGV_ACCERR);
> + info._sifields._sigfault._addr = env->CP0_BadVAddr;
> + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
> + break;
> + case EXCP_AdEL:
> + case EXCP_AdES:
> + /*
> + * Note that on real hw AdE is also raised for access to a
> + * kernel address from user mode instead of a TLB error.
> + * For simplicity, we do not distinguish this in the user
> + * version of mips_cpu_tlb_fill so only unaligned comes here.
> + */
> + info.si_signo = TARGET_SIGBUS;
> + info.si_errno = 0;
> + info.si_code = TARGET_BUS_ADRALN;
The MIPS kernel code doesn't use si_code BUS_ADRALN for alignment
errors, as far as I can see -- it just calls force_sig(SIGBUS):
https://elixir.bootlin.com/linux/latest/source/arch/mips/kernel/unaligned.c#L557
which gets you the same thing our force_sig() does: a code
of SI_KERNEL. So I think we should be calling
force_sig(TARGET_SIGBUS);
here rather than filling in a target_siginfo_t and calling
queue_signal().
> info._sifields._sigfault._addr = env->CP0_BadVAddr;
> queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info);
> break;
thanks
-- PMM
- Re: [PATCH v2 02/55] hw/core: Make do_unaligned_access available to user-only, (continued)
- [PATCH v2 03/55] target/alpha: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 04/55] target/arm: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 05/55] target/hppa: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 06/55] target/microblaze: Do not set MO_ALIGN for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 07/55] target/mips: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- Re: [PATCH v2 07/55] target/mips: Implement do_unaligned_access for user-only,
Peter Maydell <=
- [PATCH v2 08/55] target/ppc: Move SPR_DSISR setting to powerpc_excp, Richard Henderson, 2021/08/03
- [PATCH v2 10/55] target/ppc: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 11/55] target/riscv: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 09/55] target/ppc: Set fault address in ppc_cpu_do_unaligned_access, Richard Henderson, 2021/08/03
- [PATCH v2 13/55] target/sh4: Set fault address in superh_cpu_do_unaligned_access, Richard Henderson, 2021/08/03
- [PATCH v2 14/55] target/sh4: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03
- [PATCH v2 16/55] target/sparc: Split out build_sfsr, Richard Henderson, 2021/08/03
- [PATCH v2 12/55] target/s390x: Implement do_unaligned_access for user-only, Richard Henderson, 2021/08/03