Summary: | Valgrind does not support POWER9 "DARN" RNG instructions | ||
---|---|---|---|
Product: | [Developer tools] valgrind | Reporter: | Jack Lloyd <lloyd> |
Component: | general | Assignee: | Julian Seward <jseward> |
Status: | CLOSED FIXED | ||
Severity: | normal | CC: | cel, mark, noloader, will_schmidt |
Priority: | NOR | ||
Version: | 3.15 SVN | ||
Target Milestone: | --- | ||
Platform: | Other | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Jack Lloyd
2019-08-22 20:26:22 UTC
Add a "mee too". Crypto++ is dying during analysis. The issue should also affect OpenSSL and GnuTLS. Maybe even GnuPG. ===== The Crypto++ use case is a bit different. Compiler support for DARN is a bit lacking among GCC, Clang and XLC. Crypto++ just issues byte codes for the instruction (https://github.com/weidai11/cryptopp/blob/master/darn.cpp#L43): do { __asm__ __volatile__ ( #if (CRYPTOPP_BIG_ENDIAN) ".byte 0x7c, 0x60, 0x05, 0xe6 \n\t" // r3 = darn 3, 0 "mr %0, 3 \n\t" // val = r3 #else ".byte 0xe6, 0x05, 0x60, 0x7c \n\t" // r3 = darn 3, 0 "mr %0, 3 \n\t" // val = r3 #endif : "=r" (*ptr) : : "r3" ); } while (*ptr == 0xFFFFFFFFu); Here is OpenSSL's use of the DARN generator OpenSSL is also issuing byte codes (https://github.com/openssl/openssl/blob/master/crypto/perlasm/ppc-xlate.pl#L279): # PowerISA 3.0 stuff my $maddhdu = sub { vfour(@_,49); }; my $maddld = sub { vfour(@_,51); }; my $darn = sub { my ($f, $rt, $l) = @_; " .long ".sprintf "0x%X",(31<<26)|($rt<<21)|($l<<16)|(755<<1); }; This doesn't solve this bug, DARN is still not implemented, but now valgrind will not advertise DARN is available so programs should not use it when running under valgrind. commit ea98cccb4d50a8740708507c4c72cfb1e6c88e38 Author: Mark Wielaard <mark@klomp.org> Date: Tue Feb 23 16:19:26 2021 +0100 Filter out unsupported instructions from HWCAP2 on powerpc. Valgrind currently doesn't support the DARN random number instruction and the SCV syscall instruction. Filter them out of HWCAP2 so glibc and applications don't try to use them when running under valgrind. Also suppress printing a log message for scv instructions in the instruction stream. Reported by: Florian Weimer <fweimer@redhat.com> DARN bug: https://bugs.kde.org/show_bug.cgi?id=411189 SCV bug: https://bugs.kde.org/show_bug.cgi?id=431157 Darn instruction support committed. commit 8afb49abe04a341d60b441c1f09a956aeccf0bbb Author: Carl Love <cel@us.ibm.com> Date: Mon Mar 22 17:55:05 2021 -0500 PPC64: Add support for the darn instruction Tested the test program on a Power 9 box with the latest Valgrind source tree. valgrind ./min_darn ==2840566== Memcheck, a memory error detector ==2840566== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==2840566== Using Valgrind-3.18.0.GIT and LibVEX; rerun with -h for copyright info ==2840566== Command: ./min_darn ==2840566== 13F736A2E6879909 ==2840566== ==2840566== HEAP SUMMARY: ==2840566== in use at exit: 0 bytes in 0 blocks ==2840566== total heap usage: 1 allocs, 1 frees, 1,024 bytes allocated ==2840566== ==2840566== All heap blocks were freed -- no leaks are possible ==2840566== ==2840566== For lists of detected and suppressed errors, rerun with: -s ==2840566== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) The test program seems to work fine. Jack Lloyd, please verify the fix works for you using the current upstream Valgrind repository. If the issue is fixed please close this issue. Otherwise let me know and I will look at it again. Thanks. No response from Jack. The bug has been fixed. Closing. |