Rollup merge of #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` (#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 https://github.com/rust-lang/rust/pull/135107)

r? `@Amanieu`

`@rustbot` label +O-eBPF +A-inline-assembly
This commit is contained in:
Matthias Krüger 2025-01-31 12:28:17 +01:00 committed by GitHub
commit 12a7f06e3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 44 additions and 0 deletions

View file

@ -934,6 +934,7 @@ pub enum InlineAsmClobberAbi {
LoongArch,
PowerPC,
S390x,
Bpf,
Msp430,
}
@ -1003,6 +1004,10 @@ impl InlineAsmClobberAbi {
"C" | "system" => Ok(InlineAsmClobberAbi::S390x),
_ => Err(&["C", "system"]),
},
InlineAsmArch::Bpf => match name {
"C" | "system" => Ok(InlineAsmClobberAbi::Bpf),
_ => Err(&["C", "system"]),
},
InlineAsmArch::Msp430 => match name {
"C" | "system" => Ok(InlineAsmClobberAbi::Msp430),
_ => Err(&["C", "system"]),
@ -1278,6 +1283,14 @@ impl InlineAsmClobberAbi {
a8, a9, a10, a11, a12, a13, a14, a15,
}
},
InlineAsmClobberAbi::Bpf => clobbered_regs! {
Bpf BpfInlineAsmReg {
// Refs: Section 1.1 "Registers and calling convention" in BPF ABI Recommended Conventions and Guidelines v1.0
// https://www.kernel.org/doc/html/latest/bpf/standardization/abi.html#registers-and-calling-convention
r0, r1, r2, r3, r4, r5,
}
},
InlineAsmClobberAbi::Msp430 => clobbered_regs! {
Msp430 Msp430InlineAsmReg {
r11, r12, r13, r14, r15,