Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3001572ybi; Fri, 5 Jul 2019 00:01:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwng+09ugxvXbDx6B1ro3XtXt9Sg7xacJyJIq0GsWGbSHcBHX3fYhsDSPmh3tq/DTWuUbwG X-Received: by 2002:a17:902:bcc6:: with SMTP id o6mr3239010pls.268.1562310094322; Fri, 05 Jul 2019 00:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562310094; cv=none; d=google.com; s=arc-20160816; b=eLVWvOfLVI3One+qKT3lnaavaEvhFwQIxumiTUmnBMkr0De1eBB0GOXq5hj9uFysLr ULHvW8GExZ8GpCsNDG2sWAzoBn6/hzJ0t4LteRDvEGpYJz99gMpycYdx0awkQjUtk4Th fHD8AdeLhkyWd5c5yMslBH8c8mA037uotEFvAPbCz3NcteX8a1sTOAmnvFYPwuPDKPlQ oBhNnoHB39Oz9r7ZTNFHJ3hsXinD6basq3vaSVR2CO4Nnv/M4D31YOYm53P2MwaAAy/M TldpwzWdNlOWoM85I0ukwMBRCa2rK11dfQFZTUxwWy5rSLMRXsP0+7jGsF0HkIZnDu9B nkuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PZ7J1xjsbzm1U/of1KhsZpOdk4BLy/jqSSNr0GyJ1Og=; b=D0D0j9w3zWD2wov7eZsw9iUfEZpJZJqmq5YbX/wxE9xVpibdaEQFe0FGGSSFimCpSw oVVMrSfGqzEYKwpnz/i46FTV5BT+rhp3lwkdvcWmNrNT3EFY6mF8UWWNfw2iR/XW2hn0 NG0fHvrgTkh+uY1a5iUgJUOCTT3gJCc2/2niB0lLufs588bzs1AgeNtjZ3mGnDZU6Nq7 MdrzzrjcHVrKVU1YlhEyUInfGxo34eKUeMTWPsfbDY65esie1+KkpsToPahNd6q7dVp8 THZ/cBok2jFQogENTTHFqWvmR452tLBLQG0as+KcfL5QbN/fp69DAE9XKV6lM2lz61Ui Uzbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kTYoIrLi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10si7555055pla.135.2019.07.05.00.01.18; Fri, 05 Jul 2019 00:01:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kTYoIrLi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727910AbfGEGbX (ORCPT + 99 others); Fri, 5 Jul 2019 02:31:23 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43440 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727840AbfGEGbX (ORCPT ); Fri, 5 Jul 2019 02:31:23 -0400 Received: by mail-qt1-f195.google.com with SMTP id w17so6998722qto.10; Thu, 04 Jul 2019 23:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=PZ7J1xjsbzm1U/of1KhsZpOdk4BLy/jqSSNr0GyJ1Og=; b=kTYoIrLiHNVlf8mJdGVchtMrXO9vACuma/1M3y8WcbkCkzbhmbYnkZl8hU4MqPhxq0 hzQffvUAThjMmmzI5zAEXXgjNVoZgmKvm3ihA9NSyjGYlJwKXUFfforoHouQkgDJLXEq wbVWB2nsiaAAvRpjGjoGburer6g8LpVI/kqtqvtKZufX1lzDwZasK4EteXjgWs50RVEA +Sd4UvQM9A5makPgQEWm4jcafa3xbYhd4rvMqUe8fsP3iRokKTOs8MDq40DSw0fxPcHz fwGAptLf7RHmQPOLX/Q9abKKO+yNhJnxiqzgTDce+xU/KqZeUGUSR/LDS3vvqIJBDGlu ArGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=PZ7J1xjsbzm1U/of1KhsZpOdk4BLy/jqSSNr0GyJ1Og=; b=NGfEYhiTeXBIHIYR8Pei05UM1/oJlwJEoz1J+za2uID+aIflyQWocC8wBH+vebSfBf drCvDREqPhdJkU/1efELaZk0VHibuyiLN04ezRbfXC1xk43GkZp75eZzOGgXdvBVaBl7 D/2kwYrz9Kb8bQfgJ0emULNcB8V6xe5RsZz+BHc1JgV9VSoKI0UNVtlKSmqyYeMESDtm 1AjIw49EPkgwM4kIMhh9uJyjgmr+RuaXFHiH7cH5tgYrrbXHced6nY1Td+4YcVw9s1gW 8KCDN8Z98AD8ByHCeh6Oj4I6AO3emotIlL0zC+8F303WlzUxsCYG+mtI0QLEPPy2ZJg8 pgew== X-Gm-Message-State: APjAAAUFOQV+mG6oaT6BYJPsU6hQs0l43a7VBiioGZWZqBDsTZpMqGea 3ETwgMF2nCTJ/6NskHZm1eGrEaPcMI7Pxeny5Ww= X-Received: by 2002:a0c:ac98:: with SMTP id m24mr1873564qvc.9.1562308282034; Thu, 04 Jul 2019 23:31:22 -0700 (PDT) MIME-Version: 1.0 References: <20190705001803.30094-1-luke.r.nels@gmail.com> In-Reply-To: <20190705001803.30094-1-luke.r.nels@gmail.com> From: =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= Date: Fri, 5 Jul 2019 08:31:10 +0200 Message-ID: Subject: Re: [PATCH bpf-next] Enable zext optimization for more RV64G ALU ops To: Luke Nelson Cc: LKML , Luke Nelson , Song Liu , Jiong Wang , Xi Wang , Palmer Dabbelt , Albert Ou , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Netdev , linux-riscv@lists.infradead.org, bpf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 5 Jul 2019 at 02:18, Luke Nelson wrote= : > > commit 66d0d5a854a6 ("riscv: bpf: eliminate zero extension code-gen") > added the new zero-extension optimization for some BPF ALU operations. > > Since then, bugs in the JIT that have been fixed in the bpf tree require > this optimization to be added to other operations: commit 1e692f09e091 > ("bpf, riscv: clear high 32 bits for ALU32 add/sub/neg/lsh/rsh/arsh"), > and commit fe121ee531d1 ("bpf, riscv: clear target register high 32-bits > for and/or/xor on ALU32") > > Now that these have been merged to bpf-next, the zext optimization can > be enabled for the fixed operations. > Thanks for the patch, Luke! Acked-by: Bj=C3=B6rn T=C3=B6pel > Cc: Song Liu > Cc: Jiong Wang > Cc: Xi Wang > Signed-off-by: Luke Nelson > --- > arch/riscv/net/bpf_jit_comp.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net/bpf_jit_comp.= c > index 876cb9c705ce..5451ef3845f2 100644 > --- a/arch/riscv/net/bpf_jit_comp.c > +++ b/arch/riscv/net/bpf_jit_comp.c > @@ -757,31 +757,31 @@ static int emit_insn(const struct bpf_insn *insn, s= truct rv_jit_context *ctx, > case BPF_ALU | BPF_ADD | BPF_X: > case BPF_ALU64 | BPF_ADD | BPF_X: > emit(is64 ? rv_add(rd, rd, rs) : rv_addw(rd, rd, rs), ctx= ); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > case BPF_ALU | BPF_SUB | BPF_X: > case BPF_ALU64 | BPF_SUB | BPF_X: > emit(is64 ? rv_sub(rd, rd, rs) : rv_subw(rd, rd, rs), ctx= ); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > case BPF_ALU | BPF_AND | BPF_X: > case BPF_ALU64 | BPF_AND | BPF_X: > emit(rv_and(rd, rd, rs), ctx); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > case BPF_ALU | BPF_OR | BPF_X: > case BPF_ALU64 | BPF_OR | BPF_X: > emit(rv_or(rd, rd, rs), ctx); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > case BPF_ALU | BPF_XOR | BPF_X: > case BPF_ALU64 | BPF_XOR | BPF_X: > emit(rv_xor(rd, rd, rs), ctx); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > case BPF_ALU | BPF_MUL | BPF_X: > @@ -811,13 +811,13 @@ static int emit_insn(const struct bpf_insn *insn, s= truct rv_jit_context *ctx, > case BPF_ALU | BPF_RSH | BPF_X: > case BPF_ALU64 | BPF_RSH | BPF_X: > emit(is64 ? rv_srl(rd, rd, rs) : rv_srlw(rd, rd, rs), ctx= ); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > case BPF_ALU | BPF_ARSH | BPF_X: > case BPF_ALU64 | BPF_ARSH | BPF_X: > emit(is64 ? rv_sra(rd, rd, rs) : rv_sraw(rd, rd, rs), ctx= ); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > > @@ -826,7 +826,7 @@ static int emit_insn(const struct bpf_insn *insn, str= uct rv_jit_context *ctx, > case BPF_ALU64 | BPF_NEG: > emit(is64 ? rv_sub(rd, RV_REG_ZERO, rd) : > rv_subw(rd, RV_REG_ZERO, rd), ctx); > - if (!is64) > + if (!is64 && !aux->verifier_zext) > emit_zext_32(rd, ctx); > break; > > -- > 2.20.1 >