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=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 38EE2C04E30 for ; Mon, 9 Dec 2019 18:52:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 170DE205C9 for ; Mon, 9 Dec 2019 18:52:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbfLISwz (ORCPT ); Mon, 9 Dec 2019 13:52:55 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44999 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbfLISwz (ORCPT ); Mon, 9 Dec 2019 13:52:55 -0500 Received: by mail-wr1-f67.google.com with SMTP id q10so17384525wrm.11; Mon, 09 Dec 2019 10:52:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uY4cn+xIFLZ0Oi5hmbU8L9lvpdrHAajc90wxqBq3LmY=; b=eq1mxZg32c83Kjzodfycm7yf+xlFElXlzuFZcbZCX7I0wXR7rm3AaXgjXgphy2S5g2 umfuF5tPnYDLlxiasuFApdlZFequJCZwRH2ss8BJF5s7nU+UGl6hvyQl3NDzyFR3nNac qC+ZtkaDBzECy0/WaBRL2zo8VPaP5GThSl3FnHFYMPX1TlsXYxzgsLbZNFIfIlc5ndPZ bMvlqyG1MMz8prJCwOq8ei+SF7/up134GovfMrsdnI3i3Iu5OdEYnwsTCsMRYIdzKbbe aRoS0433jP8Pc64mNY5FEaeB3XlJ8XmUETLsy0kxLh5qInVRMhxIS1im6AJdMdkN+AZC oEGg== X-Gm-Message-State: APjAAAWnz+futS/jY2rTWeXlxlR/M6+Nj/G+ZAuBlJWENWkkFXg0Nds8 H7JgAZ1+y6HrKl43DQBjdC8= X-Google-Smtp-Source: APXvYqwNShettKgA+gWe7hTfRTlXnGom6hHNhYffFHiwOv6OPhFWKwdvz4bHtVbdJSvPwjDh5fMNuQ== X-Received: by 2002:a5d:4fd0:: with SMTP id h16mr3575944wrw.255.1575917573091; Mon, 09 Dec 2019 10:52:53 -0800 (PST) Received: from Jitter (lfbn-idf1-1-987-41.w86-238.abo.wanadoo.fr. [86.238.65.41]) by smtp.gmail.com with ESMTPSA id s10sm438169wrw.12.2019.12.09.10.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 10:52:52 -0800 (PST) Date: Mon, 9 Dec 2019 19:52:52 +0100 From: Paul Chaignon To: Paul Burton , =?iso-8859-1?Q?Bj=F6rn_T=F6pel?= Cc: Mahshid Khezri , paul.chaignon@gmail.com, bpf@vger.kernel.org, netdev@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko Subject: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org All BPF JIT compilers except RISC-V's and MIPS' enforce a 33-tail calls limit at runtime. In addition, a test was recently added, in tailcalls2, to check this limit. This patch updates the tail call limit in MIPS' JIT compiler to allow 33 tail calls. Fixes: b6bd53f9c4e8 ("MIPS: Add missing file for eBPF JIT.") Reported-by: Mahshid Khezri Signed-off-by: Paul Chaignon --- arch/mips/net/ebpf_jit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c index 46b76751f3a5..3ec69d9cbe88 100644 --- a/arch/mips/net/ebpf_jit.c +++ b/arch/mips/net/ebpf_jit.c @@ -604,6 +604,7 @@ static void emit_const_to_reg(struct jit_ctx *ctx, int dst, u64 value) static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx) { int off, b_off; + int tcc_reg; ctx->flags |= EBPF_SEEN_TC; /* @@ -616,14 +617,14 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx) b_off = b_imm(this_idx + 1, ctx); emit_instr(ctx, bne, MIPS_R_AT, MIPS_R_ZERO, b_off); /* - * if (--TCC < 0) + * if (TCC-- < 0) * goto out; */ /* Delay slot */ - emit_instr(ctx, daddiu, MIPS_R_T5, - (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4, -1); + tcc_reg = (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4; + emit_instr(ctx, daddiu, MIPS_R_T5, tcc_reg, -1); b_off = b_imm(this_idx + 1, ctx); - emit_instr(ctx, bltz, MIPS_R_T5, b_off); + emit_instr(ctx, bltz, tcc_reg, b_off); /* * prog = array->ptrs[index]; * if (prog == NULL) -- 2.17.1