diff mbox series

[v3,01/14] target/s390x: Make CKSM raise an exception if R2 is odd

Message ID 20230719221310.1968845-2-iii@linux.ibm.com
State New
Headers show
Series target/s390x: Miscellaneous TCG fixes, part 2 | expand

Commit Message

Ilya Leoshkevich July 19, 2023, 10:11 p.m. UTC
R2 designates an even-odd register pair; the instruction should raise
a specification exception when R2 is not even.

Cc: qemu-stable@nongnu.org
Fixes: e023e832d0ac ("s390x: translate engine for s390x CPU")
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
---
 target/s390x/tcg/translate.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Comments

Richard Henderson July 23, 2023, 4:14 p.m. UTC | #1
On 7/19/23 23:11, Ilya Leoshkevich wrote:
> R2 designates an even-odd register pair; the instruction should raise
> a specification exception when R2 is not even.
> 
> Cc: qemu-stable@nongnu.org
> Fixes: e023e832d0ac ("s390x: translate engine for s390x CPU")
> Reviewed-by: David Hildenbrand <david@redhat.com>
> Signed-off-by: Ilya Leoshkevich <iii@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 6661b27efa4..2f61e879878 100644
> --- a/target/s390x/tcg/translate.c
> +++ b/target/s390x/tcg/translate.c
> @@ -1991,11 +1991,18 @@ static DisasJumpType op_cxlgb(DisasContext *s, DisasOps *o)
>   static DisasJumpType op_cksm(DisasContext *s, DisasOps *o)
>   {
>       int r2 = get_field(s, r2);
> -    TCGv_i128 pair = tcg_temp_new_i128();
> -    TCGv_i64 len = tcg_temp_new_i64();
> +    TCGv_i128 pair;
> +    TCGv_i64 len;
> +
> +    if (r2 & 1) {
> +        gen_program_exception(s, PGM_SPECIFICATION);
> +        return DISAS_NORETURN;
> +    }

Ideally, SPEC_r2_even would be set, handling this earlier.
Perhaps adding an "in2_ra2_E" might be helpful?


r~
diff mbox series

Patch

diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index 6661b27efa4..2f61e879878 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -1991,11 +1991,18 @@  static DisasJumpType op_cxlgb(DisasContext *s, DisasOps *o)
 static DisasJumpType op_cksm(DisasContext *s, DisasOps *o)
 {
     int r2 = get_field(s, r2);
-    TCGv_i128 pair = tcg_temp_new_i128();
-    TCGv_i64 len = tcg_temp_new_i64();
+    TCGv_i128 pair;
+    TCGv_i64 len;
+
+    if (r2 & 1) {
+        gen_program_exception(s, PGM_SPECIFICATION);
+        return DISAS_NORETURN;
+    }
 
+    pair = tcg_temp_new_i128();
     gen_helper_cksm(pair, cpu_env, o->in1, o->in2, regs[r2 + 1]);
     set_cc_static(s);
+    len = tcg_temp_new_i64();
     tcg_gen_extr_i128_i64(o->out, len, pair);
 
     tcg_gen_add_i64(regs[r2], regs[r2], len);