qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH qemu] s390x: sck: load into a temporary not into in1
@ 2022-01-25 12:29 Nico Boehr
  2022-01-25 13:13 ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Nico Boehr @ 2022-01-25 12:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: linux-s390, thuth, richard.henderson, david

We previously loaded into in1, but in1 is not filled during
disassembly and hence always zero. This leads to an assertion failure:

  qemu-system-s390x: /home/nrb/qemu/include/tcg/tcg.h:654: temp_idx:
  Assertion `n >= 0 && n < tcg_ctx->nb_temps' failed.`

Instead, load into a temporary and pass that to the helper.

This fixes the SCK test I sent here under TCG:
<https://www.spinics.net/lists/kvm/msg265169.html>

Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
---
 target/s390x/tcg/translate.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index 46dea733571e..dc0baec5a5f4 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -4290,9 +4290,16 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o)
 #ifndef CONFIG_USER_ONLY
 static DisasJumpType op_sck(DisasContext *s, DisasOps *o)
 {
-    tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEUQ | MO_ALIGN);
-    gen_helper_sck(cc_op, cpu_env, o->in1);
+    TCGv_i64 t1;
+
+    t1 = tcg_temp_new_i64();
+
+    tcg_gen_qemu_ld_i64(t1, o->addr1, get_mem_index(s), MO_TEUQ | MO_ALIGN);
+    gen_helper_sck(cc_op, cpu_env, t1);
     set_cc_static(s);
+
+    tcg_temp_free_i64(t1);
+
     return DISAS_NEXT;
 }
 
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH qemu] s390x: sck: load into a temporary not into in1
  2022-01-25 12:29 [PATCH qemu] s390x: sck: load into a temporary not into in1 Nico Boehr
@ 2022-01-25 13:13 ` David Hildenbrand
  2022-01-25 14:54   ` Nico Boehr
  0 siblings, 1 reply; 5+ messages in thread
From: David Hildenbrand @ 2022-01-25 13:13 UTC (permalink / raw)
  To: Nico Boehr, qemu-devel; +Cc: linux-s390, thuth, richard.henderson

On 25.01.22 13:29, Nico Boehr wrote:
> We previously loaded into in1, but in1 is not filled during
> disassembly and hence always zero. This leads to an assertion failure:
> 
>   qemu-system-s390x: /home/nrb/qemu/include/tcg/tcg.h:654: temp_idx:
>   Assertion `n >= 0 && n < tcg_ctx->nb_temps' failed.`
> 
> Instead, load into a temporary and pass that to the helper.
> 
> This fixes the SCK test I sent here under TCG:
> <https://www.spinics.net/lists/kvm/msg265169.html>
> 
> Signed-off-by: Nico Boehr <nrb@linux.ibm.com>
> ---
>  target/s390x/tcg/translate.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
> index 46dea733571e..dc0baec5a5f4 100644
> --- a/target/s390x/tcg/translate.c
> +++ b/target/s390x/tcg/translate.c
> @@ -4290,9 +4290,16 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o)
>  #ifndef CONFIG_USER_ONLY
>  static DisasJumpType op_sck(DisasContext *s, DisasOps *o)
>  {
> -    tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEUQ | MO_ALIGN);
> -    gen_helper_sck(cc_op, cpu_env, o->in1);
> +    TCGv_i64 t1;
> +
> +    t1 = tcg_temp_new_i64();
> +
> +    tcg_gen_qemu_ld_i64(t1, o->addr1, get_mem_index(s), MO_TEUQ | MO_ALIGN);
> +    gen_helper_sck(cc_op, cpu_env, t1);
>      set_cc_static(s);
> +
> +    tcg_temp_free_i64(t1);
> +
>      return DISAS_NEXT;
>  }
>  

I think you can actually just reuse in2_m2_64a, similar as we handle SCKC


diff --git a/target/s390x/tcg/insn-data.def b/target/s390x/tcg/insn-data.def
index f0af458aee..3a78606866 100644
--- a/target/s390x/tcg/insn-data.def
+++ b/target/s390x/tcg/insn-data.def
@@ -1317,7 +1317,7 @@
 /* SET ADDRESS SPACE CONTROL FAST */
     F(0xb279, SACF,    S,     Z,   0, a2, 0, 0, sacf, 0, IF_PRIV)
 /* SET CLOCK */
-    F(0xb204, SCK,     S,     Z,   la2, 0, 0, 0, sck, 0, IF_PRIV | IF_IO)
+    F(0xb204, SCK,     S,     Z,   0, m2_64a, 0, 0, sck, 0, IF_PRIV | IF_IO)
 /* SET CLOCK COMPARATOR */
     F(0xb206, SCKC,    S,     Z,   0, m2_64a, 0, 0, sckc, 0, IF_PRIV | IF_IO)
 /* SET CLOCK PROGRAMMABLE FIELD */
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index f180853e7a..c18011920e 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -4295,8 +4295,7 @@ static DisasJumpType op_stcke(DisasContext *s, DisasOps *o)
 #ifndef CONFIG_USER_ONLY
 static DisasJumpType op_sck(DisasContext *s, DisasOps *o)
 {
-    tcg_gen_qemu_ld_i64(o->in1, o->addr1, get_mem_index(s), MO_TEUQ | MO_ALIGN);
-    gen_helper_sck(cc_op, cpu_env, o->in1);
+    gen_helper_sck(cc_op, cpu_env, o->in2);
     set_cc_static(s);
     return DISAS_NEXT;
 }


-- 
Thanks,

David / dhildenb



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH qemu] s390x: sck: load into a temporary not into in1
  2022-01-25 13:13 ` David Hildenbrand
@ 2022-01-25 14:54   ` Nico Boehr
  2022-01-25 16:42     ` Philippe Mathieu-Daudé via
  0 siblings, 1 reply; 5+ messages in thread
From: Nico Boehr @ 2022-01-25 14:54 UTC (permalink / raw)
  To: David Hildenbrand, qemu-devel; +Cc: linux-s390, thuth, richard.henderson

On Tue, 2022-01-25 at 14:13 +0100, David Hildenbrand wrote:
> I think you can actually just reuse in2_m2_64a, similar as we handle
> SCKC

I tried my SCK tests with your patch, it works just as well and seems
much cleaner, thanks.

Do you want to send this or should I make a v2 and add you as
Suggested-by?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH qemu] s390x: sck: load into a temporary not into in1
  2022-01-25 14:54   ` Nico Boehr
@ 2022-01-25 16:42     ` Philippe Mathieu-Daudé via
  2022-01-25 16:44       ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-01-25 16:42 UTC (permalink / raw)
  To: Nico Boehr, David Hildenbrand, qemu-devel
  Cc: linux-s390, thuth, richard.henderson

On 25/1/22 15:54, Nico Boehr wrote:
> On Tue, 2022-01-25 at 14:13 +0100, David Hildenbrand wrote:
>> I think you can actually just reuse in2_m2_64a, similar as we handle
>> SCKC
> 
> I tried my SCK tests with your patch, it works just as well and seems
> much cleaner, thanks.
> 
> Do you want to send this or should I make a v2 and add you as
> Suggested-by?

v2 ;)



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH qemu] s390x: sck: load into a temporary not into in1
  2022-01-25 16:42     ` Philippe Mathieu-Daudé via
@ 2022-01-25 16:44       ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-01-25 16:44 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, Nico Boehr, qemu-devel
  Cc: linux-s390, thuth, richard.henderson

On 25.01.22 17:42, Philippe Mathieu-Daudé wrote:
> On 25/1/22 15:54, Nico Boehr wrote:
>> On Tue, 2022-01-25 at 14:13 +0100, David Hildenbrand wrote:
>>> I think you can actually just reuse in2_m2_64a, similar as we handle
>>> SCKC
>>
>> I tried my SCK tests with your patch, it works just as well and seems
>> much cleaner, thanks.
>>
>> Do you want to send this or should I make a v2 and add you as
>> Suggested-by?
> 
> v2 ;)

Yes, v2 please :)


-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-01-25 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-25 12:29 [PATCH qemu] s390x: sck: load into a temporary not into in1 Nico Boehr
2022-01-25 13:13 ` David Hildenbrand
2022-01-25 14:54   ` Nico Boehr
2022-01-25 16:42     ` Philippe Mathieu-Daudé via
2022-01-25 16:44       ` David Hildenbrand

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).