Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2633001pxa; Mon, 17 Aug 2020 15:00:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpsFvaAR7pIcZ7Ys/UwZKbcRv4oJu/4BTQ3F5SgaITHef0M8TmZQb6/04c9TF1GCXBOAUt X-Received: by 2002:a17:907:1183:: with SMTP id uz3mr16981961ejb.216.1597701646876; Mon, 17 Aug 2020 15:00:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597701646; cv=none; d=google.com; s=arc-20160816; b=rTxC6pJrJODiYMcHxFVkqOvppQnfaptBYEjpSdM/HzaMUtzD4cYiermQSdDcVs0SeL UilM0PGEB8Gf+5vEOYOnUb+aCBP2BXSD28hG0rzcqopZtoJbFFIC4NbEcFRxei2vd9+C Vd2BjJwGeSP28+pjP+q3FG3dycrZrWxet/vHmyVlhYv3VGII3zUZgr163TRHs4oYtGXg H3XQgErooJz39YNm0OQ8Da5oBNQbBgOEPR087tRlN4Oj5uv6mEUQXzsuD45P/2cyO7yK m91ySrsXJPX7Xu90kVQaZFfOzKL/qGZkfNr7hLXp1bjSfMdNp8OuJsef/B+uvXGaW+4s PS6A== 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:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WvTSPPaRhnfpBxZBfrBD+4QK8imaSB7GrhP93FGoaLI=; b=LPvJwPFngTZ2KG9xft5VMI2F4x7Wt19ey1n7feR1sD8Mlv0h2PxfrvMb+6GZCS9Qkx BdWhrba/TcfBgW8r+2+XS0++VfZ668QGmuZTpGMDUS5zhfKNz/PwOGTHMSy6HSkyFX7m vzqe141qybLPQ9p+eXOEjTI/KLOYL7TYBNIzdBS5xWdmrKELvUP6m0d7D9qulHxLSFyD c9pHha/7F4PrvR/l6eGX3objkPHIuMjTP021/880/mO0pT+o1+AAe9cE+RUPzK+ebgZW 2qknhKFypPhG+JyaMaafUEEcsWEQoj2JcZKfX9zamGbxdTyopLccE/a/5B6DOPtcuKFb g6Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UDuHtfXD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si11893784ejw.748.2020.08.17.15.00.24; Mon, 17 Aug 2020 15:00:46 -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=@kernel.org header.s=default header.b=UDuHtfXD; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbgHQPhO (ORCPT + 99 others); Mon, 17 Aug 2020 11:37:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:54458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730262AbgHQPbJ (ORCPT ); Mon, 17 Aug 2020 11:31:09 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 464352245C; Mon, 17 Aug 2020 15:31:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678268; bh=puuZK4Hc/ru+F/LefG+5ZC9v99mVnZgP2MsXOFegl9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UDuHtfXDDkoW0gR51mirMoKE5vsHd2mKqeAtdJjTOhdBGCw7uOLWaEMmnj2hUlwCt Rp3OcEL/ZUUUaJjrJ+PdbQajnOvivTktYKJlGvQvZAPCM8rBzYq7e/eV7YlXZlfMnU joz+mtmj9IMYalzrScdBbUxdIfgG6flGZV/W/vRM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Leoshkevich , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.8 275/464] s390/bpf: Use brcl for jumping to exit_ip if necessary Date: Mon, 17 Aug 2020 17:13:48 +0200 Message-Id: <20200817143846.943990302@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143833.737102804@linuxfoundation.org> References: <20200817143833.737102804@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Leoshkevich [ Upstream commit 5fa6974471c5518a50bdd814067508dbcb477251 ] "BPF_MAXINSNS: Maximum possible literals" test causes panic with bpf_jit_harden = 2. The reason is that BPF_JMP | BPF_EXIT is always emitted as brc, however, after removal of JITed image size limitations, brcl might be required. Fix by using brcl when necessary. Fixes: 4e9b4a6883dd ("s390/bpf: Use relative long branches") Signed-off-by: Ilya Leoshkevich Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20200717165326.6786-4-iii@linux.ibm.com Signed-off-by: Sasha Levin --- arch/s390/net/bpf_jit_comp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c index 6b3d612948fba..6b8968f6e207d 100644 --- a/arch/s390/net/bpf_jit_comp.c +++ b/arch/s390/net/bpf_jit_comp.c @@ -1268,8 +1268,12 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp, last = (i == fp->len - 1) ? 1 : 0; if (last) break; - /* j */ - EMIT4_PCREL(0xa7f40000, jit->exit_ip - jit->prg); + if (!is_first_pass(jit) && can_use_rel(jit, jit->exit_ip)) + /* brc 0xf, */ + EMIT4_PCREL_RIC(0xa7040000, 0xf, jit->exit_ip); + else + /* brcl 0xf, */ + EMIT6_PCREL_RILC(0xc0040000, 0xf, jit->exit_ip); break; /* * Branch relative (number of skipped instructions) to offset on -- 2.25.1