Skip to content

Support clobber_abi in BPF inline assembly #136194

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Jan 31, 2025

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Jan 28, 2025

This supports clobber_abi which is one of the requirements of stabilization mentioned in the tracking Issue for asm_experimental_arch (#93335).

Refs: Section 1.1 "Registers and calling convention" in BPF ABI Recommended Conventions and Guidelines v1.0

R0 - R5 are scratch registers and BPF programs needs to spill/fill them if necessary across calls.

cc @alessandrod @dave-tucker @tamird @vadorovsky (target maintainers mentioned in platform support document which will be added by #135107)

r? @Amanieu

@rustbot label +O-eBPF +A-inline-assembly

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-inline-assembly Area: Inline assembly (`asm!(…)`) O-eBPF Target: I heard you liked code execution so I put some code execution in your code execution labels Jan 28, 2025
@Amanieu
Copy link
Member

Amanieu commented Jan 28, 2025

r=me once a target maintainer has approved it

InlineAsmClobberAbi::Bpf => clobbered_regs! {
Bpf BpfInlineAsmReg {
// Refs: Section 1.1 "Registers and calling convention" in BPF ABI Recommended Conventions and Guidelines v1.0
// https://github.com/torvalds/linux/blob/v6.13/Documentation/bpf/standardization/abi.rst#id2
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer if this were a permalink rather than a link to a tag.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, updated comment to use a permalink.

Copy link
Contributor

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

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

Thanks!

InlineAsmClobberAbi::Bpf => clobbered_regs! {
Bpf BpfInlineAsmReg {
// Refs: Section 1.1 "Registers and calling convention" in BPF ABI Recommended Conventions and Guidelines v1.0
// https://github.com/torvalds/linux/blob/ffd294d346d185b70e28b1a28abe367bbfe53c04/Documentation/bpf/standardization/abi.rst#id2
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps even better if we link to the html docs?

https://www.kernel.org/doc./html/latest/bpf/standardization/abi.html

Copy link
Member Author

@taiki-e taiki-e Jan 28, 2025

Choose a reason for hiding this comment

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

I used a link to a specific version of the source code because of my previous experience of using a link to https://www.kernel.org/doc/html/latest/ elsewhere and having trouble when the page being renamed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link

@dave-tucker dave-tucker left a comment

Choose a reason for hiding this comment

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

lgtm thanks!

@tgross35
Copy link
Contributor

@bors r=amanieu

@bors
Copy link
Collaborator

bors commented Jan 30, 2025

📌 Commit e586382 has been approved by amanieu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 30, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 31, 2025
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#134531 ([rustdoc] Add `--extract-doctests` command-line flag)
 - rust-lang#135860 (Compiler: Finalize dyn compatibility renaming)
 - rust-lang#135992 (Improve documentation when adding a new target)
 - rust-lang#136194 (Support clobber_abi in BPF inline assembly)
 - rust-lang#136325 (Delay a bug when indexing unsized slices)
 - rust-lang#136326 (Replace our `LLVMRustDIBuilderRef` with LLVM-C's `LLVMDIBuilderRef`)
 - rust-lang#136330 (Remove unnecessary hooks)
 - rust-lang#136336 (Overhaul `rustc_middle::util`)
 - rust-lang#136341 (Remove myself from vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 31, 2025
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#134531 ([rustdoc] Add `--extract-doctests` command-line flag)
 - rust-lang#135860 (Compiler: Finalize dyn compatibility renaming)
 - rust-lang#135992 (Improve documentation when adding a new target)
 - rust-lang#136194 (Support clobber_abi in BPF inline assembly)
 - rust-lang#136325 (Delay a bug when indexing unsized slices)
 - rust-lang#136326 (Replace our `LLVMRustDIBuilderRef` with LLVM-C's `LLVMDIBuilderRef`)
 - rust-lang#136330 (Remove unnecessary hooks)
 - rust-lang#136336 (Overhaul `rustc_middle::util`)
 - rust-lang#136341 (Remove myself from vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 12a7f06 into rust-lang:master Jan 31, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 31, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 31, 2025
Rollup merge of rust-lang#136194 - taiki-e:bpf-clobber-abi, r=amanieu

Support clobber_abi in BPF inline assembly

This supports [`clobber_abi`](https://doc.rust-lang.org/nightly/reference/inline-assembly.html#abi-clobbers) which is one of the requirements of stabilization mentioned in the tracking Issue for `asm_experimental_arch` (rust-lang#93335).

Refs: [Section 1.1 "Registers and calling convention" in BPF ABI Recommended Conventions and Guidelines v1.0](https://github.com/torvalds/linux/blob/v6.13/Documentation/bpf/standardization/abi.rst#11registers-and-calling-convention)
> R0 - R5 are scratch registers and BPF programs needs to spill/fill them if necessary across calls.

cc `@alessandrod` `@dave-tucker` `@tamird` `@vadorovsky` (target maintainers mentioned in platform support document which will be added by rust-lang#135107)

r? `@Amanieu`

`@rustbot` label +O-eBPF +A-inline-assembly
@taiki-e taiki-e deleted the bpf-clobber-abi branch January 31, 2025 23:27
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) O-eBPF Target: I heard you liked code execution so I put some code execution in your code execution S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants