Bug 497861

Summary: ARM: SUBW Rd, Rn, #uimm12 should accept SP as Rn
Product: [Developer tools] valgrind Reporter: Angelos Oikonomopoulos <aoikonomopoulos>
Component: vexAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version First Reported In: 3.24 GIT   
Target Milestone: ---   
Platform: unspecified   
OS: Other   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: A trivial fix.

Description Angelos Oikonomopoulos 2024-12-24 12:10:06 UTC
Created attachment 176865 [details]
A trivial fix.

SUMMARY
The ARM manual specifies (https://developer.arm.com/documentation/dui0489/i/arm-and-thumb-instructions/sub) that SUBW Rd, Rn, #uimm12 accepts SP as Rn. However, the (T4) SUBW Rd, Rn, #uimm12 case in guest_arm_toIR.c only accepts this form when SP is both Rd and Rn.

STEPS TO REPRODUCE
1. Manually code up a program that uses such an instruction, e.g. I ran into subw    r3, sp, #8 in WebKit's JavaScriptCore.
2. Run the program natively, observe that it doesn't hit a SIGILL.
3. Run the program under valgrind, observe that it takes a SIGILL.

OBSERVED RESULT

SIGILL.

EXPECTED RESULT

No SIGILL.

SOFTWARE/OS VERSIONS
Valgrind at commit 04edd792bd707bace8ccbf947b48b0c70b7dc5d0.

ADDITIONAL INFORMATION