From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from imap5.colo.codethink.co.uk (imap5.colo.codethink.co.uk [78.40.148.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 738036EB4C for ; Thu, 14 Mar 2024 10:32:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=78.40.148.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710412332; cv=none; b=V7QZ8vTxz6dMinQ/cKq+W3gQ2tVJm24ObrqgUXvXi8crnGmjfrHJoVXHUgQ0xa8Tlh+1L9X+s7Pp10FroPQhDgkvyannmniWqgQO/T1KO28Xgo61gCZUQh4V5x9qZQzVy2KKfapoiFtXnCBZuOAw3Z5I7bX0Ce8TFlmPRei4qP0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710412332; c=relaxed/simple; bh=IG+0xGQRcuxP2kBpWaihNxT6iMFxh5ldH4Uswj21xYU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=HgVS51zB9boQkWMGPIKjpLfltThhiCrwgkqMv/EmmnkBSfj/E63z1GTmJphZlXp++4mPh05goHXVmGfmWRFYDAUWJ96w96MbRpOGiW42WnOGQkyUyCgtg5hwTju78Oco4PRSVfTuKvEtY1W40z0b29RPlCVeWZUm9HlrNW8slrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codethink.co.uk; spf=pass smtp.mailfrom=codethink.com; dkim=pass (2048-bit key) header.d=codethink.co.uk header.i=@codethink.co.uk header.b=Qcz5XF4k; arc=none smtp.client-ip=78.40.148.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=codethink.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=codethink.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=codethink.co.uk header.i=@codethink.co.uk header.b="Qcz5XF4k" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codethink.co.uk; s=imap5-20230908; h=Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VaEjgu8ITeKxTn4FxZQUOED0yFCvmHCuqkcHOpCtLPQ=; b=Qcz5XF4kGMLSjCH7nvC16jN3Ut +RnXV3NboiLQA+bIqX/U/pr4W+51b53+uucMt1dzjj0/8HSia1dtB+uhqqlVK+eV2PxNhj5R8Pcbx DXsp5oa7D9Yvhk/Pg7w6rchFNFvM1Qg1Lo1sebeIrjMZ3GYVWcxU+HX1DR2YjvcwdvugCYmoL46wK OHaLAwipY6Ygis5+NcZVtSugiQAd+hNMa2NpBQ9EcASnDqPj5+oVhxZOknUrPrAwuaRopNLNk/TTw HGy2XWX6bBMXjKyoVseHkM+xLKZC5SuBhH79exGTEtxO4z4PjnZFufPexWt3aD3cFG1mTUu7ovHJg l7yl/TLA==; Received: from [167.98.27.226] (helo=rainbowdash) by imap5.colo.codethink.co.uk with esmtpsa (Exim 4.94.2 #2 (Debian)) id 1rkiNP-000RB5-Hk; Thu, 14 Mar 2024 10:31:55 +0000 Received: from ben by rainbowdash with local (Exim 4.97) (envelope-from ) id 1rkiNP-0000000ARZR-0aL8; Thu, 14 Mar 2024 10:31:55 +0000 From: Ben Dooks To: ast@kernel.org, daniel@iogearbox.net Cc: bpf@vger.kernel.org, Ben Dooks Subject: [PATCH] bpf: remove trunctaiton warning in BPF_LD_IMM64_RAW Date: Thu, 14 Mar 2024 10:31:53 +0000 Message-Id: <20240314103153.2489252-1-ben.dooks@codethink.co.uk> X-Mailer: git-send-email 2.37.2.352.g3c44437643 Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: srv_ts003@codethink.com When building W=1, the following warningds get generated by lib/test_bpf.c due to the BPF_LD_IMM64_RAW() truncating a 64bit to 32bit value without a specific mask to do so. lib/test_bpf.c:6441:25: warning: cast truncates bits from constant value (ffffffff0000 becomes ffff0000) lib/test_bpf.c:6442:25: warning: cast truncates bits from constant value (ffffffff0000 becomes ffff0000) lib/test_bpf.c:6473:25: warning: cast truncates bits from constant value (123456789abcdef becomes 89abcdef) lib/test_bpf.c:6489:25: warning: cast truncates bits from constant value (123456789abcdef becomes 89abcdef) lib/test_bpf.c:6490:25: warning: cast truncates bits from constant value (123456780a0c0e0 becomes 80a0c0e0) lib/test_bpf.c:6599:25: warning: cast truncates bits from constant value (123456789abcdef becomes 89abcdef) lib/test_bpf.c:6637:25: warning: cast truncates bits from constant value (ffffffff0000 becomes ffff0000) (more warnings truncated) Signed-off-by: Ben Dooks --- include/linux/filter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/filter.h b/include/linux/filter.h index c99bc3df2d28..c1ff6511f365 100644 --- a/include/linux/filter.h +++ b/include/linux/filter.h @@ -238,7 +238,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn) .dst_reg = DST, \ .src_reg = SRC, \ .off = 0, \ - .imm = (__u32) (IMM) }), \ + .imm = (__u32) ((IMM) & (__u64)0xffffffff) }), \ ((struct bpf_insn) { \ .code = 0, /* zero is reserved opcode */ \ .dst_reg = 0, \ -- 2.37.2.352.g3c44437643