[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 26/88] target/hppa: Fix hppa64 addressing
|
From: |
Richard Henderson |
|
Subject: |
[PATCH v3 26/88] target/hppa: Fix hppa64 addressing |
|
Date: |
Wed, 1 Nov 2023 18:29:14 -0700 |
In form_gva and cpu_get_tb_cpu_state, we must truncate when PSW_W == 0.
In space_select, the bits that choose the space depend on PSW_W.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/cpu.h | 7 +++----
target/hppa/translate.c | 22 +++++++++++++---------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 2999df9ff9..cb838defb0 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -302,7 +302,7 @@ static inline target_ulong hppa_form_gva_psw(target_ureg
psw, uint64_t spc,
#ifdef CONFIG_USER_ONLY
return off;
#else
- off &= (psw & PSW_W ? 0x3fffffffffffffffull : 0xffffffffull);
+ off &= psw & PSW_W ? MAKE_64BIT_MASK(0, 62) : MAKE_64BIT_MASK(0, 32);
return spc | off;
#endif
}
@@ -343,9 +343,8 @@ static inline void cpu_get_tb_cpu_state(CPUHPPAState *env,
vaddr *pc,
flags |= env->psw & (PSW_W | PSW_C | PSW_D | PSW_P);
flags |= (env->iaoq_f & 3) << TB_FLAG_PRIV_SHIFT;
- *pc = (env->psw & PSW_C
- ? hppa_form_gva_psw(env->psw, env->iasq_f, env->iaoq_f & -4)
- : env->iaoq_f & -4);
+ *pc = hppa_form_gva_psw(env->psw, (env->psw & PSW_C ? env->iasq_f : 0),
+ env->iaoq_f & -4);
*cs_base = env->iasq_f;
/* Insert a difference between IAOQ_B and IAOQ_F within the otherwise zero
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 44c9911720..4e0bc48b09 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -710,6 +710,13 @@ static bool nullify_end(DisasContext *ctx)
return true;
}
+static target_ureg gva_offset_mask(DisasContext *ctx)
+{
+ return (ctx->tb_flags & PSW_W
+ ? MAKE_64BIT_MASK(0, 62)
+ : MAKE_64BIT_MASK(0, 32));
+}
+
static void copy_iaoq_entry(TCGv_reg dest, target_ureg ival, TCGv_reg vval)
{
if (unlikely(ival == -1)) {
@@ -1398,7 +1405,8 @@ static TCGv_i64 space_select(DisasContext *ctx, int sp,
TCGv_reg base)
tmp = tcg_temp_new();
spc = tcg_temp_new_tl();
- tcg_gen_shri_reg(tmp, base, TARGET_REGISTER_BITS - 5);
+ /* Extract top 2 bits of the address, shift left 3 for uint64_t index. */
+ tcg_gen_shri_reg(tmp, base, (ctx->tb_flags & PSW_W ? 64 : 32) - 5);
tcg_gen_andi_reg(tmp, tmp, 030);
tcg_gen_trunc_reg_ptr(ptr, tmp);
@@ -1415,6 +1423,7 @@ static void form_gva(DisasContext *ctx, TCGv_tl *pgva,
TCGv_reg *pofs,
{
TCGv_reg base = load_gpr(ctx, rb);
TCGv_reg ofs;
+ TCGv_tl addr;
/* Note that RX is mutually exclusive with DISP. */
if (rx) {
@@ -1429,18 +1438,13 @@ static void form_gva(DisasContext *ctx, TCGv_tl *pgva,
TCGv_reg *pofs,
}
*pofs = ofs;
-#ifdef CONFIG_USER_ONLY
- *pgva = (modify <= 0 ? ofs : base);
-#else
- TCGv_tl addr = tcg_temp_new_tl();
+ *pgva = addr = tcg_temp_new_tl();
tcg_gen_extu_reg_tl(addr, modify <= 0 ? ofs : base);
- if (ctx->tb_flags & PSW_W) {
- tcg_gen_andi_tl(addr, addr, 0x3fffffffffffffffull);
- }
+ tcg_gen_andi_tl(addr, addr, gva_offset_mask(ctx));
+#ifndef CONFIG_USER_ONLY
if (!is_phys) {
tcg_gen_or_tl(addr, addr, space_select(ctx, sp, base));
}
- *pgva = addr;
#endif
}
--
2.34.1
- [PATCH v3 12/88] target/hppa: Fix hppa64 case in machine.c, (continued)
- [PATCH v3 12/88] target/hppa: Fix hppa64 case in machine.c, Richard Henderson, 2023/11/01
- [PATCH v3 19/88] target/hppa: Introduce TYPE_HPPA64_CPU, Richard Henderson, 2023/11/01
- [PATCH v3 16/88] target/hppa: Fix do_add, do_sub for hppa64, Richard Henderson, 2023/11/01
- [PATCH v3 23/88] target/hppa: Update cpu_hppa_get/put_psw for hppa64, Richard Henderson, 2023/11/01
- [PATCH v3 13/88] target/hppa: Fix load in do_load_32, Richard Henderson, 2023/11/01
- [PATCH v3 11/88] target/hppa: Remove load_const, Richard Henderson, 2023/11/01
- [PATCH v3 22/88] target/hppa: Implement hppa_cpu_class_by_name, Richard Henderson, 2023/11/01
- [PATCH v3 25/88] target/hppa: Adjust hppa_cpu_dump_state for hppa64, Richard Henderson, 2023/11/01
- [PATCH v3 24/88] target/hppa: Handle absolute addresses for pa2.0, Richard Henderson, 2023/11/01
- [PATCH v3 21/88] target/hppa: Implement cpu_list, Richard Henderson, 2023/11/01
- [PATCH v3 26/88] target/hppa: Fix hppa64 addressing,
Richard Henderson <=
- [PATCH v3 31/88] target/hppa: sar register allows only 5 bits on 32-bit CPU, Richard Henderson, 2023/11/01
- [PATCH v3 29/88] target/hppa: Use copy_iaoq_entry for link in do_ibranch, Richard Henderson, 2023/11/01
- [PATCH v3 33/88] target/hppa: Pass d to do_sub_cond, Richard Henderson, 2023/11/01
- [PATCH v3 34/88] target/hppa: Pass d to do_log_cond, Richard Henderson, 2023/11/01
- [PATCH v3 30/88] target/hppa: Mask inputs in copy_iaoq_entry, Richard Henderson, 2023/11/01
- [PATCH v3 08/88] tcg: Improve expansion of deposit into a constant, Richard Henderson, 2023/11/01
- [PATCH v3 20/88] target/hppa: Make HPPA_BTLB_ENTRIES variable, Richard Henderson, 2023/11/01
- [PATCH v3 27/88] target/hppa: Pass DisasContext to copy_iaoq_entry, Richard Henderson, 2023/11/01
- [PATCH v3 28/88] target/hppa: Always use copy_iaoq_entry to set cpu_iaoq_[fb], Richard Henderson, 2023/11/01
- [PATCH v3 32/88] target/hppa: Pass d to do_cond, Richard Henderson, 2023/11/01