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

Pull some upstream patches related to LVI mitigations compile time #74

Merged

Conversation

jethrogb
Copy link

@jethrogb jethrogb commented Sep 8, 2020

Cherry-pick:

This (partially?) addresses rust-lang/rust#74632

scottconstable and others added 6 commits September 8, 2020 13:51
…VI) mitigations

Fix for the issue raised in rust-lang/rust#74632.

The current heuristic for inserting LFENCEs uses a quadratic-time algorithm. This can apparently cause substantial compilation slowdowns for building Rust projects, where functions > 5000 LoC are apparently common.

The updated heuristic in this patch implements a linear-time algorithm. On a set of benchmarks, the slowdown factor for the generated code was comparable (2.55x geo mean for the quadratic-time heuristic, vs. 2.58x for the linear-time heuristic). Both heuristics offer the same security properties, namely, mitigating LVI.

This patch also includes some formatting fixes.

Differential Revision: https://reviews.llvm.org/D84471
This function has been reduced to an identity function for some time.
The sorting is needed, because reaching defs are (logically) ordered,
but are not collected in that order. This change will break up the
single call to std::sort into a series of smaller sorts, each of which
should use a cheaper comparison function than the original.
This improves performance of PhysicalRegisterInfo::makeRegRef.
@jethrogb
Copy link
Author

Ping for review?

@cuviper
Copy link
Member

cuviper commented Sep 15, 2020

@nikic, do you have a sense of how safe these are to backport?

@nikic
Copy link

nikic commented Sep 15, 2020

@cuviper Not familiar with the code changes here, but in terms of impact this should be fine. LVI changes should only affect people explicitly opting into them (in particular SGX), and I believe that apart from LVI the only other consumer of RDF is the Hexagon target, which is rather obscure (not sure it's even supported by Rust at all). So this shouldn't change anything for standard targets.

@cuviper
Copy link
Member

cuviper commented Sep 16, 2020

OK, works for me.

Note for 3rd-parties: the RDF changes do affect the public API, so you probably don't want this in distro backports, for example.

@cuviper cuviper merged commit a78defc into rust-lang:rustc/11.0-2020-08-20 Sep 16, 2020
vext01 added a commit to vext01/llvm-project that referenced this pull request Jul 18, 2023
74: Stuff required for AOT optimisations. r=ptersilie a=vext01



Co-authored-by: Edd Barrett <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants