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

[DRAFT] #741

Closed
wants to merge 9 commits into from
Closed

[DRAFT] #741

wants to merge 9 commits into from

Conversation

veselypeta
Copy link

No description provided.

StephenHuwClarke and others added 9 commits May 16, 2024 15:34
EVT::getTypeForEVT currently returns a PointerType for MVT::cN, but this
has a couple of issues. The first issue is we have to hard-code the
address space, though that's not such a big deal given we do that
elsewhere too. The bigger issue is that, when we later pass that to
MVT::getVT or EVT::getEVT, it doesn't know what the right size is, so
returns MVT::cPTR instead, which is not a true value type, and is
supposed to only be used by TableGen. This has been seen to confuse
TargetLoweringBase::getTypeConversion, as when presented with a vector
of capability pointers it can end up trying to recreate a smaller vector
of the same type, but this trips up various assertions for the MVT::cPTR
as both the IR methods and the code here are expecting to be dealing
with actual value types.

Borrowing the idea of TypedPointerType (DXILPointerTyID) a bit,
introduce a new IR type, SizedCapabilityType, to represent a fixed-size
capability during CodeGen, which allows lossless roundtripping from MVT
to Type and back.

This fixes building cheritest, which has crashed since the introduction
of cPTR due to cPTR not being a value type, mirroring iPTR, unlike the
old iFATPTRAny which was its own weird beast, but wouldn't have tripped
up these assertions. It probably didn't do the most sensible things
though.

Fixes: 7aa7f2e ("[CodeGen] Rework MVT representation of capabilities and add type inference")
This now preserves typedefs where possible, and the generalisation
allows us to remove the special enum case from its caller.
These are an artifact of how types are structured but serve little
purpose, merely showing that the type is sugared in some way. For
example, ElaboratedType's existence means struct S gets printed as
'struct S':'struct S' in the AST, which is unnecessary visual clutter.
Note that skipping the second print when the types have the same string
matches what we do for diagnostics, where the aka will be skipped.

(cherry picked from commit f9ead46931aef2978ddf350ba6523638175d7861)
Under the benchmark ABI, when making a function call that never returns, the link register might contain an untagged capability generated by a previous function return (Recall that returning under the benchmark ABI involves clearing the LSB of the address, clearing the tag at the same time).
This commit adds support for backtrace and exception handling in
libunwind when the process is running with the compartmentalization
runtime linker. The unwinding process remains the same until a
trampoline is encountered as the return address. This means that we are
crossing compartment boundaries and we need to gather the unwind
information from the runtime linker. We do this by reading information
from the executive stack that the runtime linker populates for us in
unw_getcontext.

It also adds a new class, CompartmentInfo, which is responsible for
abstracting away the details of c18n compartments. Currently, it is only
used to define the constants relating to the trusted frame layout.

The otype allocated to libunwind is given to libunwind by the runtime
linker via the _rtld_unw_getsealer function, and as such this code is
guarded by a LIBUNWIND_CHERI_C18N_SUPPORT define. The sealer is
used to internally access the executive stack pointer in order to unwind
through compartment boundaries. This design may change in the future.

This functionality only works on Morello right now.
subrepo:
  subdir:   "libunwind"
  merged:   "af9f3c32d12f"
upstream:
  origin:   "https://github.com/CTSRD-CHERI/libunwind"
  branch:   "monorepo-mirror"
  commit:   "af9f3c32d12f"
git-subrepo:
  version:  "0.4.1"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "1f13869"
@veselypeta veselypeta closed this Jun 24, 2024
@veselypeta veselypeta deleted the petr/llvm-16 branch June 24, 2024 08:58
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.

5 participants