All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] Fix building tools/tests/x86_emulator with clang-21
@ 2026-02-27 10:58 Edwin Török
  2026-02-27 10:58 ` [PATCH v2 1/4] tools/tests/x86_emulator: avoid duplicate symbol error with clang Edwin Török
                   ` (3 more replies)
  0 siblings, 4 replies; 18+ messages in thread
From: Edwin Török @ 2026-02-27 10:58 UTC (permalink / raw)
  To: xen-devel
  Cc: Edwin Török, Jan Beulich, Andrew Cooper,
	Roger Pau Monné, Anthony PERARD

Changed since v1:
 * filed upstream bug and added reference for integrated-as issue
 * use .ifndef directive instead of volatile workaround
 * fixed 2 more undefined behaviour warnings from fsanitize=undefined

This makes the tests build (but not yet run) with clang.

I dropped the ifdef __clang__ patch:  compiling just x86-emulate.c with
clang and the rest with GCC fails too, so there are probably some
implicit assumptions about x86_emulate not modifying some registers (but
when compiled with clang it does). I don't have a good solution for
these, and I don't understand what most of these tests are trying to
test.
For example I don't see how this tests the result of the emulator,
where rc is entirely computed by the asm block (and with clang the
result here is 0xfffe instead of 0xffff):
```
        asm volatile ( "pcmpeqb %%xmm1, %%xmm1\n"
                       put_insn(movq_from_mem2, "movq 32(%0), %%xmm1")
                       :: "c" (NULL) );

        set_insn(movq_from_mem2);
        rc = x86_emulate(&ctxt, &emulops);
        if ( rc != X86EMUL_OKAY || !check_eip(movq_from_mem2) )
            goto fail;
        asm ( "pcmpgtb %%xmm0, %%xmm0\n\t"
              "pcmpeqb %%xmm1, %%xmm0\n\t"
              "pmovmskb %%xmm0, %0" : "=r" (rc) );
        if ( rc != 0xffff )
            goto fail;
```

After fixing the bugs reported by UBSAN/MSAN (and disabling the memset
wrapper which causes it to infloop) the tests still fail.
Using -Os doesn't help either.

valgrind also fails here, but that could be a bug in valgrind:
Testing mulx (%eax),%ecx,%ebx...        failed!

Edwin Török (4):
  tools/tests/x86_emulator: avoid duplicate symbol error with clang
  tools/tests/x86_emulator: fix build on clang-21
  tools/tests/x86_emulator: fix undefined behaviour in shift
  tools/tests/x86_emulator: avoid passing NULL to memcpy

 tools/tests/x86_emulator/Makefile            |  5 +++++
 tools/tests/x86_emulator/test_x86_emulator.c | 14 ++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

-- 
2.47.3



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

end of thread, other threads:[~2026-03-06 16:47 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 10:58 [PATCH v2 0/4] Fix building tools/tests/x86_emulator with clang-21 Edwin Török
2026-02-27 10:58 ` [PATCH v2 1/4] tools/tests/x86_emulator: avoid duplicate symbol error with clang Edwin Török
2026-03-03 13:59   ` Jan Beulich
2026-03-03 15:09     ` Edwin Torok
2026-03-03 15:36       ` Jan Beulich
2026-03-03 15:55         ` Edwin Torok
2026-03-03 16:43           ` Jan Beulich
2026-03-06 16:46             ` Edwin Torok
2026-02-27 10:58 ` [PATCH v2 2/4] tools/tests/x86_emulator: fix build on clang-21 Edwin Török
2026-03-03 14:05   ` Jan Beulich
2026-02-27 10:58 ` [PATCH v2 3/4] tools/tests/x86_emulator: fix undefined behaviour in shift Edwin Török
2026-03-03 14:07   ` Jan Beulich
2026-03-03 14:09     ` Jan Beulich
2026-03-03 14:30       ` Edwin Torok
2026-03-03 14:49     ` Edwin Torok
2026-02-27 10:58 ` [PATCH v2 4/4] tools/tests/x86_emulator: avoid passing NULL to memcpy Edwin Török
2026-03-03 14:18   ` Jan Beulich
2026-03-03 15:24     ` Andrew Cooper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.