All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Edwin Török" <edwin.torok@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: "Edwin Török" <edwin.torok@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Anthony PERARD" <anthony.perard@vates.tech>
Subject: [PATCH v2 0/4] Fix building tools/tests/x86_emulator with clang-21
Date: Fri, 27 Feb 2026 10:58:19 +0000	[thread overview]
Message-ID: <cover.1772189234.git.edwin.torok@citrix.com> (raw)

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



             reply	other threads:[~2026-02-27 10:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27 10:58 Edwin Török [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1772189234.git.edwin.torok@citrix.com \
    --to=edwin.torok@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@vates.tech \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.