Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp2227857rdh; Sat, 25 Nov 2023 20:31:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IEs2hhMUDv1cIPNLG6z3PUxgZhwbWAA3Kc9b4v4pyfQ02opwDNJrOj9M7vpJpwRl27sxmGD X-Received: by 2002:a05:6a21:788b:b0:18c:19e2:5735 with SMTP id bf11-20020a056a21788b00b0018c19e25735mr6542145pzc.54.1700973089153; Sat, 25 Nov 2023 20:31:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700973089; cv=none; d=google.com; s=arc-20160816; b=ppcQjwwgSE+fjC0XIn61LwC1mxaGJRBbxLFW5Yn2Ta3NPqH5yhYivfT6jffYP28AH2 ZviUC/I7b8HVH0Vg4yNMsakExBZZX8j2MqrSf3HYZqKBhcD5IEFpmI8Z27sYBGJewyR4 j5COk0vwpVxFWI4zZlkFtInnrO39PGCKI+LnyPZ1cQiKhjbl6MqSMV0mDLAQXx1BKU5q /CA6gbuuEd/LHC6vwhivD7xdKfik9QwNwT8vJmOmnc18K4tl2181Vb78Gem9Oh8ImAci ia4KYrIVPiGaNVWD4RrhocoT+Kgxx4KljOGjcW4p4gkG9y7g7decrEycBloS8VZoeklY sZlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:mime-version:date :dkim-signature:message-id; bh=YPqbGwvoWuhH3MNinMuIoCbVuSs6v7gO8I55MtBSoJU=; fh=gW08GqZ9Rq8u7UUJYaWhVdcD9bVoNnN1GY82YbOkoM8=; b=L4EPi807hX2gLbJy3Ek/udlyRd8xscg69o3JzcMhEDgQFFM3Lfrskez10Yere6ZLsg IljkYZr035yBG49o7wXq8zJQwNUUWmzHn9FwiNTnK66pq8pByfbC3PjPmEH//Xr4hpEO ju+clLSXIhtb3OpA8HLX/F0v3YxUnafm4Y+NzM+uQWbZi0Pl23e1meJui4Zp837jbIBP KP19dIjxqC4A6MfXbLwwSyVXPfevWgPFDWM96a9/FBY/HQNznwsYUw0CtA0Xt7rj0Mx3 HVX/3iDj39z7zoP9Zf6if7rpI/3w94nF6NRyY/RIQtwchcGBntxg9OzOBuqLC+q0HMCZ QYaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iFZ1kHr0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id du19-20020a056a002b5300b006cbf0153cadsi5823120pfb.381.2023.11.25.20.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Nov 2023 20:31:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=iFZ1kHr0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 5321C807C7F5; Sat, 25 Nov 2023 20:30:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229830AbjKZEW0 (ORCPT + 99 others); Sat, 25 Nov 2023 23:22:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjKZEWY (ORCPT ); Sat, 25 Nov 2023 23:22:24 -0500 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E51EB11D for ; Sat, 25 Nov 2023 20:22:27 -0800 (PST) Message-ID: <3ec6c068-7f95-419a-a0ae-a901f95e4838@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1700972545; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YPqbGwvoWuhH3MNinMuIoCbVuSs6v7gO8I55MtBSoJU=; b=iFZ1kHr0JZmtTSmpiAQW0kJwEZwA2ZDUGadFJNdN4Xb6zgg5w0HO3U4tT+Wh1oK/6dJq9a jZGPr5LjmCSgn6KBRW+H6QBHPiXz3RDDaf02BawHtOiX78jLogyZ7gDFWhyXgHgYowGOdE nEsGPUjAhKOBmOaFutn/Y8xbp9F5Lqo= Date: Sat, 25 Nov 2023 20:22:14 -0800 MIME-Version: 1.0 Subject: Re: [PATCH ipsec-next v1 6/7] bpf: selftests: test_tunnel: Disable CO-RE relocations Content-Language: en-GB To: Alexei Starovoitov Cc: Daniel Xu , Shuah Khan , Daniel Borkmann , Andrii Nakryiko , Alexei Starovoitov , Steffen Klassert , antony.antony@secunet.com, Eddy Z , 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 References: <391d524c496acc97a8801d8bea80976f58485810.1700676682.git.dxu@dxuuu.xyz> <0f210cef-c6e9-41c1-9ba8-225f046435e5@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Yonghong Song In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 groat.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 (groat.vger.email [0.0.0.0]); Sat, 25 Nov 2023 20:30:28 -0800 (PST) On 11/25/23 7:54 PM, Alexei Starovoitov wrote: > On Sat, Nov 25, 2023 at 4:52 PM Yonghong Song wrote: >>> diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c >>> index 3065a716544d..ec7e04e012ae 100644 >>> --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c >>> +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c >>> @@ -6,6 +6,7 @@ >>> * 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 >> This is a temporary workaround and hopefully we can lift it in the >> near future. Please add a comment here with prefix 'Workaround' to >> explain why this is needed and later on we can earliy search the >> keyword and remember to tackle this. > I suspect we will forget to remove this "workaround" and people > will start copy pasting it. > Let's change the test instead to avoid bitfield access. Agree. Avoiding bitfield access is definitely a solution. I just checked llvm preserve_static_offset (not merged yet), it seems to be able to fix the issue as well. Applying patch https://reviews.llvm.org/D133361 to latest llvm-project, and with the following patch on top of patch 6, ===== diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c index ec7e04e012ae..11cbb12b4029 100644 --- 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" #include #include @@ -25,12 +28,12 @@ * 172.16.1.200 */ #define ASSIGNED_ADDR_VETH1 0xac1001c8 struct vxlanhdr { __be32 vx_flags; __be32 vx_vni; } __attribute__((packed)); int bpf_skb_set_fou_encap(struct __sk_buff *skb_ctx, struct bpf_fou_encap *encap, int type) __ksym; 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 = 7; md.version = 2; +#if __has_attribute(preserve_static_offset) md.u.md2.dir = direction; md.u.md2.hwid = hwid & 0xf; md.u.md2.hwid_upper = (hwid >> 4) & 0x3; +#else + /* Change bit-field store to byte(s)-level stores. */ +#endif #endif ret = bpf_skb_set_tunnel_opt(skb, &md, sizeof(md)); ==== Eduard, could you double check whether this is a valid use case to solve this kind of issue with preserve_static_offset attribute?