Linux Audio

Check our new training course

Loading...
v6.13.7
  1// SPDX-License-Identifier: GPL-2.0
  2/* Copyright (C) 2023 SUSE LLC */
  3#include <linux/bpf.h>
  4#include <bpf/bpf_helpers.h>
  5#include "bpf_misc.h"
  6
  7SEC("?raw_tp")
  8__success __log_level(2)
  9__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 10__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0xfffffff8 goto pc+2")
 11__msg("mark_precise: frame0: regs=r2 stack= before 1: (87) r2 = -r2")
 12__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 8")
 13__naked int bpf_neg(void)
 14{
 15	asm volatile (
 16		"r2 = 8;"
 17		"r2 = -r2;"
 18		"if r2 != -8 goto 1f;"
 19		"r1 = r10;"
 20		"r1 += r2;"
 21	"1:"
 22		"r0 = 0;"
 23		"exit;"
 24		::: __clobber_all);
 25}
 26
 27SEC("?raw_tp")
 28__success __log_level(2)
 29__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 30__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 31__msg("mark_precise: frame0: regs=r2 stack= before 1: (d4) r2 = le16 r2")
 32__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 33__naked int bpf_end_to_le(void)
 34{
 35	asm volatile (
 36		"r2 = 0;"
 37		"r2 = le16 r2;"
 38		"if r2 != 0 goto 1f;"
 39		"r1 = r10;"
 40		"r1 += r2;"
 41	"1:"
 42		"r0 = 0;"
 43		"exit;"
 44		::: __clobber_all);
 45}
 46
 47
 48SEC("?raw_tp")
 49__success __log_level(2)
 50__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 51__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 52__msg("mark_precise: frame0: regs=r2 stack= before 1: (dc) r2 = be16 r2")
 53__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 54__naked int bpf_end_to_be(void)
 55{
 56	asm volatile (
 57		"r2 = 0;"
 58		"r2 = be16 r2;"
 59		"if r2 != 0 goto 1f;"
 60		"r1 = r10;"
 61		"r1 += r2;"
 62	"1:"
 63		"r0 = 0;"
 64		"exit;"
 65		::: __clobber_all);
 66}
 67
 68#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
 69	(defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 70	defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \
 71	__clang_major__ >= 18
 72
 73SEC("?raw_tp")
 74__success __log_level(2)
 75__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 76__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 77__msg("mark_precise: frame0: regs=r2 stack= before 1: (d7) r2 = bswap16 r2")
 78__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 79__naked int bpf_end_bswap(void)
 80{
 81	asm volatile (
 82		"r2 = 0;"
 83		"r2 = bswap16 r2;"
 84		"if r2 != 0 goto 1f;"
 85		"r1 = r10;"
 86		"r1 += r2;"
 87	"1:"
 88		"r0 = 0;"
 89		"exit;"
 90		::: __clobber_all);
 91}
 92
 93#endif /* v4 instruction */
 94
 95SEC("?raw_tp")
 96__success __log_level(2)
 97/*
 98 * Without the bug fix there will be no history between "last_idx 3 first_idx 3"
 99 * and "parent state regs=" lines. "R0_w=6" parts are here to help anchor
100 * expected log messages to the one specific mark_chain_precision operation.
101 *
102 * This is quite fragile: if verifier checkpointing heuristic changes, this
103 * might need adjusting.
104 */
105__msg("2: (07) r0 += 1                       ; R0_w=6")
106__msg("3: (35) if r0 >= 0xa goto pc+1")
107__msg("mark_precise: frame0: last_idx 3 first_idx 3 subseq_idx -1")
108__msg("mark_precise: frame0: regs=r0 stack= before 2: (07) r0 += 1")
109__msg("mark_precise: frame0: regs=r0 stack= before 1: (07) r0 += 1")
110__msg("mark_precise: frame0: regs=r0 stack= before 4: (05) goto pc-4")
111__msg("mark_precise: frame0: regs=r0 stack= before 3: (35) if r0 >= 0xa goto pc+1")
112__msg("mark_precise: frame0: parent state regs= stack=:  R0_rw=P4")
113__msg("3: R0_w=6")
114__naked int state_loop_first_last_equal(void)
115{
116	asm volatile (
117		"r0 = 0;"
118	"l0_%=:"
119		"r0 += 1;"
120		"r0 += 1;"
121		/* every few iterations we'll have a checkpoint here with
122		 * first_idx == last_idx, potentially confusing precision
123		 * backtracking logic
124		 */
125		"if r0 >= 10 goto l1_%=;"	/* checkpoint + mark_precise */
126		"goto l0_%=;"
127	"l1_%=:"
128		"exit;"
129		::: __clobber_common
130	);
131}
132
133char _license[] SEC("license") = "GPL";
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/* Copyright (C) 2023 SUSE LLC */
  3#include <linux/bpf.h>
  4#include <bpf/bpf_helpers.h>
  5#include "bpf_misc.h"
  6
  7SEC("?raw_tp")
  8__success __log_level(2)
  9__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 10__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0xfffffff8 goto pc+2")
 11__msg("mark_precise: frame0: regs=r2 stack= before 1: (87) r2 = -r2")
 12__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 8")
 13__naked int bpf_neg(void)
 14{
 15	asm volatile (
 16		"r2 = 8;"
 17		"r2 = -r2;"
 18		"if r2 != -8 goto 1f;"
 19		"r1 = r10;"
 20		"r1 += r2;"
 21	"1:"
 22		"r0 = 0;"
 23		"exit;"
 24		::: __clobber_all);
 25}
 26
 27SEC("?raw_tp")
 28__success __log_level(2)
 29__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 30__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 31__msg("mark_precise: frame0: regs=r2 stack= before 1: (d4) r2 = le16 r2")
 32__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 33__naked int bpf_end_to_le(void)
 34{
 35	asm volatile (
 36		"r2 = 0;"
 37		"r2 = le16 r2;"
 38		"if r2 != 0 goto 1f;"
 39		"r1 = r10;"
 40		"r1 += r2;"
 41	"1:"
 42		"r0 = 0;"
 43		"exit;"
 44		::: __clobber_all);
 45}
 46
 47
 48SEC("?raw_tp")
 49__success __log_level(2)
 50__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 51__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 52__msg("mark_precise: frame0: regs=r2 stack= before 1: (dc) r2 = be16 r2")
 53__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 54__naked int bpf_end_to_be(void)
 55{
 56	asm volatile (
 57		"r2 = 0;"
 58		"r2 = be16 r2;"
 59		"if r2 != 0 goto 1f;"
 60		"r1 = r10;"
 61		"r1 += r2;"
 62	"1:"
 63		"r0 = 0;"
 64		"exit;"
 65		::: __clobber_all);
 66}
 67
 68#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
 69	(defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
 70	defined(__TARGET_ARCH_arm) || defined(__TARGET_ARCH_s390)) && \
 71	__clang_major__ >= 18
 72
 73SEC("?raw_tp")
 74__success __log_level(2)
 75__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r1 = r10")
 76__msg("mark_precise: frame0: regs=r2 stack= before 2: (55) if r2 != 0x0 goto pc+2")
 77__msg("mark_precise: frame0: regs=r2 stack= before 1: (d7) r2 = bswap16 r2")
 78__msg("mark_precise: frame0: regs=r2 stack= before 0: (b7) r2 = 0")
 79__naked int bpf_end_bswap(void)
 80{
 81	asm volatile (
 82		"r2 = 0;"
 83		"r2 = bswap16 r2;"
 84		"if r2 != 0 goto 1f;"
 85		"r1 = r10;"
 86		"r1 += r2;"
 87	"1:"
 88		"r0 = 0;"
 89		"exit;"
 90		::: __clobber_all);
 91}
 92
 93#endif /* v4 instruction */
 94
 95SEC("?raw_tp")
 96__success __log_level(2)
 97/*
 98 * Without the bug fix there will be no history between "last_idx 3 first_idx 3"
 99 * and "parent state regs=" lines. "R0_w=6" parts are here to help anchor
100 * expected log messages to the one specific mark_chain_precision operation.
101 *
102 * This is quite fragile: if verifier checkpointing heuristic changes, this
103 * might need adjusting.
104 */
105__msg("2: (07) r0 += 1                       ; R0_w=6")
106__msg("3: (35) if r0 >= 0xa goto pc+1")
107__msg("mark_precise: frame0: last_idx 3 first_idx 3 subseq_idx -1")
108__msg("mark_precise: frame0: regs=r0 stack= before 2: (07) r0 += 1")
109__msg("mark_precise: frame0: regs=r0 stack= before 1: (07) r0 += 1")
110__msg("mark_precise: frame0: regs=r0 stack= before 4: (05) goto pc-4")
111__msg("mark_precise: frame0: regs=r0 stack= before 3: (35) if r0 >= 0xa goto pc+1")
112__msg("mark_precise: frame0: parent state regs= stack=:  R0_rw=P4")
113__msg("3: R0_w=6")
114__naked int state_loop_first_last_equal(void)
115{
116	asm volatile (
117		"r0 = 0;"
118	"l0_%=:"
119		"r0 += 1;"
120		"r0 += 1;"
121		/* every few iterations we'll have a checkpoint here with
122		 * first_idx == last_idx, potentially confusing precision
123		 * backtracking logic
124		 */
125		"if r0 >= 10 goto l1_%=;"	/* checkpoint + mark_precise */
126		"goto l0_%=;"
127	"l1_%=:"
128		"exit;"
129		::: __clobber_common
130	);
131}
132
133char _license[] SEC("license") = "GPL";