[PATCH v3 0/2] target/s390x: Fix emulation of C(G)HRL

Nina Schoetterl-Glausch posted 2 patches 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230310114157.3024170-1-nsg@linux.ibm.com
Maintainers: Richard Henderson <richard.henderson@linaro.org>, David Hildenbrand <david@redhat.com>, Ilya Leoshkevich <iii@linux.ibm.com>, Thomas Huth <thuth@redhat.com>
target/s390x/tcg/insn-data.h.inc |  4 +-
target/s390x/tcg/translate.c     |  7 +++
tests/tcg/s390x/chrl.c           | 80 ++++++++++++++++++++++++++++++++
tests/tcg/s390x/Makefile.target  |  1 +
4 files changed, 90 insertions(+), 2 deletions(-)
create mode 100644 tests/tcg/s390x/chrl.c
[PATCH v3 0/2] target/s390x: Fix emulation of C(G)HRL
Posted by Nina Schoetterl-Glausch 1 year, 1 month ago
The second operand of COMPARE HALFWORD RELATIVE LONG is a signed
halfword, it does not have the same size as the first operand.
Fix this and add a tcg test for c(g)hrl.

v2 -> v3
 * pick up R-b's (thanks Richard)
 * get rid of tabs in inline asm (cosmetic only)

v1 -> v2
 * rebase on newer version

Nina Schoetterl-Glausch (2):
  target/s390x: Fix emulation of C(G)HRL
  tests/tcg/s390x: Add C(G)HRL test

 target/s390x/tcg/insn-data.h.inc |  4 +-
 target/s390x/tcg/translate.c     |  7 +++
 tests/tcg/s390x/chrl.c           | 80 ++++++++++++++++++++++++++++++++
 tests/tcg/s390x/Makefile.target  |  1 +
 4 files changed, 90 insertions(+), 2 deletions(-)
 create mode 100644 tests/tcg/s390x/chrl.c

Range-diff against v2:
1:  228a1d9cfb ! 1:  899db74823 target/s390x: Fix emulation of C(G)HRL
    @@ Commit message
         halfword, it does not have the same size as the first operand.
     
         Fixes: a7e836d5eb ("target-s390: Convert COMPARE, COMPARE LOGICAL")
    +    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
         Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
     
      ## target/s390x/tcg/insn-data.h.inc ##
2:  3b1ca6b682 ! 2:  30868c4692 tests/tcg/s390x: Add C(G)HRL test
    @@ Commit message
         instruction.
         Test the sign extension performed on the second operand.
     
    +    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
         Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
     
      ## tests/tcg/s390x/chrl.c (new) ##
    @@ tests/tcg/s390x/chrl.c (new)
     +    uint32_t program_mask, cc;
     +
     +    asm volatile (
    -+               ".pushsection .rodata\n"
    -+        "0:	.short	1,0x8000\n"
    -+        "	.popsection\n"
    ++        ".pushsection .rodata\n"
    ++        "0:\n\t"
    ++        ".short 1, 0x8000\n\t"
    ++        ".popsection\n\t"
     +
    -+        "	chrl	%[r],0b\n"
    -+        "	ipm	%[program_mask]\n"
    ++        "chrl %[r], 0b\n\t"
    ++        "ipm %[program_mask]\n"
     +        : [program_mask] "=r" (program_mask)
     +        : [r] "r" (1)
     +    );
    @@ tests/tcg/s390x/chrl.c (new)
     +    assert(!cc);
     +
     +    asm volatile (
    -+               ".pushsection .rodata\n"
    -+        "0:	.short	-1,0x8000\n"
    -+        "	.popsection\n"
    ++        ".pushsection .rodata\n"
    ++        "0:\n\t"
    ++        ".short -1, 0x8000\n\t"
    ++        ".popsection\n\t"
     +
    -+        "	chrl	%[r],0b\n"
    -+        "	ipm	%[program_mask]\n"
    ++        "chrl %[r], 0b\n\t"
    ++        "ipm %[program_mask]\n"
     +        : [program_mask] "=r" (program_mask)
     +        : [r] "r" (-1)
     +    );
    @@ tests/tcg/s390x/chrl.c (new)
     +    uint32_t program_mask, cc;
     +
     +    asm volatile (
    -+               ".pushsection .rodata\n"
    -+        "0:	.short	1,0x8000,0,0\n"
    -+        "	.popsection\n"
    ++        ".pushsection .rodata\n"
    ++        "0:\n\t"
    ++        ".short 1, 0x8000, 0, 0\n\t"
    ++        ".popsection\n\t"
     +
    -+        "	cghrl	%[r],0b\n"
    -+        "	ipm	%[program_mask]\n"
    ++        "cghrl %[r], 0b\n\t"
    ++        "ipm %[program_mask]\n"
     +        : [program_mask] "=r" (program_mask)
     +        : [r] "r" (1L)
     +    );
    @@ tests/tcg/s390x/chrl.c (new)
     +    assert(!cc);
     +
     +    asm volatile (
    -+               ".pushsection .rodata\n"
    -+        "0:	.short	-1,0x8000,0,0\n"
    -+        "	.popsection\n"
    ++        ".pushsection .rodata\n"
    ++        "0:\n\t"
    ++        ".short -1, 0x8000, 0, 0\n\t"
    ++        ".popsection\n\t"
     +
    -+        "	cghrl	%[r],0b\n"
    -+        "	ipm	%[program_mask]\n"
    ++        "cghrl %[r], 0b\n\t"
    ++        "ipm %[program_mask]\n"
     +        : [program_mask] "=r" (program_mask)
     +        : [r] "r" (-1L)
     +    );

base-commit: 15002921e878e6cf485f655d580733b5319ea015
-- 
2.39.1