Skip to contentSkip to conversation

tests/tcg fixes

PATCH In review Eric Farman 3 participants 10 messages Oct 19 – Oct 24 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

v2 cover tests/tcg fixes

Hi,

Here's a quick turnaround on the tests/tcg fixes to address Pierrick's comments on v1.

Quoting the important part of v1:

- Patch 1 addresses an endianness problem that shows up when running on a big-endian (s390) host. It's existed for a while, as I can recreate similar errors (if slightly different messages) at least back to 11.0.0. Just never noticed (or looked into it) before.
- Patch 2 addresses a change in behavior that occurs in the powerpc toolchain between power6 and power7 (based on experimentation with gcc -mcpu= settings). The tests as they currently are run fine for me on either an s390 or x86 host running Fedora, but fail on both hosts running Debian.

v1->v2:
- [PB] Add -mcpu in the loop processing the multiarch tests, rather than skipping it and adding it later.
- [PB] Squash patches 2-4 into one
v1: https://lore.kernel.org/qemu-devel/[email protected]/

Eric Farman (2):
hw/i386: ELF endianness fixes
tests/tcg/ppc64: Run float_conv* against power8

 hw/i386/x86-common.c            |   6 +-
 include/hw/elf_ops.h.inc        |  20 ++++-
 tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
 tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
 tests/tcg/ppc64/meson.build     |   6 ++
 5 files changed, 140 insertions(+), 116 deletions(-)
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 1/2 hw/i386: ELF endianness fixes

Running make check-tcg-x86_64 on a big-endian host (e.g., s390x) fails due to problems reading/parsing the ELF data:

qemu-system-x86_64: Error loading uncompressed kernel without PVH ELF Note

There already exists logic in include/hw/elf_ops.h.inc to handle byte-swaps where necessary, but it does not perform this logic for ELF notes itself.

Fixing that improves matters, but yields other errors: most of the tests timeout while some generate confusing assertions. Both appear to be related to the data addresses in those notes, which are incorrect when running on a big-endian host.

Adding tswap wrappers, which will conditionally swap if the host and target endianness don't match, fixes that such that check-tcg-x86_64 runs cleanly on an s390 host.

---
 hw/i386/x86-common.c     |  6 ++++--
 include/hw/elf_ops.h.inc | 20 ++++++++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)
hw/i386/x86-common.c +4 -2
index fa18bf1aece..dcd4fa8eb79 100644
@@ -45,6 +45,8 @@
 #include "kvm/kvm_i386.h"
 #include "kvm/tdx.h"
 
+#include "exec/tswap.h"
+
 #ifdef CONFIG_XEN_EMU
 #include "hw/xen/xen.h"
 #include "hw/i386/kvm/xen_evtchn.h"
@@ -573,7 +575,7 @@ static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64)
             ((void *)nhdr64) + nhdr_size64 +
             QEMU_ALIGN_UP(nhdr_namesz, phdr_align);
 
-        pvh_start_addr = *elf_note_data_addr;
+        pvh_start_addr = tswap64(*elf_note_data_addr);
     } else {
         struct elf32_note *nhdr32 = (struct elf32_note *)arg1;
         uint32_t nhdr_size32 = sizeof(struct elf32_note);
@@ -584,7 +586,7 @@ static uint64_t read_pvh_start_addr(void *arg1, void *arg2, bool is64)
             ((void *)nhdr32) + nhdr_size32 +
             QEMU_ALIGN_UP(nhdr_namesz, phdr_align);
 
-        pvh_start_addr = *(uint32_t *)elf_note_data_addr;
+        pvh_start_addr = tswap32(*(uint32_t *)elf_note_data_addr);
     }
 
     return pvh_start_addr;
include/hw/elf_ops.h.inc +18 -2
index 044e72de2a2..b4fc0b146f0 100644
@@ -56,6 +56,13 @@ static void glue(bswap_rela, SZ)(struct elf_rela *rela)
     bswapSZs((elf_word *)&rela->r_addend);
 }
 
+static void glue(bswap_note, SZ)(struct elf_note *note)
+{
+    bswap32s(&note->n_namesz);
+    bswap32s(&note->n_descsz);
+    bswap32s(&note->n_type);
+}
+
 static struct elf_shdr *glue(find_section, SZ)(struct elf_shdr *shdr_table,
                                                int n, int type)
 {
@@ -275,7 +282,8 @@ fail:
 static struct elf_note *glue(get_elf_note_type, SZ)(struct elf_note *nhdr,
                                                     elf_word note_size,
                                                     elf_word phdr_align,
-                                                    elf_word elf_note_type)
+                                                    elf_word elf_note_type,
+                                                    int must_swab)
 {
     elf_word nhdr_size = sizeof(struct elf_note);
     elf_word elf_note_entry_offset = 0;
@@ -287,6 +295,10 @@ static struct elf_note *glue(get_elf_note_type, SZ)(struct elf_note *nhdr,
         return NULL;
     }
 
+    if (must_swab) {
+        glue(bswap_note, SZ)(nhdr);
+    }
+
     note_type = nhdr->n_type;
     while (note_type != elf_note_type) {
         nhdr_namesz = nhdr->n_namesz;
@@ -306,6 +318,9 @@ static struct elf_note *glue(get_elf_note_type, SZ)(struct elf_note *nhdr,
 
         /* skip to the next ELF Note entry */
         nhdr = (void *)nhdr + elf_note_entry_offset;
+        if (must_swab) {
+            glue(bswap_note, SZ)(nhdr);
+        }
         note_type = nhdr->n_type;
     }
 
@@ -608,7 +623,8 @@ static ssize_t glue(load_elf, SZ)(const char *name, int fd,
             nhdr = (struct elf_note *)data;
             assert(translate_opaque != NULL);
             nhdr = glue(get_elf_note_type, SZ)(nhdr, file_size, ph->p_align,
-                                               *(uint64_t *)translate_opaque);
+                                               *(uint64_t *)translate_opaque,
+                                               must_swab);
             if (nhdr != NULL) {
                 elf_note_fn((void *)nhdr, (void *)&ph->p_align, SZ == 64);
             }
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v2 1/2] hw/i386: ELF endianness fixes

Quoted 17 lines · Eric Farman

Running make check-tcg-x86_64 on a big-endian host (e.g., s390x) fails due to problems reading/parsing the ELF data:

qemu-system-x86_64: Error loading uncompressed kernel without PVH ELF Note

There already exists logic in include/hw/elf_ops.h.inc to handle byte-swaps where necessary, but it does not perform this logic for ELF notes itself.

Fixing that improves matters, but yields other errors: most of the tests timeout while some generate confusing assertions. Both appear to be related to the data addresses in those notes, which are incorrect when running on a big-endian host.

Adding tswap wrappers, which will conditionally swap if the host and target endianness don't match, fixes that such that check-tcg-x86_64 runs cleanly on an s390 host.

Quoted 6 lines
---
  hw/i386/x86-common.c     |  6 ++++--
  include/hw/elf_ops.h.inc | 20 ++++++++++++++++++--
  2 files changed, 22 insertions(+), 4 deletions(-)

Hi!

This looks like a good addition for the stable series, if it actually fixed the issue mentioned.

I'm queuing this change for the stable series, but not picking for any release just yet, - if a follow-up fix will come, I'll include both.

And please let me know if I shouldn't :)

Thanks,

/mjt

#3 lore raw

PATCH v2 2/2 tests/tcg/ppc64: Run float_conv* against power8

In reply to Eric Farman

There is an oddity that turns up with the float_convd and float_convs tests, when running from different toolchains. As one example, the expectation at the start of tests/tcg/ppc64/float_conv*.ref is:

### Rounding to nearest
from double: f64(nan:0x007ff4000000000000)

    to single: f32(nan:0x7fe00000) (INVALID)
     to int32: -2147483648 (INVALID)
     to int64: -9223372036854775808 (INVALID)
    to uint32: 0 (INVALID)
    to uint64: -9223372036854775808 (INVALID)

But, other hosts offer a different response, e.g., this debian guest on my laptop:

### Rounding to nearest
from double: f64(nan:0x007ff4000000000000)

    to single: f32(nan:0x7fe00000) (INVALID)
     to int32: -2147483648 (INVALID)
     to int64: -9223372036854775808 (INVALID)
    to uint32: 0 (INVALID)
    to uint64: 0 (INVALID)

The explanation seems to be a behavior change when compiling to different versions of power hardware. When building the arguments from the multiarch directory, let's ensure these float tests offer a deterministic response to these NaN tests by explicitly binding them to a CPU architecture.

Chose power8 for no real reason. This behavior change appears between power6 and power7, but other tests that rely on a specific architecture today pick either power8 or power10.

---
 tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
 tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
 tests/tcg/ppc64/meson.build     |   6 ++
 3 files changed, 118 insertions(+), 112 deletions(-)
tests/tcg/ppc64/float_convd.ref +72 -72
index 43aa3117f14..2995a767c04 100644
@@ -4,61 +4,61 @@ from double: f64(nan:0x007ff4000000000000)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-nan:0x00fff8000000000000)
   to single: f32(-nan:0xffc00000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-inf:0x00fff0000000000000)
   to single: f32(-inf:0xff800000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffffffffff0000000p+1023:0x00ffefffffffffffff)
   to single: f32(-inf:0xff800000) (OVERFLOW INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.1874b135ff6540000000p+103:0x00c661874b135ff654)
   to single: f32(-0x1.1874b200000000000000p+103:0xf30c3a59) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.c0bab523323b90000000p+99:0x00c62c0bab523323b9)
   to single: f32(-0x1.c0bab600000000000000p+99:0xf1605d5b) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+1:0x00c000000000000000)
   to single: f32(-0x1.00000000000000000000p+1:0xc0000000) (OK)
    to int32: -2 (OK)
    to int64: -2 (OK)
-  to uint32: -2 (OK)
-  to uint64: -2 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+0:0x00bff0000000000000)
   to single: f32(-0x1.00000000000000000000p+0:0xbf800000) (OK)
    to int32: -1 (OK)
    to int64: -1 (OK)
-  to uint32: -1 (OK)
-  to uint64: -1 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p-1022:0x008010000000000000)
   to single: f32(-0x0.00000000000000000000p+0:0x80000000) (UNDERFLOW INEXACT )
    to int32: 0 (INEXACT )
@@ -208,19 +208,19 @@ from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
   to single: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) (OK)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffffffffff0000000p+1023:0x007fefffffffffffff)
   to single: f32(inf:0x7f800000) (OVERFLOW INEXACT )
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(inf:0x007ff0000000000000)
   to single: f32(inf:0x7f800000) (OK)
    to int32: 2147483647 (INVALID)
@@ -232,80 +232,80 @@ from double: f64(nan:0x007ff8000000000000)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff0000000000001)
   to single: f32(nan:0x7fc00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 ### Rounding upwards
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-nan:0x00fff8000000000000)
   to single: f32(-nan:0xffc00000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-inf:0x00fff0000000000000)
   to single: f32(-inf:0xff800000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffffffffff0000000p+1023:0x00ffefffffffffffff)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OVERFLOW INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.1874b135ff6540000000p+103:0x00c661874b135ff654)
   to single: f32(-0x1.1874b000000000000000p+103:0xf30c3a58) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.c0bab523323b90000000p+99:0x00c62c0bab523323b9)
   to single: f32(-0x1.c0bab400000000000000p+99:0xf1605d5a) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+1:0x00c000000000000000)
   to single: f32(-0x1.00000000000000000000p+1:0xc0000000) (OK)
    to int32: -2 (OK)
    to int64: -2 (OK)
-  to uint32: -2 (OK)
-  to uint64: -2 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+0:0x00bff0000000000000)
   to single: f32(-0x1.00000000000000000000p+0:0xbf800000) (OK)
    to int32: -1 (OK)
    to int64: -1 (OK)
-  to uint32: -1 (OK)
-  to uint64: -1 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p-1022:0x008010000000000000)
   to single: f32(-0x0.00000000000000000000p+0:0x80000000) (UNDERFLOW INEXACT )
    to int32: 0 (INEXACT )
@@ -455,19 +455,19 @@ from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
   to single: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) (OK)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffffffffff0000000p+1023:0x007fefffffffffffff)
   to single: f32(inf:0x7f800000) (OVERFLOW INEXACT )
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(inf:0x007ff0000000000000)
   to single: f32(inf:0x7f800000) (OK)
    to int32: 2147483647 (INVALID)
@@ -479,80 +479,80 @@ from double: f64(nan:0x007ff8000000000000)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff0000000000001)
   to single: f32(nan:0x7fc00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 ### Rounding downwards
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-nan:0x00fff8000000000000)
   to single: f32(-nan:0xffc00000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-inf:0x00fff0000000000000)
   to single: f32(-inf:0xff800000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffffffffff0000000p+1023:0x00ffefffffffffffff)
   to single: f32(-inf:0xff800000) (OVERFLOW INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.1874b135ff6540000000p+103:0x00c661874b135ff654)
   to single: f32(-0x1.1874b200000000000000p+103:0xf30c3a59) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.c0bab523323b90000000p+99:0x00c62c0bab523323b9)
   to single: f32(-0x1.c0bab600000000000000p+99:0xf1605d5b) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+1:0x00c000000000000000)
   to single: f32(-0x1.00000000000000000000p+1:0xc0000000) (OK)
    to int32: -2 (OK)
    to int64: -2 (OK)
-  to uint32: -2 (OK)
-  to uint64: -2 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+0:0x00bff0000000000000)
   to single: f32(-0x1.00000000000000000000p+0:0xbf800000) (OK)
    to int32: -1 (OK)
    to int64: -1 (OK)
-  to uint32: -1 (OK)
-  to uint64: -1 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p-1022:0x008010000000000000)
   to single: f32(-0x1.00000000000000000000p-149:0x80000001) (UNDERFLOW INEXACT )
    to int32: 0 (INEXACT )
@@ -702,19 +702,19 @@ from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
   to single: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) (OK)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffffffffff0000000p+1023:0x007fefffffffffffff)
   to single: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) (OVERFLOW INEXACT )
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(inf:0x007ff0000000000000)
   to single: f32(inf:0x7f800000) (OK)
    to int32: 2147483647 (INVALID)
@@ -726,80 +726,80 @@ from double: f64(nan:0x007ff8000000000000)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff0000000000001)
   to single: f32(nan:0x7fc00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 ### Rounding to zero
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-nan:0x00fff8000000000000)
   to single: f32(-nan:0xffc00000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-inf:0x00fff0000000000000)
   to single: f32(-inf:0xff800000) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffffffffff0000000p+1023:0x00ffefffffffffffff)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OVERFLOW INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.fffffe00000000000000p+127:0x00c7efffffe0000000)
   to single: f32(-0x1.fffffe00000000000000p+127:0xff7fffff) (OK)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.1874b135ff6540000000p+103:0x00c661874b135ff654)
   to single: f32(-0x1.1874b000000000000000p+103:0xf30c3a58) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.c0bab523323b90000000p+99:0x00c62c0bab523323b9)
   to single: f32(-0x1.c0bab400000000000000p+99:0xf1605d5a) (INEXACT )
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+1:0x00c000000000000000)
   to single: f32(-0x1.00000000000000000000p+1:0xc0000000) (OK)
    to int32: -2 (OK)
    to int64: -2 (OK)
-  to uint32: -2 (OK)
-  to uint64: -2 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p+0:0x00bff0000000000000)
   to single: f32(-0x1.00000000000000000000p+0:0xbf800000) (OK)
    to int32: -1 (OK)
    to int64: -1 (OK)
-  to uint32: -1 (OK)
-  to uint64: -1 (OK)
+  to uint32: 0 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(-0x1.00000000000000000000p-1022:0x008010000000000000)
   to single: f32(-0x0.00000000000000000000p+0:0x80000000) (UNDERFLOW INEXACT )
    to int32: 0 (INEXACT )
@@ -949,19 +949,19 @@ from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffe00000000000000p+127:0x0047efffffe0000000)
   to single: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) (OK)
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(0x1.fffffffffffff0000000p+1023:0x007fefffffffffffff)
   to single: f32(0x1.fffffe00000000000000p+127:0x7f7fffff) (OVERFLOW INEXACT )
    to int32: 2147483647 (INVALID)
    to int64: 9223372036854775807 (INVALID)
   to uint32: -1 (INVALID)
-  to uint64: -1 (INEXACT INVALID)
+  to uint64: -1 (INVALID)
 from double: f64(inf:0x007ff0000000000000)
   to single: f32(inf:0x7f800000) (OK)
    to int32: 2147483647 (INVALID)
@@ -973,16 +973,16 @@ from double: f64(nan:0x007ff8000000000000)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff0000000000001)
   to single: f32(nan:0x7fc00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
 from double: f64(nan:0x007ff4000000000000)
   to single: f32(nan:0x7fe00000) (INVALID)
    to int32: -2147483648 (INVALID)
    to int64: -9223372036854775808 (INVALID)
   to uint32: 0 (INVALID)
-  to uint64: -9223372036854775808 (INVALID)
+  to uint64: 0 (INVALID)
tests/tcg/ppc64/float_convs.ref +40 -40

289 lines not on this page · raw message

tests/tcg/ppc64/meson.build +6 -0
index 8cca4d65a4c..d9b4b153d94 100644
@@ -13,6 +13,12 @@ foreach t: tcg_tests['multiarch-linux-user']['tests']
     if fs.stem(src) == 'test-plugin-mem-access' and 'wrapper' in setup
       continue
     endif
+    if fs.stem(src).contains('float_conv')
+      # Ensure float NaN tests are done against a known cpu generation
+      if 'cflags' in setup
+        setup += {'cflags': setup['cflags'] + '-mcpu=power8'}
+      endif
+    endif
     tests += {src: setup}
   endforeach
 endforeach
Signature · 1 line
2.53.0
Reviewed-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] tests/tcg/ppc64: Run float_conv* against power8

Quoted 32 lines · Eric Farman

There is an oddity that turns up with the float_convd and float_convs tests, when running from different toolchains. As one example, the expectation at the start of tests/tcg/ppc64/float_conv*.ref is:

### Rounding to nearest
from double: f64(nan:0x007ff4000000000000)

    to single: f32(nan:0x7fe00000) (INVALID)
     to int32: -2147483648 (INVALID)
     to int64: -9223372036854775808 (INVALID)
    to uint32: 0 (INVALID)
    to uint64: -9223372036854775808 (INVALID)

But, other hosts offer a different response, e.g., this debian guest on my laptop:

### Rounding to nearest
from double: f64(nan:0x007ff4000000000000)

    to single: f32(nan:0x7fe00000) (INVALID)
     to int32: -2147483648 (INVALID)
     to int64: -9223372036854775808 (INVALID)
    to uint32: 0 (INVALID)
    to uint64: 0 (INVALID)

The explanation seems to be a behavior change when compiling to different versions of power hardware. When building the arguments from the multiarch directory, let's ensure these float tests offer a deterministic response to these NaN tests by explicitly binding them to a CPU architecture.

Chose power8 for no real reason. This behavior change appears between power6 and power7, but other tests that rely on a specific architecture today pick either power8 or power10.

Quoted 7 lines
---
 tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
 tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
 tests/tcg/ppc64/meson.build     |   6 ++
 3 files changed, 118 insertions(+), 112 deletions(-)

Thanks for the update Eric,

I'll let you pull this as part of ppc64 subsystem.

Also feel free to pull patch 1. Maybe let's just wait 2-3 days to see it Richard or Paolo have a specific comment, and then you can send that before the freeze date coming.

Regards,
Pierrick

#5 lore raw

Re: [PATCH v2 2/2] tests/tcg/ppc64: Run float_conv* against power8

Quoted 41 lines · Pierrick Bouvier
Quoted 32 lines · Eric Farman

There is an oddity that turns up with the float_convd and float_convs tests, when running from different toolchains. As one example, the expectation at the start of tests/tcg/ppc64/float_conv*.ref is:

### Rounding to nearest
from double: f64(nan:0x007ff4000000000000)

    to single: f32(nan:0x7fe00000) (INVALID)
     to int32: -2147483648 (INVALID)
     to int64: -9223372036854775808 (INVALID)
    to uint32: 0 (INVALID)
    to uint64: -9223372036854775808 (INVALID)

But, other hosts offer a different response, e.g., this debian guest on my laptop:

### Rounding to nearest
from double: f64(nan:0x007ff4000000000000)

    to single: f32(nan:0x7fe00000) (INVALID)
     to int32: -2147483648 (INVALID)
     to int64: -9223372036854775808 (INVALID)
    to uint32: 0 (INVALID)
    to uint64: 0 (INVALID)

The explanation seems to be a behavior change when compiling to different versions of power hardware. When building the arguments from the multiarch directory, let's ensure these float tests offer a deterministic response to these NaN tests by explicitly binding them to a CPU architecture.

Chose power8 for no real reason. This behavior change appears between power6 and power7, but other tests that rely on a specific architecture today pick either power8 or power10.

Quoted 7 lines
---
 tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
 tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
 tests/tcg/ppc64/meson.build     |   6 ++
 3 files changed, 118 insertions(+), 112 deletions(-)
Quoted 4 lines

Thanks for the update Eric,

I'll let you pull this as part of ppc64 subsystem.

Checking MAINTAINERS, I noticed you are working more on s390x side, and not ppc (I've been misled by @ibm.com). If I can help by pulling the series as part of tcg tests, let me know, and I'll send it on Thursday.

Regards,
Pierrick

#6 lore raw

Re: [PATCH v2 2/2] tests/tcg/ppc64: Run float_conv* against power8

Quoted 42 lines · Pierrick Bouvier
Quoted 41 lines · Pierrick Bouvier
Quoted 39 lines · Eric Farman

There is an oddity that turns up with the float_convd and float_convs tests, when running from different toolchains. As one example, the expectation at the start of tests/tcg/ppc64/float_conv*.ref is:

   ### Rounding to nearest
   from double: f64(nan:0x007ff4000000000000)
     to single: f32(nan:0x7fe00000) (INVALID)
      to int32: -2147483648 (INVALID)
      to int64: -9223372036854775808 (INVALID)
     to uint32: 0 (INVALID)
     to uint64: -9223372036854775808 (INVALID)

But, other hosts offer a different response, e.g., this debian guest on my laptop:

   ### Rounding to nearest
   from double: f64(nan:0x007ff4000000000000)
     to single: f32(nan:0x7fe00000) (INVALID)
      to int32: -2147483648 (INVALID)
      to int64: -9223372036854775808 (INVALID)
     to uint32: 0 (INVALID)
     to uint64: 0 (INVALID)

The explanation seems to be a behavior change when compiling to different versions of power hardware. When building the arguments from the multiarch directory, let's ensure these float tests offer a deterministic response to these NaN tests by explicitly binding them to a CPU architecture.

Chose power8 for no real reason. This behavior change appears between power6 and power7, but other tests that rely on a specific architecture today pick either power8 or power10.

---
  tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
  tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
  tests/tcg/ppc64/meson.build     |   6 ++
  3 files changed, 118 insertions(+), 112 deletions(-)
Quoted 8 lines
Quoted 4 lines

Thanks for the update Eric,

I'll let you pull this as part of ppc64 subsystem.

Checking MAINTAINERS, I noticed you are working more on s390x side, and not ppc (I've been misled by @ibm.com). If I can help by pulling the series as part of tcg tests, let me know, and I'll send it on Thursday.

Yeah, I'm only noticing these running on an s390 host; would be good if someone in PPC could chime in and confirm my suspicion, otherwise maybe you could take this one via tcg tests since it's showing up now. I don't think we ran this combination of tests prior to your meson rework? (I couldn't reproduce these ppc errors, anyway.)

Thanks,
Eric

Quoted 3 lines

Regards,
Pierrick

#7 lore raw

Re: [PATCH v2 2/2] tests/tcg/ppc64: Run float_conv* against power8

Quoted 58 lines · Eric Farman
Quoted 46 lines · Pierrick Bouvier
Quoted 45 lines · Pierrick Bouvier
Quoted 43 lines · Eric Farman

There is an oddity that turns up with the float_convd and float_convs tests, when running from different toolchains. As one example, the expectation at the start of tests/tcg/ppc64/float_conv*.ref is:

   ### Rounding to nearest
   from double: f64(nan:0x007ff4000000000000)
     to single: f32(nan:0x7fe00000) (INVALID)
      to int32: -2147483648 (INVALID)
      to int64: -9223372036854775808 (INVALID)
     to uint32: 0 (INVALID)
     to uint64: -9223372036854775808 (INVALID)

But, other hosts offer a different response, e.g., this debian guest on my laptop:

   ### Rounding to nearest
   from double: f64(nan:0x007ff4000000000000)
     to single: f32(nan:0x7fe00000) (INVALID)
      to int32: -2147483648 (INVALID)
      to int64: -9223372036854775808 (INVALID)
     to uint32: 0 (INVALID)
     to uint64: 0 (INVALID)

The explanation seems to be a behavior change when compiling to different
versions of power hardware. When building the arguments from the multiarch
directory, let's ensure these float tests offer a deterministic response
to these NaN tests by explicitly binding them to a CPU architecture.

Chose power8 for no real reason. This behavior change appears between power6 and power7, but other tests that rely on a specific architecture today pick either power8 or power10.

---
  tests/tcg/ppc64/float_convd.ref | 144 +++++++++++++++

+----------------
  tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
  tests/tcg/ppc64/meson.build     |   6 ++
  3 files changed, 118 insertions(+), 112 deletions(-)
Quoted 8 lines
Quoted 4 lines

Thanks for the update Eric,

I'll let you pull this as part of ppc64 subsystem.

Checking MAINTAINERS, I noticed you are working more on s390x side, and not ppc (I've been misled by @ibm.com). If I can help by pulling the series as part of tcg tests, let me know, and I'll send it on Thursday.

Quoted 6 lines

Yeah, I'm only noticing these running on an s390 host; would be good if someone in PPC could chime in and confirm my suspicion, otherwise maybe you could take this one via tcg tests since it's showing up now. I don't think we ran this combination of tests prior to your meson rework? (I couldn't reproduce these ppc errors, anyway.)

Not that I'm aware of. Personally I only ran tcg tests on aarch64 and x64 linux hosts. That said, I'm happy to see we are covering more things, and discovering issues.

I'll pull this on Thursday through tcg tests if there are no further comments on the series.

Quoted 3 lines

Thanks,
Eric

Regards,
Pierrick

Reviewed-by on the v2 series
#8 lore raw
In reply to Eric Farman
Quoted 27 lines · Eric Farman

Hi,

Here's a quick turnaround on the tests/tcg fixes to address Pierrick's comments on v1.

Quoting the important part of v1:

- Patch 1 addresses an endianness problem that shows up when running on a big-endian (s390) host. It's existed for a while, as I can recreate similar errors (if slightly different messages) at least back to 11.0.0. Just never noticed (or looked into it) before.
- Patch 2 addresses a change in behavior that occurs in the powerpc toolchain between power6 and power7 (based on experimentation with gcc -mcpu= settings). The tests as they currently are run fine for me on either an s390 or x86 host running Fedora, but fail on both hosts running Debian.

v1->v2:
- [PB] Add -mcpu in the loop processing the multiarch tests, rather than skipping it and adding it later.
- [PB] Squash patches 2-4 into one
v1: https://lore.kernel.org/qemu-devel/[email protected]/

Eric Farman (2):
hw/i386: ELF endianness fixes
tests/tcg/ppc64: Run float_conv* against power8

Quoted 7 lines
 hw/i386/x86-common.c            |   6 +-
 include/hw/elf_ops.h.inc        |  20 ++++-
 tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
 tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
 tests/tcg/ppc64/meson.build     |   6 ++
 5 files changed, 140 insertions(+), 116 deletions(-)

Series:

#9 lore raw
In reply to Eric Farman
Quoted 27 lines · Eric Farman

Hi,

Here's a quick turnaround on the tests/tcg fixes to address Pierrick's comments on v1.

Quoting the important part of v1:

- Patch 1 addresses an endianness problem that shows up when running on a big-endian (s390) host. It's existed for a while, as I can recreate similar errors (if slightly different messages) at least back to 11.0.0. Just never noticed (or looked into it) before.
- Patch 2 addresses a change in behavior that occurs in the powerpc toolchain between power6 and power7 (based on experimentation with gcc -mcpu= settings). The tests as they currently are run fine for me on either an s390 or x86 host running Fedora, but fail on both hosts running Debian.

v1->v2:
- [PB] Add -mcpu in the loop processing the multiarch tests, rather than skipping it and adding it later.
- [PB] Squash patches 2-4 into one
v1: https://lore.kernel.org/qemu-devel/[email protected]/

Eric Farman (2):
hw/i386: ELF endianness fixes
tests/tcg/ppc64: Run float_conv* against power8

Quoted 7 lines
 hw/i386/x86-common.c            |   6 +-
 include/hw/elf_ops.h.inc        |  20 ++++-
 tests/tcg/ppc64/float_convd.ref | 144 ++++++++++++++++----------------
 tests/tcg/ppc64/float_convs.ref |  80 +++++++++---------
 tests/tcg/ppc64/meson.build     |   6 ++
 5 files changed, 140 insertions(+), 116 deletions(-)

This was merged into master (b6c4b7e86dec12d07f5cac65265b986d38ee9002). Thank you for your contribution!

Regards,
Pierrick