From: Martin Cermak Date: Thu, 25 Jun 2026 12:14:31 +0000 (+0200) Subject: Robustify the flags check in none/tests/x86/crc32.c X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0b62907a2514946a264484a2b2fe7c50113331cc;p=thirdparty%2Fvalgrind.git Robustify the flags check in none/tests/x86/crc32.c 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 --- diff --git a/NEWS b/NEWS index 61e41393f..a43a927a6 100644 --- 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 diff --git a/none/tests/x86/crc32.c b/none/tests/x86/crc32.c index 1bfcd26ef..55d9f8566 100644 --- a/none/tests/x86/crc32.c +++ b/none/tests/x86/crc32.c @@ -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"