Skip to content

selftests/bpf: more precise cpu_mitigations state detection

Eduard Zingerman bpf 3 versions – Applied

Status from this message: This patch was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest1 patch 0 repliesApplied 1/1
  2. v21 patch 4 repliesSuperseded
  3. v11 patch 4 repliesSuperseded

Changes in v3 from the cover letter

- stylistic changes (Andrii).

Patches in v3 All 1 applied

#Subject and filesSizeRepliesApplied
1/1selftests/bpf: more precise cpu_mitigations state detectiontools/testing/selftests/bpf/unpriv_helpers.c+90 -30 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/1] selftests/bpf: more precise cpu_mitigations state detection

If kernel executing selftests is configured with spectre mitigations disabled, verification of unprivileged BPF won't emulate speculative branches.

A number of selftests relies on speculative branches being visited. In discussion [1] it was decided not to add additional tests classification, but to execute unprivileged tests only when mitigations are enabled.

Current mitigations status detection inspects /proc/cmdline, which is not sufficient for some configurations. This patch adds logic to also inspect /proc/config.gz and /boot/config-$(uname -r).

Changelog:
v2: https://lore.kernel.org/bpf/[email protected]/
v2 -> v3:
- stylistic changes (Andrii).

v1: https://lore.kernel.org/bpf/[email protected]/
v1 -> v2:
- added code to visit /boot/config-$(uname -r) (Yafang, Andrii)
- in case if config can't be read, print a warning and disable unprivileged tests execution.

[1] https://lore.kernel.org/bpf/[email protected]/

Eduard Zingerman (1):
selftests/bpf: more precise cpu_mitigations state detection

 tools/testing/selftests/bpf/unpriv_helpers.c | 93 +++++++++++++++++++-
 1 file changed, 90 insertions(+), 3 deletions(-)
Signature · 1 line
2.47.1