target/s390x: Implement s390_cpu_record_sigsegv

Move the masking of the address from cpu_loop into
s390_cpu_record_sigsegv -- this is governed by hw, not linux.
This does mean we have to raise our own exception, rather
than return to the fallback.

Use maperr to choose between PGM_PROTECTION and PGM_ADDRESSING.
Use the appropriate si_code for each in cpu_loop.

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2021-09-18 10:34:30 -07:00
parent db9aab5783
commit c8e7fef102
4 changed files with 31 additions and 19 deletions

View file

@ -24,8 +24,6 @@
#include "cpu_loop-common.h"
#include "signal-common.h"
/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */
#define S390X_FAIL_ADDR_MASK -4096LL
static int get_pgm_data_si_code(int dxc_code)
{
@ -111,12 +109,13 @@ void cpu_loop(CPUS390XState *env)
n = TARGET_ILL_ILLOPC;
goto do_signal_pc;
case PGM_PROTECTION:
force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_ACCERR,
env->__excp_addr);
break;
case PGM_ADDRESSING:
sig = TARGET_SIGSEGV;
/* XXX: check env->error_code */
n = TARGET_SEGV_MAPERR;
addr = env->__excp_addr & S390X_FAIL_ADDR_MASK;
goto do_signal;
force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR,
env->__excp_addr);
break;
case PGM_EXECUTE:
case PGM_SPECIFICATION:
case PGM_SPECIAL_OP: