diff --git a/features/misc.go b/features/misc.go index 0c4e1a261..c903198db 100644 --- a/features/misc.go +++ b/features/misc.go @@ -93,3 +93,25 @@ var haveV3ISA = internal.NewFeatureTest("v3 ISA", func() error { }, }) }, "5.1") + +// HaveV4ISA probes the running kernel if instructions of the v4 ISA are supported. +// +// Upstream commit 1f9a1ea821ff ("bpf: Support new sign-extension load insns"). +// +// See the package documentation for the meaning of the error return value. +func HaveV4ISA() error { + return haveV4ISA() +} + +var haveV4ISA = internal.NewFeatureTest("v4 ISA", func() error { + return probeProgram(&ebpf.ProgramSpec{ + Type: ebpf.SocketFilter, + Instructions: asm.Instructions{ + asm.Mov.Imm(asm.R0, 0), + asm.JEq.Imm(asm.R0, 1, "error"), + asm.LongJump("exit"), + asm.Mov.Imm(asm.R0, 1).WithSymbol("error"), + asm.Return().WithSymbol("exit"), + }, + }) +}, "6.6") diff --git a/features/misc_test.go b/features/misc_test.go index 95fa0e09f..7e261039c 100644 --- a/features/misc_test.go +++ b/features/misc_test.go @@ -21,3 +21,7 @@ func TestHaveV2ISA(t *testing.T) { func TestHaveV3ISA(t *testing.T) { testutils.CheckFeatureTest(t, HaveV3ISA) } + +func TestHaveV4ISA(t *testing.T) { + testutils.CheckFeatureTest(t, HaveV4ISA) +}