Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp697090pxb; Tue, 5 Apr 2022 19:11:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD5/EFq+L6BcavvwdzmjqHjyDXaAQmxsTeKiCj49wKGFQ7y0HlzSSbMej2ETlUOlfUcQG8 X-Received: by 2002:a65:48c6:0:b0:398:b858:e332 with SMTP id o6-20020a6548c6000000b00398b858e332mr5162730pgs.291.1649211108420; Tue, 05 Apr 2022 19:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649211108; cv=none; d=google.com; s=arc-20160816; b=BDYblxTQUnOw7DPBYOk2mdHk2FVn+TkfrCWS3WHg+3tM7R6qjbOsOQcM5L1tuLuFQw s3XzyxVIHgKt9qHpbpbpItUZ78sMC8XP1di76CpexjADbZRGhXsCQXVLRb8T7Wbl9GSR hx11X4jzZTy773f/NDZH5Y53FlqVj+wuoGBIAc7iZZ7nYuDyCvvMMdRx9eDw/S5neFkl JHaY0ONR1NYEoUfGhQ28v+Wajwns/8Zgfit749HIQleLI7hMv86WqZwKS89Hd9G+AzST bVWxSddYvqsb8wVmVsPyQJCJGHlHTC1aZmEJGxsfczQt+/TtB5shyxkUM+hrCi7cpVt0 D/kQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lmAl/Ym4QRqsJd2mY5mo9YCaRpYXlFwP5E3mqFs0y1s=; b=qWhrovtcnydJu2KvXL9FSeH4+SxjEtVfD5idBmsWFeToiTZptSWZwURA117x0D97Ao ZMnQ1+SQ7m5tuuz7WHdgUVksFLyGroLYbNi06CkaTIa8nXNut4VV02Wq7DJr5AR60LhX LnkKxiTg/252XAW43ATMgl+KJCK/2LYATaY/pVRy4SR/atnQtehU3qvrDYYkfqvsSeSU 8WGBUGgN3rSwJbMfB15GAivA8TNIm3Ozb/Vhist2f55fPT+GGsP520c0Fj82ybwWiy0E m5Ep5h9cwD6hNyPsryTi/w38n0ZSNzP/G3+JxZcQz5+hvZdbTPOvzKkQy0j4a2FIG1jM kWPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k+YlihSI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bg16-20020a056a02011000b003991d7cd361si8082553pgb.622.2022.04.05.19.11.33; Tue, 05 Apr 2022 19:11:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k+YlihSI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378146AbiDEMwj (ORCPT + 99 others); Tue, 5 Apr 2022 08:52:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243543AbiDEJJE (ORCPT ); Tue, 5 Apr 2022 05:09:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B89B91B0; Tue, 5 Apr 2022 01:58:13 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A7D4761572; Tue, 5 Apr 2022 08:58:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9145C385A0; Tue, 5 Apr 2022 08:58:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149092; bh=kYZhOnBQIEQ5uNY6XMoHEpNf48Uv3rRYsl8kLmBQSDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+YlihSIqIl71Y23T4AE9EOpDNFn1/ldemvHNusYvAhideNyRKi6voZQ8DMucEbkF ROfn2TJQdcYUiPJaYZ2oQ2Xop3eaVP/S7H+PvnxZ8ZqiigL7jwnvtKQHd31G9hxnZK tceIsxDCcqdcRSdCH8q0oRdKQ7ZR6vDbj80ChdK0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hou Tao , Daniel Borkmann , Sasha Levin Subject: [PATCH 5.16 0553/1017] bpf, arm64: Call build_prologue() first in first JIT pass Date: Tue, 5 Apr 2022 09:24:26 +0200 Message-Id: <20220405070410.698756494@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hou Tao [ Upstream commit 68e4f238b0e9d3670a1612ad900a6e98b2b3f7dd ] BPF line info needs ctx->offset to be the instruction offset in the whole JITed image instead of the body itself, so also call build_prologue() first in first JIT pass. Fixes: 37ab566c178d ("bpf: arm64: Enable arm64 jit to provide bpf_line_info") Signed-off-by: Hou Tao Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20220226121906.5709-2-houtao1@huawei.com Signed-off-by: Sasha Levin --- arch/arm64/net/bpf_jit_comp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 71ef9dcd9b57..3c6d0d60820f 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -1049,15 +1049,18 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) goto out_off; } - /* 1. Initial fake pass to compute ctx->idx. */ - - /* Fake pass to fill in ctx->offset. */ - if (build_body(&ctx, extra_pass)) { + /* + * 1. Initial fake pass to compute ctx->idx and ctx->offset. + * + * BPF line info needs ctx->offset[i] to be the offset of + * instruction[i] in jited image, so build prologue first. + */ + if (build_prologue(&ctx, was_classic)) { prog = orig_prog; goto out_off; } - if (build_prologue(&ctx, was_classic)) { + if (build_body(&ctx, extra_pass)) { prog = orig_prog; goto out_off; } -- 2.34.1