Skip to content

Commit 7aa1e62

Browse files
committed
add haveV4ISA probe
This commit introduces the haveV4ISA probe and HaveV4ISA API to check in the running kernel if instructions of the v4 ISA are supported. The upstream commit used as reference is 1f9a1ea821ff ("bpf: Support new sign-extension load insns"). The probes tests the new long jump given by `BPF_JMP32 | BPF_JA`. Signed-off-by: Simone Magnani <[email protected]>
1 parent 2eace67 commit 7aa1e62

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

features/misc.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,25 @@ var haveV3ISA = internal.NewFeatureTest("v3 ISA", func() error {
9393
},
9494
})
9595
}, "5.1")
96+
97+
// HaveV4ISA probes the running kernel if instructions of the v4 ISA are supported.
98+
//
99+
// Upstream commit 1f9a1ea821ff ("bpf: Support new sign-extension load insns").
100+
//
101+
// See the package documentation for the meaning of the error return value.
102+
func HaveV4ISA() error {
103+
return haveV4ISA()
104+
}
105+
106+
var haveV4ISA = internal.NewFeatureTest("v4 ISA", func() error {
107+
return probeProgram(&ebpf.ProgramSpec{
108+
Type: ebpf.SocketFilter,
109+
Instructions: asm.Instructions{
110+
asm.Mov.Imm(asm.R0, 0),
111+
asm.JEq.Imm(asm.R0, 1, "error"),
112+
asm.LongJump("exit"),
113+
asm.Mov.Imm(asm.R0, 1).WithSymbol("error"),
114+
asm.Return().WithSymbol("exit"),
115+
},
116+
})
117+
}, "6.6")

features/misc_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ func TestHaveV2ISA(t *testing.T) {
2121
func TestHaveV3ISA(t *testing.T) {
2222
testutils.CheckFeatureTest(t, HaveV3ISA)
2323
}
24+
25+
func TestHaveV4ISA(t *testing.T) {
26+
testutils.CheckFeatureTest(t, HaveV4ISA)
27+
}

0 commit comments

Comments
 (0)