* [PATCH] target/sparc: allow partial decode of v8 STBAR instructions
@ 2025-09-04 16:10 Mark Cave-Ayland
2025-09-04 16:44 ` Richard Henderson
0 siblings, 1 reply; 3+ messages in thread
From: Mark Cave-Ayland @ 2025-09-04 16:10 UTC (permalink / raw)
To: richard.henderson, qemu-devel
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);
}
if (a->mmask) {
/* Note TCG_MO_* was modeled on sparc64, so mmask matches. */
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] target/sparc: allow partial decode of v8 STBAR instructions
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
2025-09-04 21:18 ` Mark Cave-Ayland
0 siblings, 1 reply; 3+ messages in thread
From: Richard Henderson @ 2025-09-04 16:44 UTC (permalink / raw)
To: Mark Cave-Ayland, qemu-devel
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~
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] target/sparc: allow partial decode of v8 STBAR instructions
2025-09-04 16:44 ` Richard Henderson
@ 2025-09-04 21:18 ` Mark Cave-Ayland
0 siblings, 0 replies; 3+ messages in thread
From: Mark Cave-Ayland @ 2025-09-04 21:18 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 04/09/2025 17:44, Richard Henderson wrote:
> 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~
Agreed, I think your suggestion is semantically clearer. I'll send a v2 shortly.
ATB,
Mark.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-04 21:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-09-04 21:18 ` Mark Cave-Ayland
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).