-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[BOLT][AArch64] Handle OpNegateRAState to enable optimizing binaries with pac-ret hardening #120064
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
Draft
bgergely0
wants to merge
18
commits into
llvm:main
Choose a base branch
from
bgergely0:negate-ra-state-support-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
4760ed9
[BOLT] Recognize paciasp and autiasp instructions
bgergely0 6d5c293
[BOLT] Support for OpNegateRAState
bgergely0 81c2cc0
[BOLT] only run MarkRAState pass on AArch64
bgergely0 6b570da
[BOLT] InsertNegateRAStatePass: remove print
bgergely0 3bf41a2
[BOLT] Remove unused MCAnnotation
bgergely0 ba4b47f
[BOLT] Add changes from code review (#120064)
bgergely0 2c17baa
[BOLT] Fix more review nits (#120064)
bgergely0 59112e3
[BOLT] remove asserts from MarkRAStates
bgergely0 cea4801
[BOLT] Bug fix: remove usage of outdated reference
bgergely0 632ca76
[BOLT] Add all PSign/PAuth variants
bgergely0 2ca430a
[BOLT] Add unit tests for negate_ra_state cfi handling
bgergely0 39397cf
[BOLT][AArch64] Fix which PSign and PAuth variants are used (#120064)
bgergely0 342ccea
[BOLT] Codereview changes #120064
bgergely0 cc46141
[BOLT] Add allow-experimental-pacret flag
bgergely0 aab667f
[BOLT] Disallow Instrumentation mode for pac-ret binaries
bgergely0 2a93a0d
[BOLT] Review nits (NFC)
bgergely0 c3948cf
[BOLT] Only run pac-ret passes if AllowPacret is set.
bgergely0 9717ce6
[BOLT] Basic exception unwinding test
bgergely0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===- bolt/Passes/InsertNegateRAStatePass.cpp ----------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements the InsertNegateRAStatePass class. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef BOLT_PASSES_INSERT_NEGATE_RA_STATE_PASS | ||
#define BOLT_PASSES_INSERT_NEGATE_RA_STATE_PASS | ||
|
||
#include "bolt/Passes/BinaryPasses.h" | ||
#include <stack> | ||
|
||
namespace llvm { | ||
namespace bolt { | ||
|
||
class InsertNegateRAState : public BinaryFunctionPass { | ||
public: | ||
explicit InsertNegateRAState() : BinaryFunctionPass(false) {} | ||
|
||
const char *getName() const override { return "insert-negate-ra-state-pass"; } | ||
|
||
/// Pass entry point | ||
Error runOnFunctions(BinaryContext &BC) override; | ||
void runOnFunction(BinaryFunction &BF); | ||
|
||
private: | ||
/// Loops over all instructions and adds OpNegateRAState CFI | ||
/// after any pointer signing or authenticating instructions, | ||
/// which operate on the LR, except fused ptrauth + ret instructions | ||
/// (such as RETAA). | ||
/// Returns true, if any OpNegateRAState CFIs were added. | ||
bgergely0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
bool addNegateRAStateAfterPacOrAuth(BinaryFunction &BF); | ||
bgergely0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// Because states are tracked as MCAnnotations on individual instructions, | ||
/// newly inserted instructions do not have a state associated with them. | ||
/// New states are "inherited" from the last known state. | ||
void fixUnknownStates(BinaryFunction &BF); | ||
}; | ||
|
||
} // namespace bolt | ||
} // namespace llvm | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===- bolt/Passes/MarkRAStates.cpp ---------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements the MarkRAStates class. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef BOLT_PASSES_MARK_RA_STATES | ||
#define BOLT_PASSES_MARK_RA_STATES | ||
|
||
#include "bolt/Passes/BinaryPasses.h" | ||
|
||
namespace llvm { | ||
namespace bolt { | ||
|
||
class MarkRAStates : public BinaryFunctionPass { | ||
public: | ||
explicit MarkRAStates() : BinaryFunctionPass(false) {} | ||
|
||
const char *getName() const override { return "mark-ra-states"; } | ||
|
||
/// Pass entry point | ||
Error runOnFunctions(BinaryContext &BC) override; | ||
void runOnFunction(BinaryFunction &BF); | ||
}; | ||
|
||
} // namespace bolt | ||
} // namespace llvm | ||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.