Skip to content

Commit

Permalink
features: consider ENOTSUPP in v2 and v4 ISA probes as conclusive
Browse files Browse the repository at this point in the history
With the addition of the v4 ISA probe, we noticed an ENOTSUPP being returned by
BPF_PROG_LOAD on aarch64. Typically, this is an error code internal to the
verifier/JIT, but on aarch64 it seems to bubble up.

Since we cannot currently test older arm kernels, apply this logic to the older
ISA probes as well.

Signed-off-by: Timo Beckers <timo@isovalent.com>
  • Loading branch information
ti-mo committed Dec 12, 2024
1 parent 6d2a32e commit e987b16
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions features/misc.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package features

import (
"errors"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/asm"
"github.com/cilium/ebpf/internal"
"github.com/cilium/ebpf/internal/sys"
)

// HaveLargeInstructions probes the running kernel if more than 4096 instructions
Expand Down Expand Up @@ -62,7 +65,7 @@ func HaveV2ISA() error {
}

var haveV2ISA = internal.NewFeatureTest("v2 ISA", func() error {
return probeProgram(&ebpf.ProgramSpec{
err := probeProgram(&ebpf.ProgramSpec{
Type: ebpf.SocketFilter,
Instructions: asm.Instructions{
asm.Mov.Imm(asm.R0, 0),
Expand All @@ -71,6 +74,11 @@ var haveV2ISA = internal.NewFeatureTest("v2 ISA", func() error {
asm.Return().WithSymbol("exit"),
},
})
// This sometimes bubbles up from the JIT on aarch64.
if errors.Is(err, sys.ENOTSUPP) {
return ebpf.ErrNotSupported
}
return err
}, "4.14")

// HaveV3ISA probes the running kernel if instructions of the v3 ISA are supported.
Expand All @@ -83,7 +91,7 @@ func HaveV3ISA() error {
}

var haveV3ISA = internal.NewFeatureTest("v3 ISA", func() error {
return probeProgram(&ebpf.ProgramSpec{
err := probeProgram(&ebpf.ProgramSpec{
Type: ebpf.SocketFilter,
Instructions: asm.Instructions{
asm.Mov.Imm(asm.R0, 0),
Expand All @@ -92,6 +100,11 @@ var haveV3ISA = internal.NewFeatureTest("v3 ISA", func() error {
asm.Return().WithSymbol("exit"),
},
})
// This sometimes bubbles up from the JIT on aarch64.
if errors.Is(err, sys.ENOTSUPP) {
return ebpf.ErrNotSupported
}
return err
}, "5.1")

// HaveV4ISA probes the running kernel if instructions of the v4 ISA are supported.
Expand Down

0 comments on commit e987b16

Please sign in to comment.