qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, qemu-devel@nongnu.org
Subject: Re: [PATCH] target/sparc: allow partial decode of v8 STBAR instructions
Date: Thu, 4 Sep 2025 18:44:06 +0200	[thread overview]
Message-ID: <611cba04-c567-439e-8f52-4d5f74828083@linaro.org> (raw)
In-Reply-To: <20250904161026.804239-1-mark.cave-ayland@ilande.co.uk>

On 9/4/25 18:10, Mark Cave-Ayland wrote:
> Solaris 8 appears to have a bug whereby it executes v9 MEMBAR instructions
> when booting a freshly installed image. According to the SPARC v8
> architecture manual, whilst bits 14 and bits 13-0 of the "Read State Register
> Instructions" are notionally zero, they are marked as unused (i.e. ignored).
> In effect the v9 MEMBAR instruction becomes a v8 STBAR instruction on a 32-bit
> SPARC CPU.
> 
> Adjust the avail_32() logic in trans_MEMBAR() so that if a v9 MEMBAR
> instruction is executed on 32-bit SPARC, the equivalent of a v8 STBAR
> instruction is executed instead.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Fixes: af25071c1d ("target/sparc: Move RDASR, STBAR, MEMBAR to decodetree")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3097
> ---
>   target/sparc/translate.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/target/sparc/translate.c b/target/sparc/translate.c
> index b922e53bf1..9efefe41c6 100644
> --- a/target/sparc/translate.c
> +++ b/target/sparc/translate.c
> @@ -2832,7 +2832,15 @@ static bool trans_STBAR(DisasContext *dc, arg_STBAR *a)
>   static bool trans_MEMBAR(DisasContext *dc, arg_MEMBAR *a)
>   {
>       if (avail_32(dc)) {
> -        return false;
> +        /*
> +         * At least Solaris 8 executes v9 MEMBAR instructions such as
> +         * 0x8143e008 during boot. According to the SPARC v8 architecture
> +         * manual, bits 13 and 12-0 are unused (notionally zero) so in
> +         * this case if we assume the unused bits are not decoded then
> +         * the instruction becomes 0x8143c000, or the equivalent of STBAR.
> +         */
> +        tcg_gen_mb(TCG_MO_ST_ST | TCG_BAR_SC);
> +        return advance_pc(dc);
>       }

You could avoid replicating this and do

     return trans_STBAR(dc, NULL);

Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~


  reply	other threads:[~2025-09-04 16:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-04 16:10 [PATCH] target/sparc: allow partial decode of v8 STBAR instructions Mark Cave-Ayland
2025-09-04 16:44 ` Richard Henderson [this message]
2025-09-04 21:18   ` Mark Cave-Ayland

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=611cba04-c567-439e-8f52-4d5f74828083@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --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).