From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0049EC2D0C0 for ; Mon, 23 Dec 2019 18:18:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2638207FF for ; Mon, 23 Dec 2019 18:18:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KiijKrRh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Qkwlw+Ij" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D2638207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Content-Transfer-Encoding:Content-Type:Mime-Version:Message-ID:References: In-Reply-To:To:Subject:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d6V52s4BKPdQEpKD1SI2Bsly2g14ETlTsMHFdZhaKlY=; b=KiijKrRhuaE7zq 1BEcPEu/wrHsnvErASKBTVmrOQxqP2sX9lFa1VP10PnggjebeLlCI0AfMBC9Ut+Xdeqmajqt5Zoxy ncszKSFaYUCEufTzpX2lJIhEmvKflxyBXd3vW/t8W+Q+V+AJuI5HnnDuwqO1SoscukYjhNqnLPw5i 2GmC2G0goD6TO7LSgY6+zM0KVDGgJJl+IrLAVO30psmiDdkC/pp7RhJwGUupAPbEAlj9FAvAC4xT0 EDagVom/C8iA/WmhYF+/5SnHCd785uhQVscDZ7yUftI0RAsaZaC65voHTyjlzhu1/DKGM7GPd366i xvQKUIMiV9PwQmLM4mbw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1ijSHr-0006fF-Ml; Mon, 23 Dec 2019 18:18:35 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1ijSHp-0006eS-3s for linux-riscv@lists.infradead.org; Mon, 23 Dec 2019 18:18:34 +0000 Received: by mail-pl1-x642.google.com with SMTP id p27so7474555pli.10 for ; Mon, 23 Dec 2019 10:18:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:subject:cc:to:in-reply-to:references:message-id :mime-version:content-transfer-encoding; bh=d6V52s4BKPdQEpKD1SI2Bsly2g14ETlTsMHFdZhaKlY=; b=Qkwlw+Ij3PJFQxO4sc7jGlpz5uhxnFhk5DVuVfP2vARkXal4HIih6A3mW8RrTYZTvp ICXsjLwgegS/rsC+Hem7BQ4/R5Z8oNb5WB1/i4VKeEixjJzAumbCGKk3ctZ0gNc7eqlP jXrnUhhmUBJJLaoNJXQlomTmlIMevULmq/IbEzbbbEQyrsWFlbS2CD/xmM1/vUKpzf6R Zn9n2miOFQjXH9ph0eX9Az63DK0huTVMNr+dIxrX6U3Il1vmgna+rGCRgtYiIT0QUZ/E mkJNKTsL0NbVqT0ekA01dwxghcvk+/LFT1ROT/iMy1wLQYjyH1DoGr+09kEg/eCZyJzQ XeHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:cc:to:in-reply-to:references :message-id:mime-version:content-transfer-encoding; bh=d6V52s4BKPdQEpKD1SI2Bsly2g14ETlTsMHFdZhaKlY=; b=oF1pNOM8EAfKDKZX1Ik9/uv71guwPgf0x9fjALiQgx5LXrHxzdpG3bCttPfuFJkNmU dBYPyltwUZc1R/fyYNMRvmkf10wPooWkhALPcelEcvQ/jHdQzxxZl5OJetqTIHgpkDDT LfOZK2vywfPO+zl6E7RL9WI5aeqzTHg4SXfudWTBGiul9zJojwM+gNFRGPeEUIaAip2T jOhiFJFOJ0sFTtllwOO6+v0WCK0ttQhypYnL1xXcHC0omkV2tmRFTXcHA5PMNI5SpRmX 7T7EJ/yj8Zj+sukfkpHDlyqbl5xxaVfZFI/u7SP3pdAq+rwjMZeC7Ely9e4gkOll2inB fpgQ== X-Gm-Message-State: APjAAAX2E/W4qqf+SJolp9SfBx9YqLS+6ebiXlWzoM8G4UZ8hDkd5aF4 yu1tLKJd1GfrTQVwvx/0lic/WA== X-Google-Smtp-Source: APXvYqxNkRz1IM63bfQgOhAxwSwTHbysAAjI6yuR5hi+uX515zg1SMQxxfRyXcnH0a8YFQqmrfACcQ== X-Received: by 2002:a17:902:aa48:: with SMTP id c8mr31418813plr.243.1577125111719; Mon, 23 Dec 2019 10:18:31 -0800 (PST) Received: from localhost ([2620:0:1000:2514:7f69:cd98:a2a2:a03d]) by smtp.gmail.com with ESMTPSA id k1sm121461pjl.21.2019.12.23.10.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2019 10:18:31 -0800 (PST) Date: Mon, 23 Dec 2019 10:18:31 -0800 (PST) X-Google-Original-Date: Mon, 23 Dec 2019 10:09:23 PST (-0800) From: Palmer Dabbelt X-Google-Original-From: Palmer Dabbelt Subject: Re: [PATCH bpf-next v2 3/9] riscv, bpf: add support for far branching when emitting tail call To: Bjorn Topel In-Reply-To: <20191216091343.23260-4-bjorn.topel@gmail.com> References: <20191216091343.23260-4-bjorn.topel@gmail.com> <20191216091343.23260-1-bjorn.topel@gmail.com> Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191223_101833_186538_843F7BC3 X-CRM114-Status: GOOD ( 13.82 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel@iogearbox.net, netdev@vger.kernel.org, ast@kernel.org, Bjorn Topel , linux-riscv@lists.infradead.org, bpf@vger.kernel.org Sender: "linux-riscv" Errors-To: linux-riscv-bounces+infradead-linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, 16 Dec 2019 01:13:37 PST (-0800), Bjorn Topel wrote: > Start use the emit_branch() function in the tail call emitter in order > to support far branching. > > Signed-off-by: Björn Töpel > --- > arch/riscv/net/bpf_jit_comp.c | 22 +++------------------- > 1 file changed, 3 insertions(+), 19 deletions(-) > > diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net/bpf_jit_comp.c > index e599458a9bcd..c38c95df3440 100644 > --- a/arch/riscv/net/bpf_jit_comp.c > +++ b/arch/riscv/net/bpf_jit_comp.c > @@ -496,16 +496,6 @@ static int is_12b_check(int off, int insn) > return 0; > } > > -static int is_13b_check(int off, int insn) > -{ > - if (!is_13b_int(off)) { > - pr_err("bpf-jit: insn=%d 13b < offset=%d not supported yet!\n", > - insn, (int)off); > - return -1; > - } > - return 0; > -} > - > static int is_21b_check(int off, int insn) > { > if (!is_21b_int(off)) { > @@ -744,18 +734,14 @@ static int emit_bpf_tail_call(int insn, struct rv_jit_context *ctx) > return -1; > emit(rv_lwu(RV_REG_T1, off, RV_REG_A1), ctx); > off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2; > - if (is_13b_check(off, insn)) > - return -1; > - emit(rv_bgeu(RV_REG_A2, RV_REG_T1, off >> 1), ctx); > + emit_branch(BPF_JGE, RV_REG_A2, RV_REG_T1, off, ctx); > > /* if (--TCC < 0) > * goto out; > */ > emit(rv_addi(RV_REG_T1, tcc, -1), ctx); > off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2; > - if (is_13b_check(off, insn)) > - return -1; > - emit(rv_blt(RV_REG_T1, RV_REG_ZERO, off >> 1), ctx); > + emit_branch(BPF_JSLT, RV_REG_T1, RV_REG_ZERO, off, ctx); > > /* prog = array->ptrs[index]; > * if (!prog) > @@ -768,9 +754,7 @@ static int emit_bpf_tail_call(int insn, struct rv_jit_context *ctx) > return -1; > emit(rv_ld(RV_REG_T2, off, RV_REG_T2), ctx); > off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2; > - if (is_13b_check(off, insn)) > - return -1; > - emit(rv_beq(RV_REG_T2, RV_REG_ZERO, off >> 1), ctx); > + emit_branch(BPF_JEQ, RV_REG_T2, RV_REG_ZERO, off, ctx); > > /* goto *(prog->bpf_func + 4); */ > off = offsetof(struct bpf_prog, bpf_func); Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt