[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 14/27] target/s390x: Assert masking of psw.addr in cpu_get_tb_
From: |
Richard Henderson |
Subject: |
[PATCH v2 14/27] target/s390x: Assert masking of psw.addr in cpu_get_tb_cpu_state |
Date: |
Sun, 11 Dec 2022 09:27:49 -0600 |
When changing modes via SAM, we raise a specification exception if the
new PC is out of range. The masking in s390x_tr_init_disas_context
was too late to be correct, but may be removed. Add a debugging
assert in cpu_get_tb_cpu_state.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/s390x/cpu.h | 20 ++++++++++++++------
target/s390x/tcg/translate.c | 6 +-----
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 7d6d01325b..c7eeebfc53 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -379,17 +379,25 @@ static inline int cpu_mmu_index(CPUS390XState *env, bool
ifetch)
}
static inline void cpu_get_tb_cpu_state(CPUS390XState* env, target_ulong *pc,
- target_ulong *cs_base, uint32_t *flags)
+ target_ulong *cs_base, uint32_t
*pflags)
{
- *pc = env->psw.addr;
- *cs_base = env->ex_value;
- *flags = (env->psw.mask >> FLAG_MASK_PSW_SHIFT) & FLAG_MASK_PSW;
+ int flags = (env->psw.mask >> FLAG_MASK_PSW_SHIFT) & FLAG_MASK_PSW;
if (env->cregs[0] & CR0_AFP) {
- *flags |= FLAG_MASK_AFP;
+ flags |= FLAG_MASK_AFP;
}
if (env->cregs[0] & CR0_VECTOR) {
- *flags |= FLAG_MASK_VECTOR;
+ flags |= FLAG_MASK_VECTOR;
}
+ *pflags = flags;
+ *cs_base = env->ex_value;
+ *pc = env->psw.addr;
+#ifdef CONFIG_DEBUG_TCG
+ if (!(flags & FLAG_MASK_32)) {
+ assert(*pc <= 0xffffff);
+ } else if (!(flags & FLAG_MASK_64)) {
+ assert(*pc <= 0x7fffffff);
+ }
+#endif
}
/* PER bits from control register 9 */
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index c9afa28c60..fcf0c52b8d 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -6491,11 +6491,7 @@ static void s390x_tr_init_disas_context(DisasContextBase
*dcbase, CPUState *cs)
{
DisasContext *dc = container_of(dcbase, DisasContext, base);
- /* 31-bit mode */
- if (!(dc->base.tb->flags & FLAG_MASK_64)) {
- dc->base.pc_first &= 0x7fffffff;
- dc->base.pc_next = dc->base.pc_first;
- }
+ /* Note cpu_get_tb_cpu_state asserts PC is masked for the mode. */
dc->cc_op = CC_OP_DYNAMIC;
dc->ex_value = dc->base.tb->cs_base;
--
2.34.1
- [PATCH v2 02/27] target/s390x: Use tcg_constant_* for DisasCompare, (continued)
- [PATCH v2 02/27] target/s390x: Use tcg_constant_* for DisasCompare, Richard Henderson, 2022/12/11
- [PATCH v2 05/27] tests/tcg/s390x: Add bal.S, Richard Henderson, 2022/12/11
- [PATCH v2 11/27] target/s390x: Use gen_psw_addr_disp in save_link_info, Richard Henderson, 2022/12/11
- [PATCH v2 07/27] target/s390x: Change help_goto_direct to work on displacements, Richard Henderson, 2022/12/11
- [PATCH v2 16/27] target/s390x: Don't set gbea for user-only, Richard Henderson, 2022/12/11
- [PATCH v2 18/27] target/s390x: Disable conditional branch-to-next for PER, Richard Henderson, 2022/12/11
- [PATCH v2 13/27] target/s390x: Use ilen instead in branches, Richard Henderson, 2022/12/11
- [PATCH v2 14/27] target/s390x: Assert masking of psw.addr in cpu_get_tb_cpu_state,
Richard Henderson <=
- [PATCH v2 15/27] target/s390x: Add disp argument to update_psw_addr, Richard Henderson, 2022/12/11
- [PATCH v2 09/27] target/s390x: Remove pc argument to pc_to_link_into, Richard Henderson, 2022/12/11
- [PATCH v2 17/27] target/s390x: Introduce per_enabled, Richard Henderson, 2022/12/11
- [PATCH v2 08/27] target/s390x: Introduce gen_psw_addr_disp, Richard Henderson, 2022/12/11
- [PATCH v2 10/27] target/s390x: Use gen_psw_addr_disp in pc_to_link_info, Richard Henderson, 2022/12/11
- [PATCH v2 12/27] target/s390x: Use gen_psw_addr_disp in op_sam, Richard Henderson, 2022/12/11
- [PATCH v2 19/27] target/s390x: Introduce help_goto_indirect, Richard Henderson, 2022/12/11