Bug 408009

Summary: Expose rdrand and f16c even on avx if host cpu supports them
Product: [Developer tools] valgrind Reporter: Mark Wielaard <mark>
Component: generalAssignee: Mark Wielaard <mark>
Status: RESOLVED FIXED    
Severity: normal CC: ahajkova
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Expose rdrand and f16c through cpuid also if the host only has avx.

Description Mark Wielaard 2019-05-27 23:04:28 UTC
Currently the following code in coregrind/m_machine.c (machine_get_hwcaps) prevents using rdrand and f16c on avx only (none-avx2) machines:

     /* Sanity check for RDRAND and F16C.  These don't actually *need* AVX2, bu
        it's convenient to restrict them to the AVX2 case since the simulated
        CPUID we'll offer them on has AVX2 as a base. */
     if (!have_avx2) {
         have_f16c   = False;
         have_rdrand = False;
      }

So even if the host CPU supports it, valgrind disables it.

Both can be supported on avx machines too.
Comment 1 Mark Wielaard 2019-05-27 23:06:36 UTC
Created attachment 120350 [details]
Expose rdrand and f16c through cpuid also if the host only has avx.

Proposed fix.
Comment 2 Mark Wielaard 2019-05-28 20:11:17 UTC
commit 791fe5ecf909d573bcbf353b677b9404f9da0ed4
Author: Mark Wielaard <mark@klomp.org>
Date:   Mon May 27 22:19:27 2019 +0200

    Expose rdrand and f16c through cpuid also if the host only has avx.
    
    The amd64 CPUID dirtyhelpers are mostly static since they emulate some
    existing CPU "family". The avx2 ("i7-4910MQ") CPUID variant however
    can "dynamicly" enable rdrand and/or f16c if the host supports them.
    Do the same for the avx_and_cx16 ("i5-2300") CPUID variant.
    
    https://bugs.kde.org/show_bug.cgi?id=408009