Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[s390x] Fix SP unwind rule for the tail-call ABI #9725

Merged

Conversation

uweigand
Copy link
Member

@uweigand uweigand commented Dec 4, 2024

On s390x, the unwound SP is always at current CFA - 160. Therefore, the default rule used on most other platforms (which sets the unwound SP to the current CFA) is incorrect, so we need to provide an explicit DWARF CFI rule to unwind SP.

With the platform ABI, the caller's SP is always stored in the register save area like other call-saved GPRs, so we can simply use a normal DW_CFA_offset rule. However, with the new tail-call ABI, the value saved in that slot is incorrect - it is not corrected for the incoming tail-call stack arguments that will have been removed as the tail call returns.

To fix this without introducing unnecessary run-time overhead, we can simply use a DW_CFA_val_offset rule that will set the unwound SP to CFA - 160, which is always correct. However, the current UnwindInst abstraction does not allow any way to generate this DWARF CFI instruction. Therefore, we introduce a new UnwindInst::RegStackOffset rule for this purpose.

Fixes: #9719

On s390x, the unwound SP is always at current CFA - 160.  Therefore,
the default rule used on most other platforms (which sets the
unwound SP to the current CFA) is incorrect, so we need to provide
an explicit DWARF CFI rule to unwind SP.

With the platform ABI, the caller's SP is always stored in the
register save area like other call-saved GPRs, so we can simply
use a normal DW_CFA_offset rule.  However, with the new tail-call
ABI, the value saved in that slot is incorrect - it is not
corrected for the incoming tail-call stack arguments that will
have been removed as the tail call returns.

To fix this without introducing unnecessary run-time overhead,
we can simply use a DW_CFA_val_offset rule that will set the
unwound SP to CFA - 160, which is always correct.  However, the
current UnwindInst abstraction does not allow any way to generate
this DWARF CFI instruction.  Therefore, we introduce a new
UnwindInst::RegStackOffset rule for this purpose.

Fixes: bytecodealliance#9719
@uweigand uweigand requested a review from a team as a code owner December 4, 2024 01:32
@uweigand uweigand requested review from abrown and removed request for a team December 4, 2024 01:32
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Dec 4, 2024
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

@alexcrichton alexcrichton added this pull request to the merge queue Dec 4, 2024
Merged via the queue into bytecodealliance:main with commit f0a15de Dec 4, 2024
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing s390x with RUST_BACKTRACE=1 in QEMU crashes
2 participants