Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2579465rdb; Mon, 5 Feb 2024 10:43:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+nonFGxQqxylMZHNRogK01QoK1hzl0qpovTRLDUIWAoHDf9Xu777pJvd4Copyzv2bpmDH X-Received: by 2002:a05:620a:4722:b0:783:9dde:ed02 with SMTP id bs34-20020a05620a472200b007839ddeed02mr409083qkb.7.1707158605571; Mon, 05 Feb 2024 10:43:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707158605; cv=pass; d=google.com; s=arc-20160816; b=rQ5XiBDWJydkwYOhXmuzFeNKRAEhI4FPZ7/pN18nSVAnZExSPzi9EgP6nmcDStyOBb YPc+qA5vetSAtUXNV+1oPN2Uk1E/MReDVd9gDbfW8utk5IffLMEyu0Cnngk2XHChey/h kPc0TNOwftZcTK7eOgEcDLnDGWAPWuNhVxEjnItJlBKbQOoc9cB7edcLkQTpqjXgmxIs 2Fn7DQTZfG/36ZGM2nZMBavh+kW5EO9xjfpLcqGJiQZ7i+4WnSNrj9m2WLaqe7HQFVkS 0JKEPpUMwDOauNLZ72RBCYP4r4iqd13/8KcIhzoVmZPAl7N3W/2Mjw4Ew8lrXGSVuqxa htZA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=LNq6oubwXmqe6ItjQ33y0Ud8zzbj1+GnKVYTNf0QWt4=; fh=neQ3wEP7YDOCnJhNT1FuW8OozDLqq8LUv3mbodz2Nok=; b=x+aRdS4wU3Uzqy30eDy0LCXvFmxNoDMwODAp8C3Vw/EWfEuexgADn6j0hzUh0wJav4 EqZAl4USgtBOA2QU7Z265cVvtfP+JrwpiiFBcq8+ITYOUXOTw4O25T6C2tB9gB2HyaXN L2fF7/4JPBNPIFm7dqbY+G3tkydPxbfNpit39g2hOKAMREhQafy9yhh/hVq3oT3M4xIc Fh6ax2ZifTiHkyeSLNQAmemmFSnw1WqzLelUKiDxZ04S5tfXzFOLmbmsp5WZoJJFCzi6 3CG0XFI0D9Y/Rz5x7QZN6M/97I9G2PzAfBqKejNVhcszfVLvlAq/bCepvYzbxWb0TW8M 3WAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LDCODIf9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-53245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXU8BtsjRASnfp7KN3BJIoDlOAA4b7szGONuMktiJLsya3xUO3QAeb6VcdrbNfhrQGPwFmIhyTmpLxy7dwFSasT+0LEsw+nTnXfQc3hXg== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dz19-20020a05620a2b9300b0078553555217si544206qkb.125.2024.02.05.10.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:43:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LDCODIf9; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-53245-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53245-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 469AF1C22399 for ; Mon, 5 Feb 2024 18:43:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8AECC47F7B; Mon, 5 Feb 2024 18:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LDCODIf9" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 9B31E47F59 for ; Mon, 5 Feb 2024 18:43:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707158589; cv=none; b=KbFHz8CYToZCUVy9Mxs2Np5Mi1fW8cjpvstpHoh998mlmWXh+cT0BrqcJvpljPomxwLVNICHoLbYivabzAD7AuczB1R/KJRoHYiEfpVneBeqF63ebmPPfblSGStMAGeS6GGpjTXIwIxldP/kan3kkvOzt+4+XkBP/JN7iUPscf0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707158589; c=relaxed/simple; bh=lxH2UkoXhtlULl/zvh0je1dal/ztpt8QeP0kl4G+Vbs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EVUcBe9LeB9ivdMPA0Dghvd0j/GeD9F2xPJkFcW6QYPC6iNtPneB67v91frBDJXIQYWBqNObVrNuXdjejS1bNaZmXAn6TmTLa/lVpa4uZ1KNLkAW1wukPsZoGI//q9NQKka07BP1d8XkJ0RHlPAOc5ncSGN+aoQavUtkhGpp77k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LDCODIf9; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707158586; 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=LNq6oubwXmqe6ItjQ33y0Ud8zzbj1+GnKVYTNf0QWt4=; b=LDCODIf9ltZ3tRdTQPs5OvjJ9JL43He9NN9YqsGnbJtT6u/qL5S3ZMpQ0HD79pWk4AbMSW OJIZG+zxzO71W5CApXODc7rJ61/FGwjhpExp16DjTzBUH8aJmqcLEIWZoBgufcogbkxFii oo/awuUIvYCHYJXvOPUT3QjGUufmV4A= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-AsxOl8HnNnSeJ4Sj4waB9w-1; Mon, 05 Feb 2024 13:43:05 -0500 X-MC-Unique: AsxOl8HnNnSeJ4Sj4waB9w-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a31ffe314c5so231586366b.1 for ; Mon, 05 Feb 2024 10:43:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707158584; x=1707763384; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LNq6oubwXmqe6ItjQ33y0Ud8zzbj1+GnKVYTNf0QWt4=; b=SQ3ho4heDuo1vHgF/8ufFucj29AGZ342ptyZoDZE7uU7IjCkgF0fhI2jTNWZ4P7/5B xdTMrtMp1+c1IsKUZd8D7Jodh5gTHiAqWEe+ZQo3qoawI5RQOQVpXXHSkzXlrV7pXjil Auk9zmjfOJeEey8JG0V0VrJWMcDpzRO4wwKDswgO6uK3C6Ge+8sYe2wxg/o0UIcUBHYE xE7Mp2uE0EgpwLdfUNx/fP3d+3FmozNyBPitt6hZkjZyMycCij/WepkGJVawOO/3Id/o Sb99gPe697dZBsAxJAG+WRBBdLCWD4Yvugpo94MlaxUMWXhh9Z6hipUoUbvA0v/MLPD9 J2uw== X-Gm-Message-State: AOJu0YzZ/UJSgLe5vIYs7J0seBOZVmVqBm8kDlY7XqnQ45JmZfAnG95E XA3u9FT0H0nRBTIKCrGB1HFCWeZ5gS1Gr48oJVc/+7BCNWqjD9xshU+ak1eETIl0eXYjj2ZawD0 hm/1ZxPiEqQ+8wHqupDgLyAzdqzs5Bs+Id40yTd6Gk4AoZv76HNDbQpAQJRdU X-Received: by 2002:a17:906:c291:b0:a32:b376:489d with SMTP id r17-20020a170906c29100b00a32b376489dmr228565ejz.21.1707158584052; Mon, 05 Feb 2024 10:43:04 -0800 (PST) X-Received: by 2002:a17:906:c291:b0:a32:b376:489d with SMTP id r17-20020a170906c29100b00a32b376489dmr228552ejz.21.1707158583686; Mon, 05 Feb 2024 10:43:03 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCW/539QzZ3CsCBd/dh6u4+Lu0RJ/lNp9RpJ+QdlVC2XRNNKX6VqeLJj50ZJA+N90OsJClBVsg5JNJx2ats/acge24t52SP1Khtr1Zb4g78xgsfghwaFLj1f6AJtfVo6O317uL1HzzNqXxmpy7ECqBJEptEIkKBxTFpYeMwuFd+BML/Xrojv2jMMXM9fitkLsKBmdYff02rTHIy1/9RYeW9KdA+vBiMMFajtXpJ9V3LInGlCjYjlUDdXOvBtO5I7hA45drv3aKenosx8u4UyB41Mz1PLz7aLENeuLx+D1O2uqJitQ5WY2/MWQsxC4hRsJLrtQSEiVEO//auoefGKYicIZXYmMBpZyobmMO+U5/AI7JRZNB4SrfhxFR3pafp6m1NPrmYlSeKc08AuIyTHk9ANC0tpyeniQJ3jCv+QnMgmLtM/kn+0P+/bRaYeDZ6d8IRlYLtr+o3sXelQ5sLfNPgIJKCnYmIVFOljcVjx7+ZUhFi0fAaUSSYmOH5KO46artcSjNhj82irK/HCSLEyg8UvWscGqbKXPwX22XgIsaFBiaZQJE98IoKW/FK5HPxvcKxRAW/5/iKxgZhKCM8KtX0dQCkHll57HIUiJSjrmPsVcn0ucLRS3jgg9lsPvnuDItmph5A4CJHwTnHeAe/8NIIZ8VBicJlP78Sc2dSEOj28GuudM2rMQLEK9T4bEzynKCV2zDJ0K6FcH+gAF302k7BBiiWiEivB Received: from [192.168.0.159] (185-219-167-205-static.vivo.cz. [185.219.167.205]) by smtp.gmail.com with ESMTPSA id t26-20020a1709066bda00b00a353d1a19a9sm121768ejs.191.2024.02.05.10.43.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Feb 2024 10:43:03 -0800 (PST) Message-ID: Date: Mon, 5 Feb 2024 19:43:02 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH bpf-next v4 0/3] Annotate kfuncs in .BTF_ids section Content-Language: en-US To: Manu Bretelle , Jiri Olsa Cc: Daniel Xu , linux-trace-kernel@vger.kernel.org, coreteam@netfilter.org, bpf@vger.kernel.org, linux-input@vger.kernel.org, cgroups@vger.kernel.org, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-kselftest@vger.kernel.org, linux-doc@vger.kernel.org, fsverity@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netfilter-devel@vger.kernel.org, alexei.starovoitov@gmail.com, quentin@isovalent.com, alan.maguire@oracle.com, memxor@gmail.com References: From: Viktor Malik In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/3/24 19:45, Manu Bretelle wrote: > On Sat, Feb 03, 2024 at 03:40:24PM +0100, Jiri Olsa wrote: >> On Fri, Feb 02, 2024 at 03:09:05PM -0800, Manu Bretelle wrote: >>> On Sun, Jan 28, 2024 at 06:24:05PM -0700, Daniel Xu wrote: >>>> === Description === >>>> >>>> This is a bpf-treewide change that annotates all kfuncs as such inside >>>> .BTF_ids. This annotation eventually allows us to automatically generate >>>> kfunc prototypes from bpftool. >>>> >>>> We store this metadata inside a yet-unused flags field inside struct >>>> btf_id_set8 (thanks Kumar!). pahole will be taught where to look. >>>> >>>> More details about the full chain of events are available in commit 3's >>>> description. >>>> >>>> The accompanying pahole and bpftool changes can be viewed >>>> here on these "frozen" branches [0][1]. >>>> >>>> [0]: https://github.com/danobi/pahole/tree/kfunc_btf-v3-mailed >>>> [1]: https://github.com/danobi/linux/tree/kfunc_bpftool-mailed >>> >>> >>> I hit a similar issue to [0] on master >>> 943b043aeecc ("selftests/bpf: Fix bench runner SIGSEGV") >>> when cross-compiling on x86_64 (LE) to s390x (BE). >>> I do have CONFIG_DEBUG_INFO_BTF enable and the issue would not trigger if >>> I disabled CONFIG_DEBUG_INFO_BTF (and with the fix mentioned in [0]). >>> >>> What seems to happen is that `tools/resolve_btfids` is ran in the context of the >>> host endianess and if I printk before the WARN_ON: >>> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c >>> index ef380e546952..a9ed7a1a4936 100644 >>> --- a/kernel/bpf/btf.c >>> +++ b/kernel/bpf/btf.c >>> @@ -8128,6 +8128,7 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type, >>> * WARN() for initcall registrations that do not check errors. >>> */ >>> if (!(kset->set->flags & BTF_SET8_KFUNCS)) { >>> + printk("Flag 0x%08X, expected 0x%08X\n", kset->set->flags, BTF_SET8_KFUNCS); >>> WARN_ON(!kset->owner); >>> return -EINVAL; >>> } >>> >>> the boot logs would show: >>> Flag 0x01000000, expected 0x00000001 >>> >>> The issue did not happen prior to >>> 6f3189f38a3e ("bpf: treewide: Annotate BPF kfuncs in BTF") >>> has only 0 was written before. >>> >>> It seems [1] will be addressing cross-compilation, but it did not fix it as is >>> by just applying on top of master, so probably some of the changes will also need >>> to be ported to `tools/include/linux/btf_ids.h`? >> >> the fix in [1] is fixing flags in set8's pairs, but not the global flags >> >> it looks like Viktor's fix should now also swap that as well? like in the >> change below on top of Viktor's changes (untested) >> >> jirka >> >> >> --- >> diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c >> index d01603ef6283..c44d57fec390 100644 >> --- a/tools/bpf/resolve_btfids/main.c >> +++ b/tools/bpf/resolve_btfids/main.c >> @@ -706,6 +706,8 @@ static int sets_patch(struct object *obj) >> * correctly translate everything. >> */ >> if (need_bswap) { >> + set8->flags = bswap_32(set8->flags); >> + >> for (i = 0; i < cnt; i++) { >> set8->pairs[i].flags = >> bswap_32(set8->pairs[i].flags); >> > > That should work. Here are a few tests I ran: > > $ md5sum /tmp/kbuild-s390x/vmlinux.* > eb658e51e089f3c5b2c8909a29dc9997 /tmp/kbuild-s390x/vmlinux.a > # plain vmlinux before running resolv_btfids (all 0s) > ea907cd46a1a73b8276b5f2a82af00ca /tmp/kbuild-s390x/vmlinux.before_resolv > # x86_64 resolv_btfids on master without Viktor's patch > 980a40c3a3ff563d1c2d1ebdd5071a23 /tmp/kbuild-s390x/vmlinux.resolv_native > # x86_64 resolv_btfids on master with Viktor's patch > b986d19e242719ebea41c578235da662 /tmp/kbuild-s390x/vmlinux.resolv_native_patch_viktor > # x86_64 resolv_btfids on master with Viktor's patch and your suggested patch > 4edd8752ff01129945bd442689b1927b /tmp/kbuild-s390x/vmlinux.resolv_native_patch_viktor_patched > # s390x resolv_btfids run with qemu-s390x-static > 4edd8752ff01129945bd442689b1927b /tmp/kbuild-s390x/vmlinux.resolv_s390x > > > and some hexdiff of those binaries: > > > # difference between master's native build and s390x build.... has byte swapping for set8 and others > diff -ruN <(xxd /tmp/kbuild-s390x/vmlinux.resolv_s390x) <(xxd /tmp/kbuild-s390x/vmlinux.resolv_native) > diff_s390x_native.diff > https://gist.github.com/chantra/c3d58637a08a6f7340953dc155bb18cc > > # difference betwee Viktor's version and s390x build.... squinting my eyes I only see the global set8 is missing > diff -ruN <(xxd /tmp/kbuild-s390x/vmlinux.resolv_s390x) <(xxd /tmp/kbuild-s390x/vmlinux.resolv_native_patch_viktor) > diff_s390x_native_viktor.diff > https://gist.github.com/chantra/61cfff02b456ae72d3c0161ce1897097 Thanks for the testing Manu! Jiri's suggested fix is now a part of [1]. Viktor [1] https://lore.kernel.org/bpf/cover.1707157553.git.vmalik@redhat.com/ > > Have a good weekend all! > > Manu >