|
From: Jeffrey W. <nol...@gm...> - 2016-01-09 12:02:17
|
Hi Everyone, We use Valgrind as part of our release process. Its a security gate, and the program must pass through it for release. We recently ramped up testing on ARM and ARM64. We caught an illegal opcode on both platforms. The illegal opcode related to a rotate, which kind of surprised us. We have experienced it on occasion on other platforms to, like x86_64 when GCC enlists SSE 4.2. Rather than just filing the bug report, we would like to attempt to provide support for the instruction. If the additional support is successful, we would like to offer it back to the community. We are having trouble locating information how to add instruction support to Valgrind. For example, the following is not producing useful results: http://www.google.com/search?q="illegal+opcode"+site:valgrind.org . Is there any information on adding support for unsupported instructions? Thanks in advance. |
|
From: Philippe W. <phi...@sk...> - 2016-01-09 13:45:58
|
On Sat, 2016-01-09 at 07:02 -0500, Jeffrey Walton wrote: > Is there any information on adding support for unsupported instructions? Not that I know of. The best is to read e.g. guest_arm_toIR.c and guest_arm64_toIR.c and inspire from that. I think that usually, it is sufficient to modify these files but sometimes, new IR instructions are needed, or specific helpers have to be developed. If you provide a patch, adding or modifying a test to cover the new instruction helps to have your patch merged. Philippe |
|
From: John R. <jr...@bi...> - 2016-01-09 13:54:25
|
> Is there any information on adding support for unsupported instructions? At this point, with >99% of instructions already recognized, then you should reason by analogy. Use a debugger such as gdb to trace the execution under valgrind of a similar instruction, then modify and extend to handle the unimplemented instruction. For a 'rotate' instruction, use the corresponding right-shift. Hints: Assemble the two-line program _start: .globl _start .word <the-bits-for-your-instruction> using gcc -nostartfiles -nodefaultlibs -nostdlib foo.S to get an executable file with a .text that has 4==.p_memsz. Then run memcheck on that executable. Run "valgrind --help-debug" and look carefully at "Vex options for all Valgrind tools", particularly --trace-flags. Read "Debugging Valgrind with GDB" in README_DEVELOPERS. The code is in VEX/priv/guest_arm* |
|
From: Julian S. <js...@ac...> - 2016-01-18 14:24:26
|
> Is there any information on adding support for unsupported instructions? Not really. As John Reiser says, find an insn which is similar and use that as an example. The front ends (xx_to_IR.c) are highly repetitive and you can usually find something fairly close to what you need. That said, it would be useful to know what insn exactly you ran across. What is implemented tends to cover the output of compilers in common use plus many obscure instructions, but there are still corner cases not implemented. In particular for ARM there are instructions of the form reg1 = reg2 OP (reg3 rotated right by <bizarre constant>) and they may not be implemented. It's also interesting to know why you fell across these; handwritten assembly, maybe? Really the best fix for unimplemented instructions is to file a bug report, and if you do fix it yourself, put the patch on the bug report. J |