Bug 444242

Summary: s390x: Valgrind crashes on EXRL with negative offset
Product: [Developer tools] valgrind Reporter: Andreas Arnez <arnez>
Component: vexAssignee: Andreas Arnez <arnez>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Sign-extend "relative long" offset in EXRL
Fix with added test case

Description Andreas Arnez 2021-10-22 17:49:57 UTC
Valgrind's implementation of the "execute relative long" (EXRL) instruction zero-extends the offset instead of sign-extending it.  This has been seen to cause a crash with SIGSEGV in s390_irgen_EXRL() when a negative offset occurred.
Comment 1 Andreas Arnez 2021-10-22 18:12:18 UTC
Created attachment 142769 [details]
Sign-extend "relative long" offset in  EXRL

This fixes the calculation of the "relative long" address in EXRL.  The calculation is moved to a helper function addr_rel_long(), which is then used other places as well, wherever applicable.  For consistency, the helper function addr_relative() is added as well.
Comment 2 Andreas Arnez 2021-10-26 15:36:26 UTC
Created attachment 142911 [details]
Fix with added test case

This version of the patch also adds an EXRL invocation with a negative offset to the "exrl.c" test case.  Without the fix, Valgrind crashes when trying to execute this.
Comment 3 Andreas Arnez 2021-10-28 13:10:27 UTC
Applied as commit b77dbefe72e4a5c7bcf1576a02c909010bd56991.