]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Robustify the flags check in none/tests/x86/crc32.c
authorMartin Cermak <mcermak@redhat.com>
Thu, 25 Jun 2026 12:14:31 +0000 (14:14 +0200)
committerMartin Cermak <mcermak@redhat.com>
Thu, 25 Jun 2026 12:15:20 +0000 (14:15 +0200)
The crc32 instruction doesn't change flags.  The testcase
assumes flags are zero after crc32 and that works with GCC.
With clang though flags appear to be some garbage value.

To make the flags check more robust, zero out the flags
before crc32 is executed.  After that we can reliably check
flags for zero value.

https://bugs.kde.org/show_bug.cgi?id=522160

NEWS
none/tests/x86/crc32.c

diff --git a/NEWS b/NEWS
index 61e41393f8899a02a270c130cd69ce72b29bdd75..a43a927a6a4bf404b98a1c8a95c875254f1f5668 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,7 @@ are not entered into bugzilla tend to get forgotten about or ignored.
 521054  Unhandled amd64-linux syscall: 467 (open_tree_attr)
 521259  Improve check_makefile_consistency
 521332  vex x86->IR: unhandled instruction bytes: 66 0F 38 37 (PCMPGTQ)
+522160  Robustify the flags check in the none/tests/x86/crc32 test
 
 To see details of a given bug, visit
   https://bugs.kde.org/show_bug.cgi?id=XXXXXX
index 1bfcd26ef906618026b3e1850ddc4bb5d9ae3358..55d9f8566699326b8827cd35beb166121d531f5b 100644 (file)
@@ -200,6 +200,8 @@ void test_CRC32_U8_x86 ( void )
          "movl %0,       %%eax"  "\n\t"
          "movl 0(%%eax), %%edx"  "\n\t"
          "movl 4(%%eax), %%ecx"  "\n\t"
+         "pushl $0"              "\n\t"
+         "popf"                  "\n\t"
          "crc32 %%dl,  %%ecx"  "\n\t"
          "movl %%ecx, 8(%%eax)"  "\n\t"
          "pushf"                 "\n\t"
@@ -219,6 +221,8 @@ void test_CRC32_U8_x86 ( void )
       __asm__ __volatile__(
          "movl %0,       %%eax"  "\n\t"
          "movl 4(%%eax), %%ecx"  "\n\t"
+         "pushl $0"              "\n\t"
+         "popf"                  "\n\t"
          "crc32b 0(%%eax), %%ecx"  "\n\t"
          "movl %%ecx, 8(%%eax)"  "\n\t"
          "pushf"                 "\n\t"
@@ -247,6 +251,8 @@ void test_CRC32_U16_x86 ( void )
          "movl %0,       %%eax"  "\n\t"
          "movl 0(%%eax), %%edi"  "\n\t"
          "movl 4(%%eax), %%ecx"  "\n\t"
+         "pushl $0"              "\n\t"
+         "popf"                  "\n\t"
          "crc32 %%di,  %%ecx"  "\n\t"
          "movl %%ecx, 8(%%eax)"  "\n\t"
          "pushf"                 "\n\t"
@@ -266,6 +272,8 @@ void test_CRC32_U16_x86 ( void )
       __asm__ __volatile__(
          "movl %0,       %%eax"  "\n\t"
          "movl 4(%%eax), %%ecx"  "\n\t"
+         "pushl $0"              "\n\t"
+         "popf"                  "\n\t"
          "crc32w 0(%%eax), %%ecx"  "\n\t"
          "movl %%ecx, 8(%%eax)"  "\n\t"
          "pushf"                 "\n\t"
@@ -294,6 +302,8 @@ void test_CRC32_U32_x86 ( void )
          "movl %0,       %%eax"  "\n\t"
          "movl 0(%%eax), %%edi"  "\n\t"
          "movl 4(%%eax), %%ecx"  "\n\t"
+         "pushl $0"              "\n\t"
+         "popf"                  "\n\t"
          "crc32 %%edi,  %%ecx"  "\n\t"
          "movl %%ecx, 8(%%eax)"  "\n\t"
          "pushf"                 "\n\t"
@@ -313,6 +323,8 @@ void test_CRC32_U32_x86 ( void )
       __asm__ __volatile__(
          "movl %0,       %%eax"  "\n\t"
          "movl 4(%%eax), %%ecx"  "\n\t"
+         "pushl $0"              "\n\t"
+         "popf"                  "\n\t"
          "crc32l 0(%%eax), %%ecx"  "\n\t"
          "movl %%ecx, 8(%%eax)"  "\n\t"
          "pushf"                 "\n\t"