Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2601127rdh; Sun, 26 Nov 2023 12:14:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfRohrgRZwz+HG6YQ0KPy+Muklfyw+N8XaGhavzOZoQF9XbUUfG53bBL/y4ksEVDVDcLgv X-Received: by 2002:a05:6a00:f8a:b0:690:d620:7801 with SMTP id ct10-20020a056a000f8a00b00690d6207801mr8857834pfb.11.1701029688763; Sun, 26 Nov 2023 12:14:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701029688; cv=none; d=google.com; s=arc-20160816; b=pQv+QFHnRx0+Zc1otAenpXQpXJXtcMIasaoK4YAP65RE8fOkaHpqnmKedXru/5/TQc Do9IDg6FEhsv2BcJCcR8nYUtYGkN+Fxv6ZvhchgfPAFoGkshfsEl8jlXdkILs25X1NaP jUvLk/TJjAfbipuuWynlidzsInYSgCUl93TksAT/PnPT5HO7C1uRvad3Sbf5qx7rusKX zna/xbRP3V7WO+MmyLgbfWBBvfBjN6VUJLbtBNQ9To0uZmA50frx2PzcLaU2M0i9tQFk YCJ156gyftAa3E9DVTVn8ImC6nLw9MdSv/I6LdVKnZsxNpIhN0CDnZL+L26Orfq6psXr 7i1w== 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=Yp72lr6ldBtEgxHJc2cyITFerBaMZB0y6t1H7uYo/wE=; fh=sPGSIrIIavaHIRQdrIMulfmUwiLRCkvgm3yVhTG4hOM=; b=mFm9/j8Of0/MYDJdkCMbzTD81xG+bqlkBxFK/UlaiBIG2wTEZSRBMCEd5Jq0McoYcG dHxl5+pB+wtnFCo6pjBCHIF9NNdGukQv4qG9eiA8kDyUuwYtqj7Uh6W98Dd3SejAqWWT DMl8iaH4k1eZ2uU6eu1htDkqYMi0m25udC+p27WIOeTmZMplUxroBIUpPu0CzSigaV/v fvL94pC+bHhj3psir88gk5iPr0aCtJgAdWsAYr9dxHt/BFezFNHzsV7WmmZE7QiqvIZR XF5iVKCzJNUVTF+nGptnwBwwi0lV7Lr445/CFx8hOrKwdlCeKjUxJlHOeQNCwNHFmsTx AZJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N6fZkzUN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id bx18-20020a056a02051200b00578da80ac3dsi9301611pgb.80.2023.11.26.12.14.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 12:14:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=N6fZkzUN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id 1FD47804B869; Sun, 26 Nov 2023 12:14:46 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229489AbjKZUOW (ORCPT + 99 others); Sun, 26 Nov 2023 15:14:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbjKZUOV (ORCPT ); Sun, 26 Nov 2023 15:14:21 -0500 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9EB3E4; Sun, 26 Nov 2023 12:14:25 -0800 (PST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-40b4746ae51so117485e9.2; Sun, 26 Nov 2023 12:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701029664; x=1701634464; 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=Yp72lr6ldBtEgxHJc2cyITFerBaMZB0y6t1H7uYo/wE=; b=N6fZkzUNCHBgaL2WqAH/H8+bY2Z3t7DuPx7ayZ0Ju5p0K/2CpRhTsl4UPcB2qR7ULN iWTsJpyFluJRDuf7I4GwYEfcPzATDuYY/qt1p7FORbNayY17deOAAij2GSPetxjk5Uay uZhfdwUtHzV3WDHR+t3OLPqKqSmTNV2DBtKSGWFRQnZbZZQN4n1UD+BM2QfWacHLLbZ9 l02azx2una8LJdA5jVtqMjCPQy+WkDYZZ6ePA9M1ikF0MLyjfKJK5zCcpu+CBxGyanCo ETWw9xIjeqbzDV677vRXYfBlJRysXJgPSAW8i2uSO2NK/bWQIaf8eqfxhNAgKa2JCKjX SDLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701029664; x=1701634464; 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=Yp72lr6ldBtEgxHJc2cyITFerBaMZB0y6t1H7uYo/wE=; b=UV/kgFJ+6eDWLiQpNm5LQ2ruzmKwK9qy+jJTN/LlFXW4bcLNk28sVGRn4mxJUY50an EvR4ehGI6nVfcgARskgs3mNSgn+U4Z/GVuEBQRFtO9m/BIGuI5kO7Pz5P5oPQ1s1Wgjf K/qaMRkDGVkjoFJBAmauMbP0q/XKpHlUaixqu6po9vAI4O+vPA1iLRJVe4pF34uKNhhY EZS8B8hWgWSBSXstzmfUkiLbwF2B5pMTpTN1c3KbcbugnIrsnc4j6tfgOahHJ/uEQXp2 J2dt6C4K+zSTlMwn6tWob94Xy48nKnAH+eV+Fd/yx56zdgQm7TBRm8Lzswel3Q/Lbf0z l4mA== X-Gm-Message-State: AOJu0YzGhMVEoBGfN4DWv2pcn7nwp5uEL43noN7obREPhlL8asPji5vs SON1Faeh4m89YN55qFA6+jA= X-Received: by 2002:a05:600c:21c7:b0:40a:4c7e:6f37 with SMTP id x7-20020a05600c21c700b0040a4c7e6f37mr6639703wmj.20.1701029663842; Sun, 26 Nov 2023 12:14:23 -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 jg28-20020a05600ca01c00b004063cd8105csm12025666wmb.22.2023.11.26.12.14.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 12:14:22 -0800 (PST) Message-ID: <18e43cdf65e7ba0d8f6912364fbc5b08a6928b35.camel@gmail.com> Subject: Re: [PATCH ipsec-next v1 6/7] bpf: selftests: test_tunnel: Disable CO-RE relocations From: Eduard Zingerman To: Yonghong Song , Alexei Starovoitov Cc: Daniel Xu , Shuah Khan , Daniel Borkmann , Andrii Nakryiko , Alexei Starovoitov , Steffen Klassert , antony.antony@secunet.com, Mykola Lysenko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf , "open list:KERNEL SELFTEST FRAMEWORK" , LKML , devel@linux-ipsec.org, Network Development Date: Sun, 26 Nov 2023 22:14:21 +0200 In-Reply-To: <3ec6c068-7f95-419a-a0ae-a901f95e4838@linux.dev> References: <391d524c496acc97a8801d8bea80976f58485810.1700676682.git.dxu@dxuuu.xyz> <0f210cef-c6e9-41c1-9ba8-225f046435e5@linux.dev> <3ec6c068-7f95-419a-a0ae-a901f95e4838@linux.dev> 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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QDQs8aUqrd46PV jsdqGvKnXZxzylux29UTNby4jTlz9pNJM+wPrDRmGfchLDUmf6CffaUYCbu4FiId+9+dcTCDvxbABRy1C3OJ8QY7cxfJ+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=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Sun, 26 Nov 2023 12:14:46 -0800 (PST) On Sat, 2023-11-25 at 20:22 -0800, Yonghong Song wrote: [...] > --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c > @@ -6,7 +6,10 @@ > * modify it under the terms of version 2 of the GNU General Public > * License as published by the Free Software Foundation. > */ > -#define BPF_NO_PRESERVE_ACCESS_INDEX > +#if __has_attribute(preserve_static_offset) > +struct __attribute__((preserve_static_offset)) erspan_md2; > +struct __attribute__((preserve_static_offset)) erspan_metadata; > +#endif > #include "vmlinux.h" [...] > int bpf_skb_get_fou_encap(struct __sk_buff *skb_ctx, > @@ -174,9 +177,13 @@ int erspan_set_tunnel(struct __sk_buff *skb) > __u8 hwid =3D 7; > =20 > md.version =3D 2; > +#if __has_attribute(preserve_static_offset) > md.u.md2.dir =3D direction; > md.u.md2.hwid =3D hwid & 0xf; > md.u.md2.hwid_upper =3D (hwid >> 4) & 0x3; > +#else > + /* Change bit-field store to byte(s)-level stores. */ > +#endif > #endif > =20 > ret =3D bpf_skb_set_tunnel_opt(skb, &md, sizeof(md)); >=20 > =3D=3D=3D=3D >=20 > Eduard, could you double check whether this is a valid use case > to solve this kind of issue with preserve_static_offset attribute? Tbh I'm not sure. This test passes with preserve_static_offset because it suppresses preserve_access_index. In general clang translates bitfield access to a set of IR statements like: C: struct foo { unsigned _; unsigned a:1; ... }; ... foo->a ... IR: %a =3D getelementptr inbounds %struct.foo, ptr %0, i32 0, i32 1 %bf.load =3D load i8, ptr %a, align 4 %bf.clear =3D and i8 %bf.load, 1 %bf.cast =3D zext i8 %bf.clear to i32 With preserve_static_offset the getelementptr+load are replaced by a single statement which is preserved as-is till code generation, thus load with align 4 is preserved. On the other hand, I'm not sure that clang guarantees that load or stores used for bitfield access would be always aligned according to verifier expectations. I think we should check if there are some clang knobs that prevent generation of unaligned memory access. I'll take a look.