* [PATCH v2 0/6] few fixes for hppa target
@ 2024-03-19 16:19 Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 1/6] target/hppa: ldcw,s uses static shift of 3 Sven Schnelle
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
Hi,
here are a few fixes for the hppa target i made while debugging
some wide mode issues.
Changes in v2:
- use Richards version for access id matching
- add trans_fic()
Sven Schnelle (6):
target/hppa: ldcw,s uses static shift of 3
target/hppa: fix shrp for wide mode
target/hppa: fix access_id check
target/hppa: exit tb on flush cache instructions
target/hppa: mask privilege bits in mfia
target/hppa: fix do_stdby_e()
target/hppa/insns.decode | 6 ++--
target/hppa/mem_helper.c | 59 +++++++++++++++++++++++++++++++++-------
target/hppa/op_helper.c | 10 +++----
target/hppa/translate.c | 19 ++++++++++---
4 files changed, 72 insertions(+), 22 deletions(-)
--
2.43.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/6] target/hppa: ldcw,s uses static shift of 3
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
@ 2024-03-19 16:19 ` Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 2/6] target/hppa: fix shrp for wide mode Sven Schnelle
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
Fixes: 96d6407f363 ("target-hppa: Implement loads and stores")
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/translate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index eb2046c5ad..6a513d7d5c 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -3085,7 +3085,7 @@ static bool trans_ldc(DisasContext *ctx, arg_ldst *a)
dest = dest_gpr(ctx, a->t);
}
- form_gva(ctx, &addr, &ofs, a->b, a->x, a->scale ? a->size : 0,
+ form_gva(ctx, &addr, &ofs, a->b, a->x, a->scale ? 3 : 0,
a->disp, a->sp, a->m, MMU_DISABLED(ctx));
/*
--
2.43.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/6] target/hppa: fix shrp for wide mode
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 1/6] target/hppa: ldcw,s uses static shift of 3 Sven Schnelle
@ 2024-03-19 16:19 ` Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 3/6] target/hppa: fix access_id check Sven Schnelle
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
Fixes: f7b775a9c075 ("target/hppa: Implement SHRPD")
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Helge Deller <deller@gmx.de>
---
target/hppa/translate.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 6a513d7d5c..8ba31567e8 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -3462,7 +3462,7 @@ static bool trans_shrp_sar(DisasContext *ctx, arg_shrp_sar *a)
/* Install the new nullification. */
cond_free(&ctx->null_cond);
if (a->c) {
- ctx->null_cond = do_sed_cond(ctx, a->c, false, dest);
+ ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
}
return nullify_end(ctx);
}
@@ -3505,7 +3505,7 @@ static bool trans_shrp_imm(DisasContext *ctx, arg_shrp_imm *a)
/* Install the new nullification. */
cond_free(&ctx->null_cond);
if (a->c) {
- ctx->null_cond = do_sed_cond(ctx, a->c, false, dest);
+ ctx->null_cond = do_sed_cond(ctx, a->c, a->d, dest);
}
return nullify_end(ctx);
}
--
2.43.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/6] target/hppa: fix access_id check
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 1/6] target/hppa: ldcw,s uses static shift of 3 Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 2/6] target/hppa: fix shrp for wide mode Sven Schnelle
@ 2024-03-19 16:19 ` Sven Schnelle
2024-03-19 18:35 ` Richard Henderson
2024-03-19 16:19 ` [PATCH v2 4/6] target/hppa: exit tb on flush cache instructions Sven Schnelle
` (2 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
PA2.0 provides 8 instead of 4 PID registers.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
target/hppa/mem_helper.c | 59 +++++++++++++++++++++++++++++++++-------
1 file changed, 49 insertions(+), 10 deletions(-)
diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 80f51e753f..f89ba91b20 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -152,6 +152,49 @@ static HPPATLBEntry *hppa_alloc_tlb_ent(CPUHPPAState *env)
return ent;
}
+#define ACCESS_ID_MASK 0xffff
+
+/* Return the set of protections allowed by a PID match. */
+static int match_prot_id_1(uint32_t access_id, uint32_t prot_id)
+{
+ if (((access_id ^ (prot_id >> 1)) & ACCESS_ID_MASK) == 0) {
+ return (prot_id & 1
+ ? PROT_EXEC | PROT_READ
+ : PROT_EXEC | PROT_READ | PROT_WRITE);
+ }
+ return 0;
+}
+
+static int match_prot_id32(CPUHPPAState *env, uint32_t access_id)
+{
+ int r, i;
+
+ for (i = CR_PID1; i <= CR_PID4; ++i) {
+ r = match_prot_id_1(access_id, env->cr[i]);
+ if (r) {
+ return r;
+ }
+ }
+ return 0;
+}
+
+static int match_prot_id64(CPUHPPAState *env, uint32_t access_id)
+{
+ int r, i;
+
+ for (i = CR_PID1; i <= CR_PID4; ++i) {
+ r = match_prot_id_1(access_id, env->cr[i]);
+ if (r) {
+ return r;
+ }
+ r = match_prot_id_1(access_id, env->cr[i] >> 32);
+ if (r) {
+ return r;
+ }
+ }
+ return 0;
+}
+
int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
int type, hwaddr *pphys, int *pprot,
HPPATLBEntry **tlb_entry)
@@ -226,16 +269,12 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
/* access_id == 0 means public page and no check is performed */
if (ent->access_id && MMU_IDX_TO_P(mmu_idx)) {
- /* If bits [31:1] match, and bit 0 is set, suppress write. */
- int match = ent->access_id * 2 + 1;
-
- if (match == env->cr[CR_PID1] || match == env->cr[CR_PID2] ||
- match == env->cr[CR_PID3] || match == env->cr[CR_PID4]) {
- prot &= PAGE_READ | PAGE_EXEC;
- if (type == PAGE_WRITE) {
- ret = EXCP_DMPI;
- goto egress;
- }
+ int access_prot = (hppa_is_pa20(env)
+ ? match_prot_id64(env, ent->access_id)
+ : match_prot_id32(env, ent->access_id));
+ if (prot & ~access_prot) {
+ ret = type & PAGE_EXEC ? EXCP_IMP : EXCP_DMPI;
+ goto egress;
}
}
--
2.43.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 4/6] target/hppa: exit tb on flush cache instructions
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
` (2 preceding siblings ...)
2024-03-19 16:19 ` [PATCH v2 3/6] target/hppa: fix access_id check Sven Schnelle
@ 2024-03-19 16:19 ` Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 5/6] target/hppa: mask privilege bits in mfia Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 6/6] target/hppa: fix do_stdby_e() Sven Schnelle
5 siblings, 0 replies; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
When the guest modifies the tb it is currently executing from,
it executes a fic instruction. Exit the tb on such instruction,
otherwise we might execute stale code.
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
target/hppa/insns.decode | 6 +++---
target/hppa/translate.c | 11 +++++++++++
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode
index f5a3f02fd1..409e3ea9c9 100644
--- a/target/hppa/insns.decode
+++ b/target/hppa/insns.decode
@@ -143,9 +143,9 @@ getshadowregs 1111 1111 1111 1101 1110 1010 1101 0010
nop 000001 ----- ----- -- 11001010 0 ----- # fdc, disp
nop_addrx 000001 ..... ..... -- 01001010 . ----- @addrx # fdc, index
nop_addrx 000001 ..... ..... -- 01001011 . ----- @addrx # fdce
-nop_addrx 000001 ..... ..... --- 0001010 . ----- @addrx # fic 0x0a
-nop_addrx 000001 ..... ..... -- 01001111 . 00000 @addrx # fic 0x4f
-nop_addrx 000001 ..... ..... --- 0001011 . ----- @addrx # fice
+fic 000001 ..... ..... --- 0001010 . ----- @addrx # fic 0x0a
+fic 000001 ..... ..... -- 01001111 . 00000 @addrx # fic 0x4f
+fic 000001 ..... ..... --- 0001011 . ----- @addrx # fice
nop_addrx 000001 ..... ..... -- 01001110 . 00000 @addrx # pdc
probe 000001 b:5 ri:5 sp:2 imm:1 100011 write:1 0 t:5
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 8ba31567e8..46da546eb9 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -2293,6 +2293,17 @@ static bool trans_nop_addrx(DisasContext *ctx, arg_ldst *a)
return true;
}
+static bool trans_fic(DisasContext *ctx, arg_fic *a)
+{
+ arg_ldst b;
+
+ b.b = a->b;
+ b.x = a->x;
+ b.m = a->m;
+ ctx->base.is_jmp = DISAS_IAQ_N_STALE;
+ return trans_nop_addrx(ctx, &b);
+}
+
static bool trans_probe(DisasContext *ctx, arg_probe *a)
{
TCGv_i64 dest, ofs;
--
2.43.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 5/6] target/hppa: mask privilege bits in mfia
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
` (3 preceding siblings ...)
2024-03-19 16:19 ` [PATCH v2 4/6] target/hppa: exit tb on flush cache instructions Sven Schnelle
@ 2024-03-19 16:19 ` Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 6/6] target/hppa: fix do_stdby_e() Sven Schnelle
5 siblings, 0 replies; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
mfia should return only the iaoq bits without privilege
bits.
Fixes: 98a9cb792c8 ("target-hppa: Implement system and memory-management insns")
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Helge Deller <deller@gmx.de>
---
target/hppa/translate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index 46da546eb9..51bf1b06c9 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -1961,7 +1961,7 @@ static bool trans_mfia(DisasContext *ctx, arg_mfia *a)
{
unsigned rt = a->t;
TCGv_i64 tmp = dest_gpr(ctx, rt);
- tcg_gen_movi_i64(tmp, ctx->iaoq_f);
+ tcg_gen_movi_i64(tmp, ctx->iaoq_f & ~3ULL);
save_gpr(ctx, rt, tmp);
cond_free(&ctx->null_cond);
--
2.43.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 6/6] target/hppa: fix do_stdby_e()
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
` (4 preceding siblings ...)
2024-03-19 16:19 ` [PATCH v2 5/6] target/hppa: mask privilege bits in mfia Sven Schnelle
@ 2024-03-19 16:19 ` Sven Schnelle
5 siblings, 0 replies; 8+ messages in thread
From: Sven Schnelle @ 2024-03-19 16:19 UTC (permalink / raw
To: Richard Henderson; +Cc: qemu-devel, Helge Deller, Sven Schnelle
stdby,e,m was writing data from the wrong half of the register
into memory for cases 0-3.
Fixes: 25460fc5a71 ("target/hppa: Implement STDBY")
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
target/hppa/op_helper.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/target/hppa/op_helper.c b/target/hppa/op_helper.c
index 480fe80844..6cf49f33b7 100644
--- a/target/hppa/op_helper.c
+++ b/target/hppa/op_helper.c
@@ -281,17 +281,17 @@ static void do_stdby_e(CPUHPPAState *env, target_ulong addr, uint64_t val,
case 3:
/* The 3 byte store must appear atomic. */
if (parallel) {
- atomic_store_mask32(env, addr - 3, val, 0xffffff00u, ra);
+ atomic_store_mask32(env, addr - 3, val >> 32, 0xffffff00u, ra);
} else {
- cpu_stw_data_ra(env, addr - 3, val >> 16, ra);
- cpu_stb_data_ra(env, addr - 1, val >> 8, ra);
+ cpu_stw_data_ra(env, addr - 3, val >> 48, ra);
+ cpu_stb_data_ra(env, addr - 1, val >> 40, ra);
}
break;
case 2:
- cpu_stw_data_ra(env, addr - 2, val >> 16, ra);
+ cpu_stw_data_ra(env, addr - 2, val >> 48, ra);
break;
case 1:
- cpu_stb_data_ra(env, addr - 1, val >> 24, ra);
+ cpu_stb_data_ra(env, addr - 1, val >> 56, ra);
break;
default:
/* Nothing is stored, but protection is checked and the
--
2.43.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/6] target/hppa: fix access_id check
2024-03-19 16:19 ` [PATCH v2 3/6] target/hppa: fix access_id check Sven Schnelle
@ 2024-03-19 18:35 ` Richard Henderson
0 siblings, 0 replies; 8+ messages in thread
From: Richard Henderson @ 2024-03-19 18:35 UTC (permalink / raw
To: Sven Schnelle; +Cc: qemu-devel, Helge Deller
On 3/19/24 06:19, Sven Schnelle wrote:
> PA2.0 provides 8 instead of 4 PID registers.
>
> Signed-off-by: Sven Schnelle <svens@stackframe.org>
> ---
> target/hppa/mem_helper.c | 59 +++++++++++++++++++++++++++++++++-------
> 1 file changed, 49 insertions(+), 10 deletions(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> +/* Return the set of protections allowed by a PID match. */
> +static int match_prot_id_1(uint32_t access_id, uint32_t prot_id)
> +{
> + if (((access_id ^ (prot_id >> 1)) & ACCESS_ID_MASK) == 0) {
> + return (prot_id & 1
> + ? PROT_EXEC | PROT_READ
> + : PROT_EXEC | PROT_READ | PROT_WRITE);
Tabs? Anyway, weird indentation...
r~
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-03-19 18:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-19 16:19 [PATCH v2 0/6] few fixes for hppa target Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 1/6] target/hppa: ldcw,s uses static shift of 3 Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 2/6] target/hppa: fix shrp for wide mode Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 3/6] target/hppa: fix access_id check Sven Schnelle
2024-03-19 18:35 ` Richard Henderson
2024-03-19 16:19 ` [PATCH v2 4/6] target/hppa: exit tb on flush cache instructions Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 5/6] target/hppa: mask privilege bits in mfia Sven Schnelle
2024-03-19 16:19 ` [PATCH v2 6/6] target/hppa: fix do_stdby_e() Sven Schnelle
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.