Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4033038rdh; Tue, 28 Nov 2023 09:59:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHWoxC9LxpY5or81ljY5VkHGk4KlVwsaiPTBGycVLcgjm3e+a6j9Tb4HJlliMVzLAqJ/djq X-Received: by 2002:a17:90b:4d10:b0:280:f534:6b9c with SMTP id mw16-20020a17090b4d1000b00280f5346b9cmr14836505pjb.21.1701194391857; Tue, 28 Nov 2023 09:59:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701194391; cv=none; d=google.com; s=arc-20160816; b=pfEehGLwi0Q2DPAba0n4FQDtYFj8ZXHn6Wxt2YfLxkLrHsAeKSHt8C6rf0j1Zg6VRL Fsi68oH7nn61wWn8mCWlfd2C4whLmObd3Sd6YUIdv3qnboZqxc6HTlrBUIhR3NrSLlF6 Kgm6ekw/VaOTigWJYu/y21VS0ITImctgM1IM4/2ChyizwihuO4lYmfMMKqpYeKgP3E13 wPnc097yeiQQcjyL42a5jNqyFsp2kmovQSj+Met0UJB/fHc4xYTHG52M3C/cgnl/sEfi eCnk4NkM5k5SqKdaPIKwylCCOFD1vhX2Wwn01+A555+ozyjpCMr6p5y5Qh7pCMxEFEGd UhZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:autocrypt:references:in-reply-to:date:cc :to:from:subject:message-id:dkim-signature; bh=6sdNoskqMew+HpExOfScjyA4mWrsG/qt11aXDDvMoFM=; fh=SgwpQdYpCkKJ/jDWX1DDVNuCyhMTcH7g6wXNA87UaJA=; b=XlJYckIu30jlcCsYaWj8c+o3C8FSCMpIvpyS5BJt/HuQrhks39EYwpKxjHcWtKwHs9 l4/lzLY06JcsvztD+CYE2paT3X8SIlDZnJorx3BsdTvaN/IneZXL+o6d2WYnCViVdttb MArXqY476nSwrobrFv/JC5BexbTLyE3c7pFrHR/zcD0P6MU/Ddyd260uA1eoMJbzaxDZ X1/2i+VZmtjfqzZjOLBau1z5jKUm9snObiBh/oRi0OXdbI1mTEowLEBxaS5AJ0AJ7WIl lIkonEt9RW+96V0E4lVbIe4YaBaUD/+KvqCysIostlOt45TvdTUi79n63j14irzzsBAC TU0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DuQnsUuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id ca20-20020a17090af31400b00280ca0a527fsi12678338pjb.114.2023.11.28.09.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 09:59:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=DuQnsUuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 85FBC80425AF; Tue, 28 Nov 2023 09:59:50 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346687AbjK1R7l (ORCPT + 99 others); Tue, 28 Nov 2023 12:59:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346913AbjK1R70 (ORCPT ); Tue, 28 Nov 2023 12:59:26 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B741D63; Tue, 28 Nov 2023 09:59:05 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-548f0b7ab11so7820849a12.1; Tue, 28 Nov 2023 09:59:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701194344; x=1701799144; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to; bh=6sdNoskqMew+HpExOfScjyA4mWrsG/qt11aXDDvMoFM=; b=DuQnsUuTl6bXIPL5yzW3wHLfna4B6Mlzl+i4oIazGZ64gDwARjuMBCOBX8YQUx29nb TpltC0Peqi0OyC85eBPCdGV5h9bS8zMCkXGotzIb4HZ5J7f8Q73xhMpeitYgiYW1iOJN s3wt0BsxFDddbvshu8pqTBIz5bxHSe6sGEi4dwckMjpclGtl/sQc1JdQPJdHKLWdx9Vk 5fnF+LRtHaDe/5Rk82fdipinDj7b89669dsOnXDdqHmYth790emi+KnsnkanH6C63sh0 UkCramFz3NW/dF3b4hhxKQRCCdoxDcWg7GCwz8JBwFolxoY/rYTkt9i9dRFJjXKOhQr5 laRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701194344; x=1701799144; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6sdNoskqMew+HpExOfScjyA4mWrsG/qt11aXDDvMoFM=; b=Vf0mCEsfPp6ryt/hP3eUPBM5oDOI7lC3sKleqiLoXPp/FFXTFgl/NJiLyis2ImNeMj /wGD4WEYE/FOV0PR4D5WUCepWPjSuEivIBR7lxgn20fVmPM2driFW78wbLaaidA3AjL0 gjTw/FnJzUZd6Q+wxl7RmtLNbCPUFBiCZ7AtHfOg+7Tn3v6UrXaqL0YHMsLZpV/BegrH F0srtayATX2B4KEeNijIG08d+346cRTNdJPxrArkjOa1tYSQ/JDpPQU7sX2lmS48QbqK 60wvTP1tVbyC5uxJezKZ1QkQRAwrvmTaZTvptCMZ5em0IM+MZQWmNFqMv+4m9W6ITuoP NrgQ== X-Gm-Message-State: AOJu0YyJVJ+NAuGXuZw5YLeZWqPqQ1ZzfZi7HzpzwX94b91t3lLvmt25 wRBR0ecDAwBHla2Z9CyroHI= X-Received: by 2002:a50:d55e:0:b0:53d:b839:2045 with SMTP id f30-20020a50d55e000000b0053db8392045mr12185509edj.25.1701194343503; Tue, 28 Nov 2023 09:59:03 -0800 (PST) Received: from [192.168.1.95] (host-176-36-0-241.b024.la.net.ua. [176.36.0.241]) by smtp.gmail.com with ESMTPSA id eh9-20020a0564020f8900b005486f7f654dsm6617724edb.7.2023.11.28.09.59.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 09:59:03 -0800 (PST) Message-ID: <20c593b6f31720a3d24d75e5e5cc3245b67249d1.camel@gmail.com> Subject: Re: [PATCH ipsec-next v2 3/6] libbpf: Add BPF_CORE_WRITE_BITFIELD() macro From: Eduard Zingerman To: Daniel Xu , ndesaulniers@google.com, andrii@kernel.org, nathan@kernel.org, daniel@iogearbox.net, ast@kernel.org, steffen.klassert@secunet.com, antony.antony@secunet.com, alexei.starovoitov@gmail.com, yonghong.song@linux.dev Cc: martin.lau@linux.dev, song@kernel.org, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, trix@redhat.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, devel@linux-ipsec.org, netdev@vger.kernel.org Date: Tue, 28 Nov 2023 19:59:01 +0200 In-Reply-To: References: Autocrypt: addr=eddyz87@gmail.com; prefer-encrypt=mutual; keydata=mQGNBGKNNQEBDACwcUNXZOGTzn4rr7Sd18SA5Wv0Wna/ONE0ZwZEx+sIjyGrPOIhR14/DsOr3ZJer9UJ/WAJwbxOBj6E5Y2iF7grehljNbLr/jMjzPJ+hJpfOEAb5xjCB8xIqDoric1WRcCaRB+tDSk7jcsIIiMish0diTK3qTdu4MB6i/sh4aeFs2nifkNi3LdBuk8Xnk+RJHRoKFJ+C+EoSmQPuDQIRaF9N2m4yO0eG36N8jLwvUXnZzGvHkphoQ9ztbRJp58oh6xT7uH62m98OHbsVgzYKvHyBu/IU2ku5kVG9pLrFp25xfD4YdlMMkJH6l+jk+cpY0cvMTS1b6/g+1fyPM+uzD8Wy+9LtZ4PHwLZX+t4ONb/48i5AKq/jSsb5HWdciLuKEwlMyFAihZamZpEj+9n91NLPX4n7XeThXHaEvaeVVl4hfW/1Qsao7l1YjU/NCHuLaDeH4U1P59bagjwo9d1n5/PESeuD4QJFNqW+zkmE4tmyTZ6bPV6T5xdDRHeiITGc00AEQEAAbQkRWR1YXJkIFppbmdlcm1hbiA8ZWRkeXo4N0BnbWFpbC5jb20+iQHUBBMBCgA+FiEEx+6LrjApQyqnXCYELgxleklgRAkFAmKNNQECGwMFCQPCZwAFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQLgxleklgRAlWZAv/cJ5v3zlEyP0/jMKQBqbVCCHTirPEw+nqxbkeSO6r2FUds0NnGA9a6NPOpBH+qW7a6+n6q3sIbvH7jlss4pzLI7LYlDC6z+egTv7KR5X1xFrY1uR5UGs1beAjnzYeV2hK4yqRUfygsT0Wk5e4FiNBv4+DUZ8r0cNDkO6swJxU55DO21mcteC147+4aDoHZ40R0tsAu+brDGSSoOPpb0RWVsEf9XOBJqWWA+T7mluw nYzhLWGcczc6J71q1Dje0l5vIPaSFOgwmWD4DA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1C3OJ8QY7cxfJ+pEZW18fRJ0XCl/fiV/ecAOfB3HsqgTzAn555h0rkFgay0hAvMU/mAW/CFNSIxV397zm749ZNLA0L2dMy1AKuOqH+/B+/ImBfJMDjmdyJQ8WU/OFRuGLdqOd2oZrA1iuPIa+yUYyZkaZfz/emQwpIL1+Q4p1R/OplA4yc301AqruXXUcVDbEB+joHW3hy5FwK5t5OwTKatrSJBkydSF9zdXy98fYzGniRyRA65P0Ix/8J3BYB4edY2/w0Ip/mdYsYQljBY0A== Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 28 Nov 2023 09:59:50 -0800 (PST) On Tue, 2023-11-28 at 10:54 -0700, Daniel Xu wrote: > Similar to reading from CO-RE bitfields, we need a CO-RE aware bitfield > writing wrapper to make the verifier happy. >=20 > Two alternatives to this approach are: >=20 > 1. Use the upcoming `preserve_static_offset` [0] attribute to disable > CO-RE on specific structs. > 2. Use broader byte-sized writes to write to bitfields. >=20 > (1) is a bit a bit hard to use. It requires specific and > not-very-obvious annotations to bpftool generated vmlinux.h. It's also > not generally available in released LLVM versions yet. >=20 > (2) makes the code quite hard to read and write. And especially if > BPF_CORE_READ_BITFIELD() is already being used, it makes more sense to > to have an inverse helper for writing. >=20 > [0]: https://reviews.llvm.org/D133361 > From: Eduard Zingerman >=20 > Signed-off-by: Daniel Xu > --- Could you please also add a selftest (or several) using __retval() annotation for this macro?