[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 52/60] target/s390x: Implement s390x_cpu_record_sigbus
From: |
Richard Henderson |
Subject: |
[PULL 52/60] target/s390x: Implement s390x_cpu_record_sigbus |
Date: |
Tue, 2 Nov 2021 07:07:32 -0400 |
For s390x, the only unaligned accesses that are signaled are atomic,
and we don't actually want to raise SIGBUS for those, but instead
raise a SPECIFICATION error, which the kernel will report as SIGILL.
Split out a do_unaligned_access function to share between the user-only
s390x_cpu_record_sigbus and the sysemu s390x_do_unaligned_access.
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/s390x/s390x-internal.h | 8 +++++---
target/s390x/cpu.c | 1 +
target/s390x/tcg/excp_helper.c | 27 ++++++++++++++++++++-------
3 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h
index 163aa4f94a..1a178aed41 100644
--- a/target/s390x/s390x-internal.h
+++ b/target/s390x/s390x-internal.h
@@ -270,18 +270,20 @@ ObjectClass *s390_cpu_class_by_name(const char *name);
void s390x_cpu_debug_excp_handler(CPUState *cs);
void s390_cpu_do_interrupt(CPUState *cpu);
bool s390_cpu_exec_interrupt(CPUState *cpu, int int_req);
-void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
- MMUAccessType access_type, int mmu_idx,
- uintptr_t retaddr) QEMU_NORETURN;
#ifdef CONFIG_USER_ONLY
void s390_cpu_record_sigsegv(CPUState *cs, vaddr address,
MMUAccessType access_type,
bool maperr, uintptr_t retaddr);
+void s390_cpu_record_sigbus(CPUState *cs, vaddr address,
+ MMUAccessType access_type, uintptr_t retaddr);
#else
bool s390_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
MMUAccessType access_type, int mmu_idx,
bool probe, uintptr_t retaddr);
+void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
+ MMUAccessType access_type, int mmu_idx,
+ uintptr_t retaddr) QEMU_NORETURN;
#endif
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 593dda75c4..ccdbaf84d5 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -269,6 +269,7 @@ static const struct TCGCPUOps s390_tcg_ops = {
#ifdef CONFIG_USER_ONLY
.record_sigsegv = s390_cpu_record_sigsegv,
+ .record_sigbus = s390_cpu_record_sigbus,
#else
.tlb_fill = s390_cpu_tlb_fill,
.cpu_exec_interrupt = s390_cpu_exec_interrupt,
diff --git a/target/s390x/tcg/excp_helper.c b/target/s390x/tcg/excp_helper.c
index b923d080fc..4e7648f301 100644
--- a/target/s390x/tcg/excp_helper.c
+++ b/target/s390x/tcg/excp_helper.c
@@ -82,6 +82,19 @@ void HELPER(data_exception)(CPUS390XState *env, uint32_t dxc)
tcg_s390_data_exception(env, dxc, GETPC());
}
+/*
+ * Unaligned accesses are only diagnosed with MO_ALIGN. At the moment,
+ * this is only for the atomic operations, for which we want to raise a
+ * specification exception.
+ */
+static void QEMU_NORETURN do_unaligned_access(CPUState *cs, uintptr_t retaddr)
+{
+ S390CPU *cpu = S390_CPU(cs);
+ CPUS390XState *env = &cpu->env;
+
+ tcg_s390_program_interrupt(env, PGM_SPECIFICATION, retaddr);
+}
+
#if defined(CONFIG_USER_ONLY)
void s390_cpu_do_interrupt(CPUState *cs)
@@ -106,6 +119,12 @@ void s390_cpu_record_sigsegv(CPUState *cs, vaddr address,
cpu_loop_exit_restore(cs, retaddr);
}
+void s390_cpu_record_sigbus(CPUState *cs, vaddr address,
+ MMUAccessType access_type, uintptr_t retaddr)
+{
+ do_unaligned_access(cs, retaddr);
+}
+
#else /* !CONFIG_USER_ONLY */
static inline uint64_t cpu_mmu_idx_to_asc(int mmu_idx)
@@ -593,17 +612,11 @@ void s390x_cpu_debug_excp_handler(CPUState *cs)
}
}
-/* Unaligned accesses are only diagnosed with MO_ALIGN. At the moment,
- this is only for the atomic operations, for which we want to raise a
- specification exception. */
void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr addr,
MMUAccessType access_type,
int mmu_idx, uintptr_t retaddr)
{
- S390CPU *cpu = S390_CPU(cs);
- CPUS390XState *env = &cpu->env;
-
- tcg_s390_program_interrupt(env, PGM_SPECIFICATION, retaddr);
+ do_unaligned_access(cs, retaddr);
}
static void QEMU_NORETURN monitor_event(CPUS390XState *env,
--
2.25.1
- [PULL 42/60] hw/core: Add TCGCPUOps.record_sigbus, (continued)
- [PULL 42/60] hw/core: Add TCGCPUOps.record_sigbus, Richard Henderson, 2021/11/02
- [PULL 45/60] target/arm: Implement arm_cpu_record_sigbus, Richard Henderson, 2021/11/02
- [PULL 44/60] target/alpha: Implement alpha_cpu_record_sigbus, Richard Henderson, 2021/11/02
- [PULL 43/60] linux-user: Add cpu_loop_exit_sigbus, Richard Henderson, 2021/11/02
- [PULL 46/60] linux-user/hppa: Remove EXCP_UNALIGN handling, Richard Henderson, 2021/11/02
- [PULL 48/60] target/ppc: Move SPR_DSISR setting to powerpc_excp, Richard Henderson, 2021/11/02
- [PULL 41/60] accel/tcg: Restrict TCGCPUOps::tlb_fill() to sysemu, Richard Henderson, 2021/11/02
- [PULL 47/60] target/microblaze: Do not set MO_ALIGN for user-only, Richard Henderson, 2021/11/02
- [PULL 49/60] target/ppc: Set fault address in ppc_cpu_do_unaligned_access, Richard Henderson, 2021/11/02
- [PULL 50/60] target/ppc: Restrict ppc_cpu_do_unaligned_access to sysemu, Richard Henderson, 2021/11/02
- [PULL 52/60] target/s390x: Implement s390x_cpu_record_sigbus,
Richard Henderson <=
- [PULL 54/60] target/sparc: Remove DEBUG_UNALIGNED, Richard Henderson, 2021/11/02
- [PULL 57/60] accel/tcg: Report unaligned atomics for user-only, Richard Henderson, 2021/11/02
- [PULL 56/60] target/sparc: Set fault address in sparc_cpu_do_unaligned_access, Richard Henderson, 2021/11/02
- [PULL 55/60] target/sparc: Split out build_sfsr, Richard Henderson, 2021/11/02
- [PULL 51/60] linux-user/ppc: Remove POWERPC_EXCP_ALIGN handling, Richard Henderson, 2021/11/02
- [PULL 53/60] target/sh4: Set fault address in superh_cpu_do_unaligned_access, Richard Henderson, 2021/11/02
- [PULL 58/60] accel/tcg: Report unaligned load/store for user-only, Richard Henderson, 2021/11/02
- [PULL 60/60] linux-user: Handle BUS_ADRALN in host_signal_handler, Richard Henderson, 2021/11/02
- [PULL 59/60] tcg: Add helper_unaligned_{ld,st} for user-only sigbus, Richard Henderson, 2021/11/02
- Re: [PULL 00/60] accel/tcg patch queue, Richard Henderson, 2021/11/02