Bug 1035704

Summary: valgrind doesn't handle Haswell xabort instruction
Product: Red Hat Enterprise Linux 7 Reporter: Mark Wielaard <mjw>
Component: valgrindAssignee: Mark Wielaard <mjw>
Status: CLOSED CURRENTRELEASE QA Contact: Miroslav Franc <mfranc>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: jakub, mbenitez, mfranc, ohudlick
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: valgrind-3.9.0-2.2.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-13 12:49:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Mark Wielaard 2013-11-28 10:18:40 UTC
Take the following program:

// gcc -g -Wall -mrtm -o rtm-test rtm-test.c

#include <immintrin.h>
#include <stdio.h>

int
main (int argc, char **argv)
{
  unsigned status;

  if ((status = _xbegin ()) == _XBEGIN_STARTED)
    {
      // Note that under valgrind the transaction will never start.
      // We will jump right into the fallback path.
      printf ("transaction started: %u\n", status);
      _xend ();
    }
  else
    {
      printf ("fallback path: %u\n", status);

      // xtest should tell us no transaction is currently active.
      printf ("xtest: %u\n", _xtest ());
    }
  printf ("transaction done: %u\n", status);

  // Aborting a non-existing transaction is just a NOP.
  _xabort (1);

  // Still no transaction active.
  printf ("xtest: %u\n", _xtest ());

  return 0;
}

$ gcc -g -Wall -mrtm -o rtm-test rtm-test.c
$ valgrind ./rtm-test

==14425== Command: ./rtm-test
==14425== 
fallback path: 8
xtest: 0
transaction done: 8
vex amd64->IR: unhandled instruction bytes: 0xC6 0xF8 0x1 0xF 0x1 0xD6 0xF 0x95
vex amd64->IR:   REX=0 REX.W=0 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE
vex amd64->IR:   PFX.66=0 PFX.F2=0 PFX.F3=0
==14425== valgrind: Unrecognised instruction at address 0x4005ae.
==14425==    at 0x4005AE: main (rtm-test.c:28)

That is the xabort.

Expected output:

==14468== Memcheck, a memory error detector
==14468== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==14468== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
==14468== Command: ./rtm-test
==14468== 
fallback path: 8
xtest: 0
transaction done: 8
xtest: 0
==14468== 
==14468== HEAP SUMMARY:
==14468==     in use at exit: 0 bytes in 0 blocks
==14468==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==14468== 
==14468== All heap blocks were freed -- no leaks are possible
==14468== 
==14468== For counts of detected and suppressed errors, rerun with: -v
==14468== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)

There is a proposed upstream patch in the upstream bug tracker:
https://bugs.kde.org/show_bug.cgi?id=328100

Comment 4 Ludek Smid 2014-06-13 12:49:01 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.