Skip to content

Support Arena on ARM64 - #6622

Closed
puranjaymohan wants to merge 3 commits into
kernel-patches:bpf-next_basefrom
puranjaymohan:bpf_arm64_arena
Closed

puranjaymohan wants to merge 3 commits into
kernel-patches:bpf-next_basefrom
puranjaymohan:bpf_arm64_arena

Conversation

@puranjaymohan

Copy link
Copy Markdown
Collaborator

The selftest is failing on the CI but passing on my local setup. A change in the selftest might fix it.

Add support for [LDX | STX | ST], PROBE_MEM32, [B | H | W | DW]
instructions.  They are similar to PROBE_MEM instructions with the
following differences:
- PROBE_MEM32 supports store.
- PROBE_MEM32 relies on the verifier to clear upper 32-bit of the
  src/dst register
- PROBE_MEM32 adds 64-bit kern_vm_start address (which is stored in R28
  in the prologue). Due to bpf_arena constructions such R28 + reg +
  off16 access is guaranteed to be within arena virtual range, so no
  address check at run-time.
- PROBE_MEM32 allows STX and ST. If they fault the store is a nop. When
  LDX faults the destination register is zeroed.

To support these on arm64, we do tmp2 = R28 + src/dst reg and then use
tmp2 as the new src/dst register. This allows us to reuse most of the
code for normal [LDX | STX | ST].

Signed-off-by: Puranjay Mohan <[email protected]>
LLVM generates bpf_addr_space_cast instruction while translating
pointers between native (zero) address space and
__attribute__((address_space(N))). The addr_space=1 is reserved as
bpf_arena address space.

rY = addr_space_cast(rX, 0, 1) is processed by the verifier and
converted to normal 32-bit move: wX = wY

rY = addr_space_cast(rX, 1, 0) has to be converted by JIT:

Here I explain using symbolic language what the JIT is supposed to do:
We have:
	src = [src_upper32][src_lower32] // 64 bit src kernel pointer
	uvm = [uvm_upper32][uvm_lower32] // 64 bit user_vm_start

The JIT has to make the dst reg like following
	dst = [uvm_upper32][src_lower32] // if src_lower32 != 0
	dst = [00000000000][00000000000] // if src_lower32 == 0

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf-rc Bot pushed a commit to kernel-patches/bpf-rc that referenced this pull request Mar 22, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf Bot pushed a commit that referenced this pull request Mar 22, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] #6622

Signed-off-by: Puranjay Mohan <[email protected]>
@puranjaymohan

Copy link
Copy Markdown
Collaborator Author

Everything looks good, sent the patch to fix the selftest to the list.

@puranjaymohan
puranjaymohan deleted the bpf_arm64_arena branch March 22, 2024 13:45
kernel-patches-daemon-bpf Bot pushed a commit that referenced this pull request Mar 22, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] #6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf-rc Bot pushed a commit to kernel-patches/bpf-rc that referenced this pull request Mar 22, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf-rc Bot pushed a commit to kernel-patches/bpf-rc that referenced this pull request Mar 22, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf Bot pushed a commit that referenced this pull request Mar 22, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] #6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf-rc Bot pushed a commit to kernel-patches/bpf-rc that referenced this pull request Mar 23, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf Bot pushed a commit that referenced this pull request Mar 23, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] #6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf Bot pushed a commit that referenced this pull request Mar 23, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] #6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf-rc Bot pushed a commit to kernel-patches/bpf-rc that referenced this pull request Mar 23, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
kernel-patches-daemon-bpf-rc Bot pushed a commit to kernel-patches/bpf-rc that referenced this pull request Mar 23, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
puranjaymohan added a commit to puranjaymohan/bpf that referenced this pull request Mar 25, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches#6622

Signed-off-by: Puranjay Mohan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
luigi311 pushed a commit to luigi311/linux that referenced this pull request Mar 31, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>
luigi311 pushed a commit to luigi311/linux that referenced this pull request Mar 31, 2024
The arena_list selftest uses (1ull << 32) in the mmap address
computation for arm64. Use the same in the verifier_arena selftest.

This makes the selftest pass for arm64 on the CI[1].

[1] kernel-patches/bpf#6622

Signed-off-by: Puranjay Mohan <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Alexei Starovoitov <[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.

1 participant