Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3792779pxf; Mon, 29 Mar 2021 11:32:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6gh96Cpfth+MLwY6pyeL64RsLCI7h1pwn9QYZzqZ3mBfTveFpla1nk/R5bo3NXjoHLGTV X-Received: by 2002:a05:6402:1517:: with SMTP id f23mr30585966edw.272.1617042723060; Mon, 29 Mar 2021 11:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617042723; cv=none; d=google.com; s=arc-20160816; b=q1e8vM4uXZdQLS8rNshKGFhagldU8zTT9yh72D7xh/BPsjF5dJCrRN1Fzr2JKo3C/T i+OTwItb+ojH+LW/ypcC2ndB3urJ9/Cvfw0Qiyk/oVGzr8jQMW3i1Xr02nD82EgvxjN/ zPTyxWyPKF6D6BL6DRMYKHiu8Cf+39Rug5qbp3sjDjEdJJwz6l2/TbLuPXkkzEmh615a xsNZCiVHhzU30BJ8ePKru45WhQuTU/ofRRQwjcDPCHEA0WZdd8/7WXBwrjHLJhU1hKxY nXNI8P48D8tDGN0AQEdI3ihls8ArGGsW29tayGI6tIPyVDVcGiCTe2d0Oy+1CtwAeUoQ 62KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=MgvKzE3RWjWapRps+L/qSm8ZaZUnOBtKKGClBE5IhG0=; b=oyt9Bs5lxVuJCp8sUo++ul3wd+/Syse2qGs0w0i2wO1mHVB3bJ2vE5giZ8+mzf52Cr CG2MnFQKqBzLnb9sV+NnTjyQ7tXaFggw+EdpkMt+BNGoTfzinoKiD/NyIphpP339WlaU bK6YBQ3R5EOr7YsRJVnncz/EKaljX9tNv1eedl1r1ZPNBJVyfoFyPno2ONim6oe7IX0N FEUAzSAggulnSqmvobbPFPzbXEf93sbnyBgdUOP6vHvJaQMTyM0X66Zyk1yoEOMLX9yu xt1QwND48nQ2danQwvRiBtAO0qWKRik7OwF6oOy/xdA0Kj837I6H31eRCq64x8Pdu9s7 6rfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=kroUk+J7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si14158623edb.68.2021.03.29.11.31.40; Mon, 29 Mar 2021 11:32:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mail.ustc.edu.cn header.s=dkim header.b=kroUk+J7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mail.ustc.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbhC2SaS (ORCPT + 99 others); Mon, 29 Mar 2021 14:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231579AbhC2SaL (ORCPT ); Mon, 29 Mar 2021 14:30:11 -0400 Received: from ustc.edu.cn (email6.ustc.edu.cn [IPv6:2001:da8:d800::8]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D950C061574; Mon, 29 Mar 2021 11:30:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.ustc.edu.cn; s=dkim; h=Received:Date:From:To:Cc:Subject: Message-ID:In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=MgvKzE3RWjWapRps+L/qSm8ZaZUnOBtKKG ClBE5IhG0=; b=kroUk+J7j5wAL6f/z9Gvunn7IwgHTeE3rm6zSDEn51PQbACmPX c4lshJok42Rb+iy8E/mc0tndtDJTyN//FL2Cfws+zA3eU/tC+xDDyJM8Q040nLbe 8fBY3uTLQhnFTq3PbcYhQYKEOlj6XOk1x3ey7T+Ok8m+FzXby+c4XMowI= Received: from xhacker (unknown [101.86.19.180]) by newmailweb.ustc.edu.cn (Coremail) with SMTP id LkAmygDHzk6eHGJgFvZpAA--.41814S2; Tue, 30 Mar 2021 02:29:50 +0800 (CST) Date: Tue, 30 Mar 2021 02:24:54 +0800 From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , " =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?=" , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Luke Nelson , Xi Wang Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH 6/9] riscv: bpf: Move bpf_jit_alloc_exec() and bpf_jit_free_exec() to core Message-ID: <20210330022454.3d0feda2@xhacker> In-Reply-To: <20210330022144.150edc6e@xhacker> References: <20210330022144.150edc6e@xhacker> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-CM-TRANSID: LkAmygDHzk6eHGJgFvZpAA--.41814S2 X-Coremail-Antispam: 1UD129KBjvJXoW7KFyftry5KF1fXw4fuw1kAFb_yoW8Cr1UpF s7Cr13ArWvqw1xGryftay7WF1Yyrs5Wa1xWFWUuayrAanIqFW7Zw15Gw15XrZ8ZFyjgayF krWYkr93Cw1kZ37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUkKb7Iv0xC_Zr1lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rw A2F7IY1VAKz4vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xII jxv20xvEc7CjxVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjc xK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40E FcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr 0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcVAKI48JM4IIrI8v6xkF7I0E8cxan2IY 04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI 0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVW8ZVWrXwCIc40Y 0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVW8JVW3JwCI42IY6I8E87Iv67AKxVW8JVWx JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7IU8tKsU UUUUU== X-CM-SenderInfo: xmv2xttqjtqzxdloh3xvwfhvlgxou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jisheng Zhang We will drop the executable permissions of the code pages from the mapping at allocation time soon. Move bpf_jit_alloc_exec() and bpf_jit_free_exec() to bpf_jit_core.c so that they can be shared by both RV64I and RV32I. Signed-off-by: Jisheng Zhang --- arch/riscv/net/bpf_jit_comp64.c | 13 ------------- arch/riscv/net/bpf_jit_core.c | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c index b44ff52f84a6..87e3bf5b9086 100644 --- a/arch/riscv/net/bpf_jit_comp64.c +++ b/arch/riscv/net/bpf_jit_comp64.c @@ -1148,16 +1148,3 @@ void bpf_jit_build_epilogue(struct rv_jit_context *ctx) { __build_epilogue(false, ctx); } - -void *bpf_jit_alloc_exec(unsigned long size) -{ - return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START, - BPF_JIT_REGION_END, GFP_KERNEL, - PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, - __builtin_return_address(0)); -} - -void bpf_jit_free_exec(void *addr) -{ - return vfree(addr); -} diff --git a/arch/riscv/net/bpf_jit_core.c b/arch/riscv/net/bpf_jit_core.c index 3630d447352c..d8da819290b7 100644 --- a/arch/riscv/net/bpf_jit_core.c +++ b/arch/riscv/net/bpf_jit_core.c @@ -164,3 +164,16 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) tmp : orig_prog); return prog; } + +void *bpf_jit_alloc_exec(unsigned long size) +{ + return __vmalloc_node_range(size, PAGE_SIZE, BPF_JIT_REGION_START, + BPF_JIT_REGION_END, GFP_KERNEL, + PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, + __builtin_return_address(0)); +} + +void bpf_jit_free_exec(void *addr) +{ + return vfree(addr); +} -- 2.31.0