-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libunwind][PAuthLR] Remove PC offset when using FEAT_PAuthLR #164224
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
[libunwind][PAuthLR] Remove PC offset when using FEAT_PAuthLR #164224
Conversation
When originally introduced to libunwind as part of llvm#112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, an offset was introduced to work with this. However, this design was reversed in llvm#121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwinds PC value would be incorrect. This can be removed from the code, as it is no longer needed.
|
@llvm/pr-subscribers-libunwind Author: Jack Styles (Stylie777) ChangesWhen originally introduced to libunwind as part of #112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, an offset was introduced to work with this. However, this design was reversed in #121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwinds PC value would be incorrect. This can be removed from the code, as it is no longer needed. Full diff: https://github.com/llvm/llvm-project/pull/164224.diff 1 Files Affected:
diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index 25250e0810987..625780f1f4558 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -808,12 +808,6 @@ bool CFI_Parser<A>::parseFDEInstructions(A &addressSpace,
results->savedRegisters[UNW_AARCH64_RA_SIGN_STATE].value ^ 0x3;
results->setRegisterValue(UNW_AARCH64_RA_SIGN_STATE, value,
initialState);
- // When calculating the value of the PC, it is assumed that the CFI
- // instruction is placed before the signing instruction, however it is
- // placed after. Because of this, we need to take into account the CFI
- // instruction is one instruction call later than expected, and reduce
- // the PC value by 4 bytes to compensate.
- results->ptrAuthDiversifier = fdeInfo.pcStart + codeOffset - 0x4;
_LIBUNWIND_TRACE_DWARF(
"DW_CFA_AARCH64_negate_ra_state_with_pc(pc=0x%" PRIx64 ")\n",
static_cast<uint64_t>(results->ptrAuthDiversifier));
|
We still need to set this value when we look at PAuthLR, it was just the 4 byte offset that needed removing
| // instruction is one instruction call later than expected, and reduce | ||
| // the PC value by 4 bytes to compensate. | ||
| results->ptrAuthDiversifier = fdeInfo.pcStart + codeOffset - 0x4; | ||
| results->ptrAuthDiversifier = fdeInfo.pcStart + codeOffset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you edit this comment instead of entirely discarding it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…64224) When originally introduced to libunwind as part of llvm#112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, a 4 byte offset was introduced to work with this. However, this design was reversed in llvm#121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwind's PC value would be incorrect. As the 4 byte offset is no longer needed, that adjustment can be removed. results->ptrAuthDiversifier will still be set.
…64224) When originally introduced to libunwind as part of llvm#112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, a 4 byte offset was introduced to work with this. However, this design was reversed in llvm#121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwind's PC value would be incorrect. As the 4 byte offset is no longer needed, that adjustment can be removed. results->ptrAuthDiversifier will still be set.
When originally introduced to libunwind as part of #112171, FEAT_PAuthLR had its Call Frame Instruction's (CFI's) in a different location to other Signing Authentication methods. To incorporate this in libunwind, a 4 byte offset was introduced to work with this. However, this design was reversed in #121551 so the CFI's are emitted in the same location as other methods. When making this change, the offset in libunwind was not removed, so libunwind's PC value would be incorrect.
As the 4 byte offset is no longer needed, that adjustment can be removed. results->ptrAuthDiversifier will still be set.