Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3649286pxb; Mon, 24 Jan 2022 14:24:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6ao8ke8Tx4GVXpGlj2O6Lqm9SQE8Z3ItxEUfAMSYk48Dmy7oMBjEAwJJkEGbV9Wq5pV0Z X-Received: by 2002:a17:90a:bc08:: with SMTP id w8mr445842pjr.130.1643063070118; Mon, 24 Jan 2022 14:24:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063070; cv=none; d=google.com; s=arc-20160816; b=DGTUDjZw6tW+ctPF0e3SYLc0jpYwqeC/vAsEHCGcQPHN3ClvPRhFVQLl7ho2KJd+d3 IyFNPRuDW0aro26g+M4maLT7gG0zFEC4oqekmBp/heNdxq9NKIAyr5hC6lbLnQgcSPQn Rn74ZF/sEtYdJavRQfu8DKBNpWXtEBTXdeFU/FW3urFseGYpKXsVVI/yjqOVB45ijiRT pfWG9/xlmJSim3ietrJ/VU82xXNHcJiOCEuP0dRABIrQu+Tg2aLE3KJa6CfcwnnX01gp jcvKy8b2qtAZEpGc1EgFGZcu6ZRb4xNnJXwpWVI4e7B9cSAGcPTL1oYSqlChHqWgIsON grRg== 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=l0afYeiPwwTqf5tobCvx0vwCcVT61Gdy0UmGeZ0F6AM=; b=jJA7w8yKb81jvztceG+IKWaGy/eZvw0czVgm1Ae/Fk8vdrMADXAaGZqRJPx0nhYu4D WoiVpN3nkw9NxphfpDekGbpdZuAsV/sKmakjHTeEK1fva/jPrPPMDT39123grog6+iIY 6yJfEc+VZP2CsL5h28sqkJX0T6Gn8unKmIHk/obsLd+o4o87g376ixeJFO9A9yjBECkJ b9zE6jZN3o+43x/3ftpwDuoc3n4FCZfUFRSiVW/TI7G7OUPUhDvfJ4fQMQvVF0ErHv0D 0s46Ubwhop4JdvuvHap9winBB+a4OYZyowOX4evUkhFezZKEYA61c7QmCqM+kYzraaac 8aaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AgE8WT0K; 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=pass (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 189si1555655pga.684.2022.01.24.14.24.17; Mon, 24 Jan 2022 14:24:30 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=AgE8WT0K; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1583063AbiAXWQX (ORCPT + 99 others); Mon, 24 Jan 2022 17:16:23 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:34358 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376267AbiAXVNV (ORCPT ); Mon, 24 Jan 2022 16:13:21 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id BCD6EB811F3; Mon, 24 Jan 2022 21:13:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8342C340E5; Mon, 24 Jan 2022 21:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058797; bh=RPNJE7lmv9dsqBv8r2uXE3MZEddVG5SDSzixqBWmW/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AgE8WT0K1sanm2oj7HXRNMcdmiXlHf/B6n4ef6+WxzHmXraNMZrmfAU9qBNeTj1p2 tpJBjUYsXJO9KdYO3qI38QCHQPiqemP+2WUsf1o6M8C43Zv/HIBay89qyogRkzo5m0 7B7rvWKODuVvvChJN1eSFZOjsGCInLcBv3660RNM= 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 0372/1039] bpf, arm64: Use emit_addr_mov_i64() for BPF_PSEUDO_FUNC Date: Mon, 24 Jan 2022 19:36:01 +0100 Message-Id: <20220124184137.812097875@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hou Tao [ Upstream commit e4a41c2c1fa916547e63440c73a51a5eb06247af ] The following error is reported when running "./test_progs -t for_each" under arm64: bpf_jit: multi-func JIT bug 58 != 56 [...] JIT doesn't support bpf-to-bpf calls The root cause is the size of BPF_PSEUDO_FUNC instruction increases from 2 to 3 after the address of called bpf-function is settled and there are two bpf-to-bpf calls in test_pkt_access. The generated instructions are shown below: 0x48: 21 00 C0 D2 movz x1, #0x1, lsl #32 0x4c: 21 00 80 F2 movk x1, #0x1 0x48: E1 3F C0 92 movn x1, #0x1ff, lsl #32 0x4c: 41 FE A2 F2 movk x1, #0x17f2, lsl #16 0x50: 81 70 9F F2 movk x1, #0xfb84 Fixing it by using emit_addr_mov_i64() for BPF_PSEUDO_FUNC, so the size of jited image will not change. Fixes: 69c087ba6225 ("bpf: Add bpf_for_each_map_elem() helper") Signed-off-by: Hou Tao Signed-off-by: Daniel Borkmann Link: https://lore.kernel.org/bpf/20211231151018.3781550-1-houtao1@huawei.com Signed-off-by: Sasha Levin --- arch/arm64/net/bpf_jit_comp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c index 3a8a7140a9bfb..c2d95aa1d294c 100644 --- a/arch/arm64/net/bpf_jit_comp.c +++ b/arch/arm64/net/bpf_jit_comp.c @@ -791,7 +791,10 @@ emit_cond_jmp: u64 imm64; imm64 = (u64)insn1.imm << 32 | (u32)imm; - emit_a64_mov_i64(dst, imm64, ctx); + if (bpf_pseudo_func(insn)) + emit_addr_mov_i64(dst, imm64, ctx); + else + emit_a64_mov_i64(dst, imm64, ctx); return 1; } -- 2.34.1