Skip to content

Library support for aarch64-unknown-linux-pauthtest target#156548

Open
jchlanda wants to merge 6 commits into
rust-lang:mainfrom
jchlanda:jakub/pac_lib
Open

Library support for aarch64-unknown-linux-pauthtest target#156548
jchlanda wants to merge 6 commits into
rust-lang:mainfrom
jchlanda:jakub/pac_lib

Conversation

@jchlanda

@jchlanda jchlanda commented May 13, 2026

Copy link
Copy Markdown
Contributor

View all comments

This is a follow up to #155722, adding library support for the target.

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels May 13, 2026
@jchlanda

Copy link
Copy Markdown
Contributor Author

The relevant change is only in the two most recent commits, the rest is from the target introduction PR.

@jchlanda

jchlanda commented May 18, 2026

Copy link
Copy Markdown
Contributor Author

@davidtwco, @folkertdev, @tgross35, @madsmtm FWI this is a follow up to #155722
This will have to be rebased once #155722 is merged.

@jchlanda jchlanda marked this pull request as ready for review May 19, 2026 12:16
@rustbot

rustbot commented May 19, 2026

Copy link
Copy Markdown
Collaborator

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

Some changes occurred in src/tools/compiletest

cc @jieyouxu

The GCC codegen subtree was changed

cc @antoyo, @GuillaumeGomez

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

This PR modifies tests/auxiliary/minicore.rs.

cc @jieyouxu

These commits modify compiler targets.
(See the Target Tier Policy.)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 19, 2026
@rustbot

rustbot commented May 19, 2026

Copy link
Copy Markdown
Collaborator

r? @folkertdev

rustbot has assigned @folkertdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 20 candidates

@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@jchlanda jchlanda force-pushed the jakub/pac_lib branch 2 times, most recently from c54b875 to 26986cc Compare June 17, 2026 13:14
@rustbot

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot

This comment has been minimized.

@rustbot

rustbot commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@davidtwco I'd appreciate your review here too.

View changes since this review

Comment thread library/std/tests/process_spawning.rs Outdated
Comment thread library/unwind/src/lib.rs Outdated
Comment on lines +59 to +62
// For pauthtest the only supported unwinding mechanism is provided by libunwind.
#[cfg(target_abi = "pauthtest")]
#[link(name = "unwind")]
unsafe extern "C" {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is making some assumptions about the target_os values that can occur in combination with target_abi = "pauthtest" right? Can you make those assumptions explicit in a comment here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've re-worded it to mention that the only supported OS for pauthtest target is Linux.

Comment thread library/std/tests/pipe_subprocess.rs Outdated
Comment on lines +102 to +108
// `pacib` corresponds to `ptrauth_key_process_dependent_code` in <ptrauth.h>.
core::arch::asm!(
"pacib {addr}, {sp}",
addr = inout(reg) addr,
sp = in(reg) sp,
options(nostack, preserves_flags)
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should this be in stdarch? or does it really only make sense to use inline assembly here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I originally introduced an intrinsic for resigning. Then discussed it with @davidtwco, and decided that inline asm was the better approach. Providing an intrinsic could potentially introduce a security risk by making it easier to construct signing oracles. As for stdarch, my understanding is that there is ongoing work to provide more comprehensive pointer authentication support, but to my knowledge it has not been completed yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, I'd like to propose eventually a handful of more complete pointer authentication intrinsics but making sure they can't be used as signing oracles is difficult so we've not proposed anything yet

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 30, 2026
@rustbot

rustbot commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@jchlanda

jchlanda commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Hi all (@davidtwco, @folkertdev, @tgross35, @madsmtm, @bjorn3),

The PR introducing the pauthtest target has been merged into main. I'd be very grateful if we could move this one forward as well.

Thank you!

@folkertdev folkertdev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rustbot rustbot assigned davidtwco and unassigned folkertdev Jul 1, 2026

@davidtwco davidtwco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me, r=me after checking if the suggestion below works

View changes since this review

#[cfg(any(target_arch = "loongarch32", target_arch = "loongarch64"))]
const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1

unsafe fn sign_lpad(context: *mut uw::_Unwind_Context, lpad: *const u8) -> *const u8 {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure it's strictly necessary, but we could use #[rustc_force_inline] here which we added for PAuth-related use but haven't actually started using yet

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It does the trick, for a simple backtrace sample, when inspected with objdump, I can see the code inlined into rust_eh_personality:

000000000006a7b0 <rust_eh_personality>:
   6a7b0: d503237f     	pacibsp
   6a7b4: d102c3ff     	sub	sp, sp, #0xb0

...

   6ac7c: aa1303e0     	mov	x0, x19
   6ac80: 528003e1     	mov	w1, #0x1f               // =31
   6ac84: 940053cf     	bl	0x7fbc0 <_Unwind_GetGR@plt>
   6ac88: dac10416     	pacib	x22, x0
   6ac8c: aa1303e0     	mov	x0, x19
   6ac90: aa1603e1     	mov	x1, x22
   6ac94: 940053cf     	bl	0x7fbd0 <_Unwind_SetIP@plt>

...

no branching to sign_lpad, which got entirely optimised-out (inlined).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In that case, given this fn is only used in std, we could use it here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-compiletest Area: The compiletest test runner A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. A-run-make Area: port run-make Makefiles to rmake.rs A-test-infra-minicore Area: `minicore` test auxiliary and `//@ add-core-stubs` A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants