1*37467c79SEduard Zingerman // SPDX-License-Identifier: GPL-2.0 2*37467c79SEduard Zingerman /* Converted from tools/testing/selftests/bpf/verifier/btf_ctx_access.c */ 3*37467c79SEduard Zingerman 4*37467c79SEduard Zingerman #include <linux/bpf.h> 5*37467c79SEduard Zingerman #include <bpf/bpf_helpers.h> 6*37467c79SEduard Zingerman #include "bpf_misc.h" 7*37467c79SEduard Zingerman 8*37467c79SEduard Zingerman SEC("fentry/bpf_modify_return_test") 9*37467c79SEduard Zingerman __description("btf_ctx_access accept") 10*37467c79SEduard Zingerman __success __retval(0) btf_ctx_access_accept(void)11*37467c79SEduard Zingerman__naked void btf_ctx_access_accept(void) 12*37467c79SEduard Zingerman { 13*37467c79SEduard Zingerman asm volatile (" \ 14*37467c79SEduard Zingerman r2 = *(u32*)(r1 + 8); /* load 2nd argument value (int pointer) */\ 15*37467c79SEduard Zingerman r0 = 0; \ 16*37467c79SEduard Zingerman exit; \ 17*37467c79SEduard Zingerman " ::: __clobber_all); 18*37467c79SEduard Zingerman } 19*37467c79SEduard Zingerman 20*37467c79SEduard Zingerman SEC("fentry/bpf_fentry_test9") 21*37467c79SEduard Zingerman __description("btf_ctx_access u32 pointer accept") 22*37467c79SEduard Zingerman __success __retval(0) ctx_access_u32_pointer_accept(void)23*37467c79SEduard Zingerman__naked void ctx_access_u32_pointer_accept(void) 24*37467c79SEduard Zingerman { 25*37467c79SEduard Zingerman asm volatile (" \ 26*37467c79SEduard Zingerman r2 = *(u32*)(r1 + 0); /* load 1nd argument value (u32 pointer) */\ 27*37467c79SEduard Zingerman r0 = 0; \ 28*37467c79SEduard Zingerman exit; \ 29*37467c79SEduard Zingerman " ::: __clobber_all); 30*37467c79SEduard Zingerman } 31*37467c79SEduard Zingerman 32*37467c79SEduard Zingerman char _license[] SEC("license") = "GPL"; 33