qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: deller@kernel.org, qemu-devel@nongnu.org
Cc: Helge Deller <deller@gmx.de>
Subject: Re: [PATCH 03/13] target/hppa: Fix PSW_W and PSW_E bits in rsm, ssm and mtsm
Date: Thu, 8 Feb 2024 10:43:26 -1000	[thread overview]
Message-ID: <2736d6d1-5585-4bbd-82c7-a3b7f5c87fb9@linaro.org> (raw)
In-Reply-To: <20240207182023.36316-4-deller@kernel.org>

On 2/7/24 08:20, deller@kernel.org wrote:
>   #define PSW_E            0x04000000
> +#define PSW_E_BIT                37 /* PA2.0 only */
>   #define PSW_W            0x08000000 /* PA2.0 only */
> +#define PSW_W_BIT                36 /* PA2.0 only */
...
> +target_ulong HELPER(get_system_mask)(CPUHPPAState *env)
> +{
> +    target_ulong psw = env->psw;
> +
> +    /* mask out invalid bits */
> +    target_ulong psw_new = psw & PSW_SM;
> +
> +    /* ssm/rsm instructions number PSW_W and PSW_E differently */
> +    psw_new &= ~PSW_W;
> +    if (psw & PSW_W) {
> +        psw_new |= 1ull << (63 - PSW_W_BIT);
> +    }

Um, this has changed nothing, since 1 << (63 - 36) == 0x8000000 == PSW_W.

The conversion of PSW_SM_W to PSW_W happens in expand_sm_imm().
There's a comment there about keeping unimplemented bits disabled, including PSW_E. 
Perhaps this is the wrong layer in which to do this?

In any case, what is the actual problem that you're seeing?  Because it *isn't* that we 
were not considering the different placement of the bits, as your commit message suggests.

> diff --git a/target/hppa/translate.c b/target/hppa/translate.c
> index 53ec57ee86..10fdc0813d 100644
> --- a/target/hppa/translate.c
> +++ b/target/hppa/translate.c
> @@ -2163,13 +2163,20 @@ static bool trans_rsm(DisasContext *ctx, arg_rsm *a)
>       nullify_over(ctx);
>   
>       tmp = tcg_temp_new_i64();
> -    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
> -    tcg_gen_andi_i64(tmp, tmp, ~a->i);
> -    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
> -    save_gpr(ctx, a->t, tmp);
> +    if (a->t != 0) {
> +        gen_helper_get_system_mask(tmp, tcg_env);
> +        save_gpr(ctx, a->t, tmp);
> +    }

If a->t == 0, tmp is uninitialized...

> +
> +    if (a->i) {
> +        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));

... but read here.

> @@ -2183,11 +2190,17 @@ static bool trans_ssm(DisasContext *ctx, arg_ssm *a)
>       nullify_over(ctx);
>   
>       tmp = tcg_temp_new_i64();
> -    tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
> -    tcg_gen_ori_i64(tmp, tmp, a->i);
> -    gen_helper_swap_system_mask(tmp, tcg_env, tmp);
> -    save_gpr(ctx, a->t, tmp);
> +    if (a->t != 0) {
> +        gen_helper_get_system_mask(tmp, tcg_env);
> +        save_gpr(ctx, a->t, tmp);
> +    }
> +
> +    if (a->i) {
> +        tcg_gen_ld_i64(tmp, tcg_env, offsetof(CPUHPPAState, psw));
> +        tcg_gen_ori_i64(tmp, tmp, a->i);

Likewise.


r~


  reply	other threads:[~2024-02-08 20:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07 18:20 [PATCH 00/13] target/hppa: Enhancements and fixes deller
2024-02-07 18:20 ` [PATCH 01/13] disas/hppa: Add disassembly for qemu specific instructions deller
2024-02-08 20:12   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 02/13] target/hppa: Add "diag 0x101" for console output support deller
2024-02-08 20:15   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 03/13] target/hppa: Fix PSW_W and PSW_E bits in rsm, ssm and mtsm deller
2024-02-08 20:43   ` Richard Henderson [this message]
2024-02-09  8:55     ` Helge Deller
2024-02-07 18:20 ` [PATCH 04/13] hw/pci-host/astro: Avoid aborting on access failure deller
2024-02-08 20:45   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 05/13] hw/pci-host/astro: Implement Hard Fail and Soft Fail mode deller
2024-02-08 20:46   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 06/13] lasi: allow access to LAN MAC address registers deller
2024-02-07 18:20 ` [PATCH 07/13] target/hppa: Implement do_transaction_failed handler for I/O errors deller
2024-02-07 18:20 ` [PATCH 08/13] lasi: Add reset I/O ports for LASI audio and FDC deller
2024-02-07 18:20 ` [PATCH 09/13] target/hppa: Allow read-access to PSW with rsm 0, reg instruction deller
2024-02-08 21:12   ` [PATCH 09/13] target/hppa: Allow read-access to PSW with rsm 0,reg instruction Richard Henderson
2024-02-07 18:20 ` [PATCH 10/13] target/hppa: Check privilege only when PSW.P is set deller
2024-02-08 21:14   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 11/13] target/hppa: PDC_BTLB_INFO uses 32-bit ints deller
2024-02-08 21:17   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 12/13] target/hppa: Update SeaBIOS-hppa to version 16 deller
2024-02-08 21:19   ` Richard Henderson
2024-02-07 18:20 ` [PATCH 13/13] hw/hppa/machine: Load 64-bit firmware on 64-bit machines deller
2024-02-08 21:18   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2736d6d1-5585-4bbd-82c7-a3b7f5c87fb9@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=deller@gmx.de \
    --cc=deller@kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).