hulk inclusion category: featrue bugzilla: https://atomgit.com/openeuler/kernel/issues/8480 -------------------------------- Deprecate hisock unused helpers and orig ingress logic. Signed-off-by: Pu Lehui <pulehui@huawei.com> --- arch/arm64/include/asm/insn.h | 4 - arch/arm64/kernel/insn.c | 8 - arch/arm64/net/bpf_jit.h | 15 -- arch/arm64/net/bpf_jit_comp.c | 266 --------------------------------- include/linux/filter.h | 3 - include/net/xdp.h | 5 - include/uapi/linux/bpf.h | 36 ----- kernel/bpf/core.c | 7 - kernel/bpf/helpers.c | 27 ---- kernel/bpf/verifier.c | 25 ---- net/core/dev.c | 19 +-- net/core/filter.c | 120 --------------- tools/include/uapi/linux/bpf.h | 36 ----- 13 files changed, 3 insertions(+), 568 deletions(-) diff --git a/arch/arm64/include/asm/insn.h b/arch/arm64/include/asm/insn.h index 01faf12ddaac..9b9ad2f6d4aa 100644 --- a/arch/arm64/include/asm/insn.h +++ b/arch/arm64/include/asm/insn.h @@ -208,10 +208,6 @@ enum aarch64_insn_ldst_type { AARCH64_INSN_LDST_STORE_PAIR_POST_INDEX, AARCH64_INSN_LDST_LOAD_EX, AARCH64_INSN_LDST_STORE_EX, -#ifdef CONFIG_HISOCK - AARCH64_INSN_LDST_LOAD_PAIR_SIGNED_OFFSET, - AARCH64_INSN_LDST_STORE_PAIR_SIGNED_OFFSET, -#endif }; enum aarch64_insn_adsb_type { diff --git a/arch/arm64/kernel/insn.c b/arch/arm64/kernel/insn.c index 25390b069a05..fbd2b7eec1dc 100644 --- a/arch/arm64/kernel/insn.c +++ b/arch/arm64/kernel/insn.c @@ -745,14 +745,6 @@ u32 aarch64_insn_gen_load_store_pair(enum aarch64_insn_register reg1, case AARCH64_INSN_LDST_STORE_PAIR_POST_INDEX: insn = aarch64_insn_get_stp_post_value(); break; -#ifdef CONFIG_HISOCK - case AARCH64_INSN_LDST_LOAD_PAIR_SIGNED_OFFSET: - insn = aarch64_insn_get_ldp_value(); - break; - case AARCH64_INSN_LDST_STORE_PAIR_SIGNED_OFFSET: - insn = aarch64_insn_get_stp_value(); - break; -#endif default: pr_err("%s: unknown load/store encoding %d\n", __func__, type); return AARCH64_BREAK_FAULT; diff --git a/arch/arm64/net/bpf_jit.h b/arch/arm64/net/bpf_jit.h index c670f35f302c..1835dffb8104 100644 --- a/arch/arm64/net/bpf_jit.h +++ b/arch/arm64/net/bpf_jit.h @@ -96,21 +96,6 @@ /* Rt = Rn[0]; Rt2 = Rn[8]; Rn += 16; */ #define A64_POP(Rt, Rt2, Rn) A64_LS_PAIR(Rt, Rt2, Rn, 16, LOAD, POST_INDEX) -#ifdef CONFIG_HISOCK -#define A64_STP(Rt, Rt2, Rn, offset) \ - A64_LS_PAIR(Rt, Rt2, Rn, offset, STORE, SIGNED_OFFSET) -#define A64_LDP(Rt, Rt2, Rn, offset) \ - A64_LS_PAIR(Rt, Rt2, Rn, offset, LOAD, SIGNED_OFFSET) -#define A64_STP32(Wt, Wt2, Rn, offset) \ - aarch64_insn_gen_load_store_pair(Wt, Wt2, Rn, offset, \ - AARCH64_INSN_VARIANT_32BIT, \ - AARCH64_INSN_LDST_STORE_PAIR_SIGNED_OFFSET) -#define A64_LDP32(Wt, Wt2, Rn, offset) \ - aarch64_insn_gen_load_store_pair(Wt, Wt2, Rn, offset, \ - AARCH64_INSN_VARIANT_32BIT, \ - AARCH64_INSN_LDST_LOAD_PAIR_SIGNED_OFFSET) -#endif - /* Load/store exclusive */ #define A64_SIZE(sf) \ ((sf) ? AARCH64_INSN_SIZE_64 : AARCH64_INSN_SIZE_32) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index e2e065382984..af5760c0d2e7 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -21,26 +21,11 @@ #include "bpf_jit.h" -#ifdef CONFIG_HISOCK -#define TCALL_CNT (MAX_BPF_JIT_REG + 0) -#define FP_BOTTOM (MAX_BPF_JIT_REG + 1) -#define TMP_REG_1 (MAX_BPF_JIT_REG + 2) -#define TMP_REG_2 (MAX_BPF_JIT_REG + 3) -#define TMP_REG_3 (MAX_BPF_JIT_REG + 4) -#define TMP_REG_4 (MAX_BPF_JIT_REG + 5) -#define TMP_REG_5 (MAX_BPF_JIT_REG + 6) -#define TMP_REG_6 (MAX_BPF_JIT_REG + 7) -#define TMP_REG_7 (MAX_BPF_JIT_REG + 8) -#define TMP_REG_8 (MAX_BPF_JIT_REG + 9) -#define TMP_REG_9 (MAX_BPF_JIT_REG + 10) -#define TMP_REG_10 (MAX_BPF_JIT_REG + 11) -#else #define TMP_REG_1 (MAX_BPF_JIT_REG + 0) #define TMP_REG_2 (MAX_BPF_JIT_REG + 1) #define TCALL_CNT (MAX_BPF_JIT_REG + 2) #define TMP_REG_3 (MAX_BPF_JIT_REG + 3) #define FP_BOTTOM (MAX_BPF_JIT_REG + 4) -#endif /* Map BPF registers to A64 registers */ static const int bpf2a64[] = { @@ -63,15 +48,6 @@ static const int bpf2a64[] = { [TMP_REG_1] = A64_R(10), [TMP_REG_2] = A64_R(11), [TMP_REG_3] = A64_R(12), -#ifdef CONFIG_HISOCK - [TMP_REG_4] = A64_R(13), - [TMP_REG_5] = A64_R(14), - [TMP_REG_6] = A64_R(15), - [TMP_REG_7] = A64_R(5), - [TMP_REG_8] = A64_R(6), - [TMP_REG_9] = A64_R(7), - [TMP_REG_10] = A64_R(28), -#endif /* tail_call_cnt */ [TCALL_CNT] = A64_R(26), /* temporary register for blinding constants */ @@ -589,234 +565,6 @@ static int add_exception_handler(const struct bpf_insn *insn, return 0; } -#ifdef CONFIG_HISOCK -static bool support_unaligned_access(void) -{ - unsigned long sctlr = SCTLR_ELx_A; - - switch (read_sysreg(CurrentEL)) { - case CurrentEL_EL1: - sctlr = read_sysreg(sctlr_el1); - break; - case CurrentEL_EL2: - sctlr = read_sysreg(sctlr_el2); - break; - default: - /* not EL1 and EL2 ? */ - break; - } - - return (sctlr & SCTLR_ELx_A) ? false : true; -} - -extern u64 bpf_ext_memcpy(void *dst, size_t dst_sz, - const void *src, size_t src_sz); - -static void emit_memcpy(struct jit_ctx *ctx, int size) -{ - u8 dst = bpf2a64[BPF_REG_1]; - u8 src = bpf2a64[BPF_REG_3]; - u8 tmp1 = bpf2a64[TMP_REG_1]; - u8 tmp2 = bpf2a64[TMP_REG_2]; - u8 tmp3 = bpf2a64[TMP_REG_3]; - u8 tmp4 = bpf2a64[TMP_REG_4]; - u8 tmp5 = bpf2a64[TMP_REG_5]; - u8 tmp6 = bpf2a64[TMP_REG_6]; - u8 tmp7 = bpf2a64[TMP_REG_7]; - u8 tmp8 = bpf2a64[TMP_REG_8]; - u8 tmp9 = bpf2a64[TMP_REG_9]; - u8 tmp10 = bpf2a64[TMP_REG_10]; - - if (!support_unaligned_access()) { - emit_call((u64)bpf_ext_memcpy, ctx); - return; - } - - switch (size) { - case 0: - break; - case 1: - emit(A64_LDRBI(tmp1, src, 0), ctx); - emit(A64_STRBI(tmp1, dst, 0), ctx); - break; - case 2: - emit(A64_LDRHI(tmp1, src, 0), ctx); - emit(A64_STRHI(tmp1, dst, 0), ctx); - break; - case 3: - emit(A64_LDRHI(tmp1, src, 0), ctx); - emit(A64_LDRBI(tmp2, src, 2), ctx); - emit(A64_STRHI(tmp1, dst, 0), ctx); - emit(A64_STRBI(tmp2, dst, 2), ctx); - break; - case 4: - emit(A64_LDR32I(tmp1, src, 0), ctx); - emit(A64_STR32I(tmp1, dst, 0), ctx); - break; - case 5: - emit(A64_LDR32I(tmp1, src, 0), ctx); - emit(A64_LDRBI(tmp2, src, 4), ctx); - emit(A64_STR32I(tmp1, dst, 0), ctx); - emit(A64_STRBI(tmp2, dst, 4), ctx); - break; - case 6: - emit(A64_LDR32I(tmp1, src, 0), ctx); - emit(A64_LDRHI(tmp2, src, 4), ctx); - emit(A64_STR32I(tmp1, dst, 0), ctx); - emit(A64_STRHI(tmp2, dst, 4), ctx); - break; - case 7: - emit(A64_LDR32I(tmp1, src, 0), ctx); - emit(A64_LDRHI(tmp2, src, 4), ctx); - emit(A64_LDRBI(tmp3, src, 6), ctx); - emit(A64_STR32I(tmp1, src, 0), ctx); - emit(A64_STRHI(tmp2, dst, 4), ctx); - emit(A64_STRBI(tmp3, dst, 6), ctx); - break; - case 8: - emit(A64_LDR64I(tmp1, src, 0), ctx); - emit(A64_STR64I(tmp1, dst, 0), ctx); - break; - case 9 ... 15: - emit(A64_ADD_I(1, tmp1, src, size), ctx); - emit(A64_ADD_I(1, tmp2, dst, size), ctx); - emit(A64_LDR64I(tmp3, src, 0), ctx); - emit(A64_LDP32(tmp4, tmp5, tmp1, -8), ctx); - emit(A64_STR64I(tmp3, dst, 0), ctx); - emit(A64_STP32(tmp4, tmp5, tmp2, -8), ctx); - break; - case 16: - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - break; - case 17 ... 31: - emit(A64_ADD_I(1, tmp1, src, size), ctx); - emit(A64_ADD_I(1, tmp2, dst, size), ctx); - emit(A64_LDP(tmp3, tmp4, src, 0), ctx); - emit(A64_LDP(tmp5, tmp6, tmp1, -16), ctx); - emit(A64_STP(tmp3, tmp4, dst, 0), ctx); - emit(A64_STP(tmp5, tmp6, tmp2, -16), ctx); - break; - case 32: - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_LDP(tmp3, tmp4, src, 16), ctx); - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - emit(A64_STP(tmp3, tmp4, dst, 16), ctx); - break; - case 33 ... 63: - emit(A64_ADD_I(1, tmp1, src, size), ctx); - emit(A64_ADD_I(1, tmp2, dst, size), ctx); - emit(A64_LDP(tmp3, tmp4, src, 0), ctx); - emit(A64_LDP(tmp5, tmp6, src, 16), ctx); - emit(A64_STP(tmp3, tmp4, dst, 0), ctx); - emit(A64_STP(tmp5, tmp6, dst, 16), ctx); - emit(A64_LDP(tmp3, tmp4, tmp1, -32), ctx); - emit(A64_LDP(tmp5, tmp6, tmp1, -16), ctx); - emit(A64_STP(tmp3, tmp4, tmp2, -32), ctx); - emit(A64_STP(tmp5, tmp6, tmp2, -16), ctx); - break; - case 64: - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_LDP(tmp3, tmp4, src, 16), ctx); - emit(A64_LDP(tmp5, tmp6, src, 32), ctx); - emit(A64_LDP(tmp7, tmp8, src, 48), ctx); - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - emit(A64_STP(tmp3, tmp4, dst, 16), ctx); - emit(A64_STP(tmp5, tmp6, dst, 32), ctx); - emit(A64_STP(tmp7, tmp8, dst, 48), ctx); - break; - case 65 ... 95: - /* copy first 48 bytes */ - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_LDP(tmp3, tmp4, src, 16), ctx); - emit(A64_LDP(tmp5, tmp6, src, 32), ctx); - - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - emit(A64_STP(tmp3, tmp4, dst, 16), ctx); - emit(A64_STP(tmp5, tmp6, dst, 32), ctx); - - /* copy last 48 bytes */ - emit(A64_ADD_I(1, tmp7, src, size), ctx); - emit(A64_ADD_I(1, tmp8, dst, size), ctx); - - emit(A64_LDP(tmp1, tmp2, tmp7, -48), ctx); - emit(A64_LDP(tmp3, tmp4, tmp7, -32), ctx); - emit(A64_LDP(tmp5, tmp6, tmp7, -16), ctx); - - emit(A64_STP(tmp1, tmp2, tmp8, -48), ctx); - emit(A64_STP(tmp3, tmp4, tmp8, -32), ctx); - emit(A64_STP(tmp5, tmp6, tmp8, -16), ctx); - break; - case 96: - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_LDP(tmp3, tmp4, src, 16), ctx); - emit(A64_LDP(tmp5, tmp6, src, 32), ctx); - emit(A64_LDP(tmp7, tmp8, src, 48), ctx); - - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - emit(A64_STP(tmp3, tmp4, dst, 16), ctx); - emit(A64_STP(tmp5, tmp6, dst, 32), ctx); - emit(A64_STP(tmp7, tmp8, dst, 48), ctx); - - emit(A64_LDP(tmp1, tmp2, src, 64), ctx); - emit(A64_LDP(tmp3, tmp4, src, 80), ctx); - emit(A64_STP(tmp1, tmp2, dst, 64), ctx); - emit(A64_STP(tmp3, tmp4, dst, 80), ctx); - break; - case 97 ... 127: - emit(A64_ADD_I(1, tmp9, src, size), ctx); - emit(A64_ADD_I(1, tmp10, dst, size), ctx); - - /* copy first 64 bytes */ - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_LDP(tmp3, tmp4, src, 16), ctx); - emit(A64_LDP(tmp5, tmp6, src, 32), ctx); - emit(A64_LDP(tmp7, tmp8, src, 48), ctx); - - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - emit(A64_STP(tmp3, tmp4, dst, 16), ctx); - emit(A64_STP(tmp5, tmp6, dst, 32), ctx); - emit(A64_STP(tmp7, tmp8, dst, 48), ctx); - - /* copy last 64 bytes */ - emit(A64_LDP(tmp1, tmp2, tmp9, -64), ctx); - emit(A64_LDP(tmp3, tmp4, tmp9, -48), ctx); - emit(A64_LDP(tmp5, tmp6, tmp9, -32), ctx); - emit(A64_LDP(tmp7, tmp8, tmp9, -16), ctx); - - emit(A64_STP(tmp1, tmp2, tmp10, -64), ctx); - emit(A64_STP(tmp3, tmp4, tmp10, -48), ctx); - emit(A64_STP(tmp5, tmp6, tmp10, -32), ctx); - emit(A64_STP(tmp7, tmp8, tmp10, -16), ctx); - break; - case 128: - emit(A64_LDP(tmp1, tmp2, src, 0), ctx); - emit(A64_LDP(tmp3, tmp4, src, 16), ctx); - emit(A64_LDP(tmp5, tmp6, src, 32), ctx); - emit(A64_LDP(tmp7, tmp8, src, 48), ctx); - - emit(A64_STP(tmp1, tmp2, dst, 0), ctx); - emit(A64_STP(tmp3, tmp4, dst, 16), ctx); - emit(A64_STP(tmp5, tmp6, dst, 32), ctx); - emit(A64_STP(tmp7, tmp8, dst, 48), ctx); - - emit(A64_LDP(tmp1, tmp2, src, 64), ctx); - emit(A64_LDP(tmp3, tmp4, src, 80), ctx); - emit(A64_LDP(tmp5, tmp6, src, 96), ctx); - emit(A64_LDP(tmp7, tmp8, src, 112), ctx); - - emit(A64_STP(tmp1, tmp2, dst, 64), ctx); - emit(A64_STP(tmp3, tmp4, dst, 80), ctx); - emit(A64_STP(tmp5, tmp6, dst, 96), ctx); - emit(A64_STP(tmp7, tmp8, dst, 112), ctx); - break; - default: - emit_call((u64)bpf_ext_memcpy, ctx); - break; - } -} -#endif - /* JITs an eBPF instruction. * Returns: * 0 - successfully JITed an 8-byte eBPF instruction. @@ -1167,13 +915,6 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool func_addr_fixed; u64 func_addr; -#ifdef CONFIG_HISOCK - if (insn->src_reg == 0 && insn->imm == BPF_FUNC_ext_memcpy) { - emit_memcpy(ctx, insn->off); - break; - } -#endif - ret = bpf_jit_get_func_addr(ctx->prog, insn, extra_pass, &func_addr, &func_addr_fixed); if (ret < 0) @@ -1720,13 +1461,6 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) return prog; } -#ifdef CONFIG_HISOCK -bool bpf_jit_supports_ext_helper(void) -{ - return true; -} -#endif - u64 bpf_jit_alloc_exec_limit(void) { return BPF_JIT_REGION_SIZE; diff --git a/include/linux/filter.h b/include/linux/filter.h index 5b9f8648b1ab..3f533983b23e 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -922,9 +922,6 @@ u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog); void bpf_jit_compile(struct bpf_prog *prog); bool bpf_jit_needs_zext(void); -#ifdef CONFIG_HISOCK -bool bpf_jit_supports_ext_helper(void); -#endif u64 bpf_arch_uaddress_limit(void); bool bpf_helper_changes_pkt_data(enum bpf_func_id func_id); diff --git a/include/net/xdp.h b/include/net/xdp.h index 66434c2eae0d..90064cdab519 100644 --- a/include/net/xdp.h +++ b/include/net/xdp.h @@ -107,11 +107,6 @@ static __always_inline void xdp_buff_clear_frags_flag(struct xdp_buff *xdp) } #endif -struct hisock_xdp_buff { - struct xdp_buff xdp; - struct sk_buff *skb; -}; - /* Reserve memory area at end-of data area. * * This macro reserves tailroom in the XDP buffer by limiting the diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h index f0840df75d35..fd5d840f8aae 100644 --- a/include/uapi/linux/bpf.h +++ b/include/uapi/linux/bpf.h @@ -3944,37 +3944,6 @@ union bpf_attr { * Return * 0 on success, or a negative error in case of failure. * - * void *bpf_get_rx_dst(struct bpf_sock_ops *skops) - * Description - * Get the ingress dst entry of the full sock. - * Return - * Valid ingress dst on success, or negative error - * in case of failure. - * - * int bpf_set_rx_dst(struct xdp_buff *xdp, void *dst) - * Description - * Set valid ingress dst entry to the skb associated - * with xdp_buff. - * Return - * 0 on success, or a negative error in case of failure. - * - * int bpf_change_skb_dev(void *ctx, u32 ifindex) - * Description - * Change ingress or egress device of the associated skb. - * Supports only BPF_PROG_TYPE_HISOCK and BPF_PROG_TYPE_XDP - * program types. - * - * *ctx* is either **struct xdp_md** for XDP programs or - * **struct __sk_buff** hisock_egress programs. - * Return - * 0 on success, or negative error in case of failure. - * - * int bpf_ext_memcpy(void *dst, size_t dst_sz, const void *src, size_t src_sz) - * Description - * Copy *src_sz* bytes from *src* to *dst* if *dst_sz* >= *src_sz*. - * Return - * 0 on success, or negative error in case of failure. - * * int bpf_set_ingress_dst(struct sk_buff *skb, void *sk) * Description * Set skb ingress dst entry with valid sock rx dst entry. @@ -4190,10 +4159,6 @@ union bpf_attr { FN(get_node_stats), \ FN(sched_net_rship_submit), \ FN(sched_set_task_prefer_cpumask), \ - FN(get_rx_dst), \ - FN(set_rx_dst), \ - FN(change_skb_dev), \ - FN(ext_memcpy), \ FN(set_ingress_dst), \ FN(get_skb_ethhdr), \ FN(set_ingress_dev), \ @@ -4567,7 +4532,6 @@ enum xdp_action { XDP_PASS, XDP_TX, XDP_REDIRECT, - XDP_HISOCK_REDIRECT = 100, }; /* user accessible metadata for XDP packet hook diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index 6abc58b682a4..c2f5ff16b742 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2376,13 +2376,6 @@ bool __weak bpf_jit_needs_zext(void) return false; } -#ifdef CONFIG_HISOCK -bool __weak bpf_jit_supports_ext_helper(void) -{ - return false; -} -#endif - /* To execute LD_ABS/LD_IND instructions __bpf_prog_run() may call * skb_copy_bits(), so provide a weak definition of it for NET-less config. */ diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index be142202bb6f..205c880d9e01 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -665,29 +665,6 @@ const struct bpf_func_proto bpf_this_cpu_ptr_proto = { .arg1_type = ARG_PTR_TO_PERCPU_BTF_ID, }; -#ifdef CONFIG_HISOCK -BPF_CALL_4(bpf_ext_memcpy, void *, dst, size_t, dst_sz, - const void *, src, size_t, src_sz) -{ - if (dst_sz < src_sz) - return -EINVAL; - - memcpy(dst, src, src_sz); - return 0; -} - -const struct bpf_func_proto bpf_ext_memcpy_proto = { - .func = bpf_ext_memcpy, - .gpl_only = false, - .pkt_access = true, - .ret_type = RET_INTEGER, - .arg1_type = ARG_PTR_TO_MEM | MEM_UNINIT, - .arg2_type = ARG_CONST_SIZE, - .arg3_type = ARG_PTR_TO_MEM | MEM_RDONLY, - .arg4_type = ARG_CONST_SIZE, -}; -#endif - const struct bpf_func_proto bpf_get_current_task_proto __weak; const struct bpf_func_proto bpf_probe_read_user_proto __weak; const struct bpf_func_proto bpf_probe_read_user_str_proto __weak; @@ -744,10 +721,6 @@ bpf_base_func_proto(enum bpf_func_id func_id) return &bpf_sched_tg_tag_of_proto; case BPF_FUNC_sched_task_tag_of: return &bpf_sched_task_tag_of_proto; -#ifdef CONFIG_HISOCK - case BPF_FUNC_ext_memcpy: - return &bpf_ext_memcpy_proto; -#endif default: break; } diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index fe05d95569d8..13df8a2fc4d7 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -5894,21 +5894,6 @@ static int check_helper_call(struct bpf_verifier_env *env, int func_id, int insn return -EINVAL; } -#ifdef CONFIG_HISOCK - if (func_id == BPF_FUNC_ext_memcpy) { - /* XXX: cleanup & check if allowed to access dst mem */ - u32 regno = BPF_REG_1 + 3; - struct bpf_reg_state *regs = cur_regs(env), *reg = ®s[regno]; - struct bpf_insn *insn = &env->prog->insnsi[env->insn_idx]; - - if (!bpf_jit_supports_ext_helper() || - reg->umax_value <= 0 || reg->umax_value > 4096) - return -ENOTSUPP; - - insn->off = reg->umax_value; - } -#endif - /* reset caller saved regs */ for (i = 0; i < CALLER_SAVED_REGS; i++) { mark_reg_not_init(env, regs, caller_saved[i]); @@ -10510,11 +10495,7 @@ static int do_check(struct bpf_verifier_env *env) env->jmps_processed++; if (opcode == BPF_CALL) { if (BPF_SRC(insn->code) != BPF_K || -#ifdef CONFIG_HISOCK - (insn->off != 0 && insn->imm != BPF_FUNC_ext_memcpy) || -#else insn->off != 0 || -#endif (insn->src_reg != BPF_REG_0 && insn->src_reg != BPF_PSEUDO_CALL) || insn->dst_reg != BPF_REG_0 || @@ -12240,12 +12221,6 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) continue; } -#ifdef CONFIG_HISOCK - /* will fixup bpf extension helper in jit */ - if (insn->imm == BPF_FUNC_ext_memcpy) - continue; -#endif - patch_call_imm: fn = env->ops->get_func_proto(insn->imm, env->prog); /* all functions that have prototype and verifier allowed diff --git a/net/core/dev.c b/net/core/dev.c index 27cb74f9ea32..00d7a299211c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4974,10 +4974,6 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb, if (metalen) skb_metadata_set(skb, metalen); break; -#ifdef CONFIG_HISOCK - case XDP_HISOCK_REDIRECT: - break; -#endif default: bpf_warn_invalid_xdp_action(act); fallthrough; @@ -5082,31 +5078,22 @@ static DEFINE_STATIC_KEY_FALSE(generic_xdp_needed_key); int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb) { if (xdp_prog) { - struct hisock_xdp_buff hxdp; - struct xdp_buff *xdp = &hxdp.xdp; + struct xdp_buff xdp; u32 act; int err; - hxdp.skb = skb; - act = netif_receive_generic_xdp(skb, xdp, xdp_prog); + act = netif_receive_generic_xdp(skb, &xdp, xdp_prog); if (act != XDP_PASS) { switch (act) { case XDP_REDIRECT: err = xdp_do_generic_redirect(skb->dev, skb, - xdp, xdp_prog); + &xdp, xdp_prog); if (err) goto out_redir; break; case XDP_TX: generic_xdp_tx(skb, xdp_prog); break; -#ifdef CONFIG_HISOCK - case XDP_HISOCK_REDIRECT: - err = do_hisock_ingress_redirect(skb); - if (err == -EOPNOTSUPP) - return XDP_PASS; - break; -#endif } return XDP_DROP; } diff --git a/net/core/filter.c b/net/core/filter.c index 37b41798d8bd..e28857036d90 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -3844,28 +3844,6 @@ static const struct bpf_func_proto bpf_handle_egress_ptype_proto = { .ret_type = RET_VOID, .arg1_type = ARG_PTR_TO_CTX, }; - -BPF_CALL_2(bpf_skb_change_skb_dev, struct sk_buff *, skb, u32, ifindex) -{ - struct net_device *dev; - - WARN_ON_ONCE(!rcu_read_lock_held()); - - dev = dev_get_by_index_rcu(&init_net, ifindex); - if (!dev) - return -ENODEV; - - skb->dev = dev; - return 0; -} - -static const struct bpf_func_proto bpf_skb_change_skb_dev_proto = { - .func = bpf_skb_change_skb_dev, - .gpl_only = false, - .ret_type = RET_INTEGER, - .arg1_type = ARG_PTR_TO_CTX, - .arg2_type = ARG_ANYTHING, -}; #endif static u32 __bpf_skb_min_len(const struct sk_buff *skb) @@ -6537,64 +6515,6 @@ static const struct bpf_func_proto bpf_xdp_sk_lookup_tcp_proto = { .arg5_type = ARG_ANYTHING, }; -#ifdef CONFIG_HISOCK -BPF_CALL_2(bpf_xdp_set_ingress_dst, struct xdp_buff *, xdp, void *, dst) -{ - struct hisock_xdp_buff *hxdp = (struct hisock_xdp_buff *)xdp; - struct dst_entry *_dst = (struct dst_entry *)dst; - - if (!hxdp->skb) - return -EOPNOTSUPP; - - if (!_dst || !virt_addr_valid(_dst)) - return -EFAULT; - - /* same as skb_valid_dst */ - if (_dst->flags & DST_METADATA) - return -EINVAL; - - skb_dst_set_noref(hxdp->skb, _dst); - return 0; -} - -static const struct bpf_func_proto bpf_xdp_set_ingress_dst_proto = { - .func = bpf_xdp_set_ingress_dst, - .gpl_only = false, - .pkt_access = true, - .ret_type = RET_INTEGER, - .arg1_type = ARG_PTR_TO_CTX, - .arg2_type = ARG_ANYTHING, -}; -#endif - -#ifdef CONFIG_HISOCK -BPF_CALL_2(bpf_xdp_change_skb_dev, struct xdp_buff *, xdp, u32, ifindex) -{ - struct hisock_xdp_buff *hxdp = (void *)xdp; - struct net_device *dev; - - WARN_ON_ONCE(!rcu_read_lock_held()); - - if (!hxdp->skb) - return -EOPNOTSUPP; - - dev = dev_get_by_index_rcu(&init_net, ifindex); - if (!dev) - return -ENODEV; - - hxdp->skb->dev = dev; - return 0; -} - -static const struct bpf_func_proto bpf_xdp_change_skb_dev_proto = { - .func = bpf_xdp_change_skb_dev, - .gpl_only = false, - .ret_type = RET_INTEGER, - .arg1_type = ARG_PTR_TO_CTX, - .arg2_type = ARG_ANYTHING, -}; -#endif - BPF_CALL_5(bpf_sock_addr_skc_lookup_tcp, struct bpf_sock_addr_kern *, ctx, struct bpf_sock_tuple *, tuple, u32, len, u64, netns_id, u64, flags) { @@ -7301,34 +7221,6 @@ static const struct bpf_func_proto bpf_sock_ops_reserve_hdr_opt_proto = { .arg3_type = ARG_ANYTHING, }; -#ifdef CONFIG_HISOCK -BTF_ID_LIST_SINGLE(btf_dst_entity_ids, struct, dst_entry) -BPF_CALL_1(bpf_sock_ops_get_ingress_dst, struct bpf_sock_ops_kern *, sops) -{ - struct sock *sk = sops->sk; - struct dst_entry *dst; - - WARN_ON_ONCE(!rcu_read_lock_held()); - - if (!sk || !sk_fullsock(sk)) - return (unsigned long)NULL; - - dst = rcu_dereference(sk->sk_rx_dst); - if (dst) - dst = dst_check(dst, 0); - - return (unsigned long)dst; -} - -const struct bpf_func_proto bpf_sock_ops_get_ingress_dst_proto = { - .func = bpf_sock_ops_get_ingress_dst, - .gpl_only = false, - .ret_type = RET_PTR_TO_BTF_ID_OR_NULL, - .arg1_type = ARG_PTR_TO_CTX, - .ret_btf_id = &btf_dst_entity_ids[0], -}; -#endif - #endif /* CONFIG_INET */ bool bpf_helper_changes_pkt_data(enum bpf_func_id func_id) @@ -7569,8 +7461,6 @@ hisock_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) return &bpf_skb_change_head_proto; case BPF_FUNC_skb_adjust_room: return &bpf_skb_adjust_room_proto; - case BPF_FUNC_change_skb_dev: - return &bpf_skb_change_skb_dev_proto; case BPF_FUNC_set_ingress_dst: return is_ingress ? &bpf_set_ingress_dst_proto : NULL; case BPF_FUNC_get_skb_ethhdr: @@ -7733,12 +7623,6 @@ xdp_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) return &bpf_xdp_adjust_tail_proto; case BPF_FUNC_fib_lookup: return &bpf_xdp_fib_lookup_proto; -#ifdef CONFIG_HISOCK - case BPF_FUNC_set_rx_dst: - return &bpf_xdp_set_ingress_dst_proto; - case BPF_FUNC_change_skb_dev: - return &bpf_xdp_change_skb_dev_proto; -#endif #ifdef CONFIG_INET case BPF_FUNC_sk_lookup_udp: return &bpf_xdp_sk_lookup_udp_proto; @@ -7800,10 +7684,6 @@ sock_ops_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) return &bpf_sock_ops_store_hdr_opt_proto; case BPF_FUNC_reserve_hdr_opt: return &bpf_sock_ops_reserve_hdr_opt_proto; -#ifdef CONFIG_HISOCK - case BPF_FUNC_get_rx_dst: - return &bpf_sock_ops_get_ingress_dst_proto; -#endif case BPF_FUNC_tcp_sock: return &bpf_tcp_sock_proto; #ifdef CONFIG_HISOCK diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index 7729ba3a13bb..1e4cfd165ff3 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h @@ -3944,37 +3944,6 @@ union bpf_attr { * Return * 0 on success, or a negative error in case of failure. * - * void *bpf_get_rx_dst(struct bpf_sock_ops *skops) - * Description - * Get the ingress dst entry of the full sock. - * Return - * Valid ingress dst on success, or negative error - * in case of failure. - * - * int bpf_set_rx_dst(struct xdp_buff *xdp, void *dst) - * Description - * Set valid ingress dst entry to the skb associated - * with xdp_buff. - * Return - * 0 on success, or negative error in case of failure. - * - * int bpf_change_skb_dev(void *ctx, u32 ifindex) - * Description - * Change ingress or egress device of the associated skb. - * Supports only BPF_PROG_TYPE_HISOCK and BPF_PROG_TYPE_XDP - * program types. - * - * *ctx* is either **struct xdp_md** for XDP programs or - * **struct __sk_buff** hisock_egress programs. - * Return - * 0 on success, or negative error in case of failure. - * - * int bpf_ext_memcpy(void *dst, size_t dst_sz, const void *src, size_t src_sz) - * Description - * Copy *src_sz* bytes from *src* to *dst* if *dst_sz* >= *src_sz*. - * Return - * 0 on success, or negative error in case of failure. - * * int bpf_set_ingress_dst(struct sk_buff *skb, void *sk) * Description * Set skb ingress dst entry with valid sock rx dst entry. @@ -4190,10 +4159,6 @@ union bpf_attr { FN(get_node_stats), \ FN(sched_net_rship_submit), \ FN(sched_set_task_prefer_cpumask), \ - FN(get_rx_dst), \ - FN(set_rx_dst), \ - FN(change_skb_dev), \ - FN(ext_memcpy), \ FN(set_ingress_dst), \ FN(get_skb_ethhdr), \ FN(set_ingress_dev), \ @@ -4571,7 +4536,6 @@ enum xdp_action { XDP_PASS, XDP_TX, XDP_REDIRECT, - XDP_HISOCK_REDIRECT = 100, }; /* user accessible metadata for XDP packet hook -- 2.34.1