Created attachment 67114 [details] Patch to add support for mfatbu and mfatbl PowerPC uses two alternate time base registers which are read from user space by using PPC instructions mfatbu and mfatbl . However these instructions are not not supported by Valgrind. Here are the logs when an application executing such instruction is executed with Valgrind: dis_proc_ctl(ppc)(mfspr,SPR)(0x20F) disInstr(ppc): unhandled instruction: 0x7C0F82A6 primary 31(0x1F), secondary 678(0x2A6) ==2204== valgrind: Unrecognised instruction at address 0x10003dfc. ==2204== at 0x10003DFC: ??? (in /usr/bin/simple_crypto) ==2204== by 0x1000181B: ??? (in /usr/bin/simple_crypto) ==2204== by 0xFE179E7: ??? (in /lib/libpthread-2.13.so) ==2204== by 0x40EEA9B: ??? (in /lib/libc-2.13.so) ==2204== Your program just tried to execute an instruction that Valgrind ==2204== did not recognise. There are two possible reasons for this. ==2204== 1. Your program has a bug and erroneously jumped to a non-code ==2204== location. If you are running Memcheck and you just saw a ==2204== warning about a bad jump, it's probably your program's fault. ==2204== 2. The instruction is legitimate but Valgrind doesn't handle it, ==2204== i.e. it's Valgrind's fault. If you think this is the case or ==2204== you are not sure, please let us know and we'll try to fix it. ==2204== Either way, Valgrind will now raise a SIGILL signal which will ==2204== probably kill your program. We have developed a path to fix the issue. Kindly find it attached.
It seems like a test program that triggers the mfatb[ul] instructions and that allows to verify the correctness of this patch is missing ? See e.g. none/tests/ppc32/lsw.c for an example.
Another possible starting point for a test program is none/tests/ppc32/bug139050-ppc32.c.
Created attachment 67145 [details] Test program to check the correctness of the patch
Thanks for the test program. In order to integrate the test program in the Valgrind regression test suite we need to know which PowerPC CPUs support the special-purpose registers 526 and 527 and which CPUs do not. The test program must be run only on CPUs that support these special-purpose registers.
(In reply to comment #4) > Thanks for the test program. In order to integrate the test program in the > Valgrind regression test suite we need to know which PowerPC CPUs support the > special-purpose registers 526 and 527 and which CPUs do not. The test program > must be run only on CPUs that support these special-purpose registers. All BookE PowerPC CPUs (such as e500mc, e500, e5500 etc) support special-purpose registers 526 and 527. I will ask the experts in this area about PowerPC CPUs which do not support these registers and post here.
Also affects e500v2 see #306590 see #268106
(In reply to comment #6) > Also affects e500v2 > see #306590 > see #268106 The patch does not work on e500v2 ==5506== Memcheck, a memory error detector ==5506== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al. ==5506== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info ==5506== Command: ls ==5506== dis_proc_ctl(ppc)(mfspr,SPR)(0x200) disInstr(ppc): unhandled instruction: 0x7D4082A6 primary 31(0x1F), secondary 678(0x2A6)
Created attachment 151700 [details] A rebased (to latest upstream commit) version of the patch