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