1// SPDX-License-Identifier: GPL-2.0
2/* Converted from tools/testing/selftests/bpf/verifier/unpriv.c */
3
4#include "vmlinux.h"
5#include <bpf/bpf_helpers.h>
6#include "bpf_misc.h"
7
8SEC("perf_event")
9__description("unpriv: spill/fill of different pointers ldx")
10__failure __msg("same insn cannot be used with different pointers")
11__naked void fill_of_different_pointers_ldx(void)
12{
13	asm volatile ("					\
14	r6 = r10;					\
15	r6 += -8;					\
16	if r1 == 0 goto l0_%=;				\
17	r2 = r10;					\
18	r2 += %[__imm_0];				\
19	*(u64*)(r6 + 0) = r2;				\
20l0_%=:	if r1 != 0 goto l1_%=;				\
21	*(u64*)(r6 + 0) = r1;				\
22l1_%=:	r1 = *(u64*)(r6 + 0);				\
23	r1 = *(u64*)(r1 + %[sample_period]);		\
24	r0 = 0;						\
25	exit;						\
26"	:
27	: __imm_const(__imm_0,
28		      -(__s32) offsetof(struct bpf_perf_event_data, sample_period) - 8),
29	  __imm_const(sample_period,
30		      offsetof(struct bpf_perf_event_data, sample_period))
31	: __clobber_all);
32}
33
34char _license[] SEC("license") = "GPL";
35