From: Paul F. <pa...@so...> - 2025-01-11 12:55:35
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=5b2fed0f5a4471d87d0763172f29332cf4cc6abe commit 5b2fed0f5a4471d87d0763172f29332cf4cc6abe Author: Paul Floyd <pj...@wa...> Date: Sat Jan 11 12:28:00 2025 +0100 Bug 498492 - none/tests/amd64/lzcnt64 crashes on FreeBSD compiled with clang Using push in inline asm is a bit risky. It worked by luck with GCC. Fix it by shifting down RSP by 1024 and before the test and restoring it after. Diff: --- NEWS | 1 + none/tests/amd64/lzcnt64.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e25d1d8b81..5c576ff33e 100644 --- a/NEWS +++ b/NEWS @@ -41,6 +41,7 @@ are not entered into bugzilla tend to get forgotten about or ignored. 498317 FdBadUse is not a valid CoreError type in a suppression even though it's generated by --gen-suppressions=yes 498143 False positive on EVIOCGRAB ioctl +498492 none/tests/amd64/lzcnt64 crashes on FreeBSD compiled with clang To see details of a given bug, visit https://bugs.kde.org/show_bug.cgi?id=XXXXXX diff --git a/none/tests/amd64/lzcnt64.c b/none/tests/amd64/lzcnt64.c index 22fa353b8d..d2b14d6911 100644 --- a/none/tests/amd64/lzcnt64.c +++ b/none/tests/amd64/lzcnt64.c @@ -9,12 +9,14 @@ void do_lzcnt64 ( /*OUT*/UInt* flags, /*OUT*/ULong* res, ULong arg ) { ULong block[3] = { arg, 0ULL, 0ULL }; __asm__ __volatile__( + "subq $1024, %%rsp\n\t" "movabsq $0x5555555555555555, %%r11" "\n\t" "lzcntq 0(%0), %%r11" "\n\t" "movq %%r11, 8(%0)" "\n\t" "pushfq" "\n\t" "popq %%r11" "\n\t" - "movq %%r11, 16(%0)" "\n" + "movq %%r11, 16(%0)" "\n\t" + "addq $1024, %%rsp" "\n" : : "r"(&block[0]) : "r11","cc","memory" ); *res = block[1]; @@ -26,12 +28,14 @@ void do_lzcnt32 ( /*OUT*/UInt* flags, /*OUT*/ULong* res, ULong arg ) { ULong block[3] = { arg, 0ULL, 0ULL }; __asm__ __volatile__( + "subq $1024, %%rsp\n\t" "movabsq $0x5555555555555555, %%r11" "\n\t" "lzcntl 0(%0), %%r11d" "\n\t" "movq %%r11, 8(%0)" "\n\t" "pushfq" "\n\t" "popq %%r11" "\n\t" - "movq %%r11, 16(%0)" "\n" + "movq %%r11, 16(%0)" "\n\t" + "addq $1024, %%rsp" "\n" : : "r"(&block[0]) : "r11","cc","memory" ); *res = block[1]; @@ -43,12 +47,14 @@ void do_lzcnt16 ( /*OUT*/UInt* flags, /*OUT*/ULong* res, ULong arg ) { ULong block[3] = { arg, 0ULL, 0ULL }; __asm__ __volatile__( + "subq $1024, %%rsp\n\t" "movabsq $0x5555555555555555, %%r11" "\n\t" "lzcntw 0(%0), %%r11w" "\n\t" "movq %%r11, 8(%0)" "\n\t" "pushfq" "\n\t" "popq %%r11" "\n\t" - "movq %%r11, 16(%0)" "\n" + "movq %%r11, 16(%0)" "\n\t" + "addq $1024, %%rsp" "\n" : : "r"(&block[0]) : "r11","cc","memory" ); *res = block[1]; |