From patchwork Tue Oct 12 02:32:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12551325 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D185C433EF for ; Tue, 12 Oct 2021 02:51:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5DC2960EE5 for ; Tue, 12 Oct 2021 02:51:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231682AbhJLCxj (ORCPT ); Mon, 11 Oct 2021 22:53:39 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:44480 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231672AbhJLCxh (ORCPT ); Mon, 11 Oct 2021 22:53:37 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19C2g7ur014649; Mon, 11 Oct 2021 22:51:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=xYqeXchHEW1P/AnDNf/4ITuRTVdjA655bkxy8OJILVE=; b=d7PY52UN8WwpWf2dlDlC9aBB4Or/Mg+plEFVaAQOz7Qu3vq6PtSwJgmzbLxZku+2f4z5 3nl/4OEPGzaZUjooQu6B1ZXjMoDNWKvEZgAcna8xU8RJwSHdgrK6Wtge/wWdmn4S7Nuu CELc+akIwk0Bw6ZE7J67nretug9qzhNlTnb4TI/Sy4O9vw+6v/ZJB0EXTKvMUT1I5I7F ie/FrpsW0CeC0I1nJFcqjniYswMIKT6MxdDq2ztnaJeZRBa4Q+9yikA7tTPyI24NcKTp EH4AyHt4x/q7fxu8SoFHpy4V5u3K/p3XBxRWDkiPdkfRsKTYTM8CnIv7v1fs5ynXiQ2c Tg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bn1t9g3vg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 22:51:24 -0400 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19C2pNAo017132; Mon, 11 Oct 2021 22:51:23 -0400 Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bn1t9g3tu-7 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 22:51:23 -0400 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19C2BLhT009794; Tue, 12 Oct 2021 02:32:24 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma03ams.nl.ibm.com with ESMTP id 3bk2q9be7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Oct 2021 02:32:24 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19C2WKfS18678204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Oct 2021 02:32:20 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA44811C054; Tue, 12 Oct 2021 02:32:20 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A5F111C050; Tue, 12 Oct 2021 02:32:20 +0000 (GMT) Received: from vm.lan (unknown [9.145.45.184]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 12 Oct 2021 02:32:20 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich Subject: [PATCH bpf-next 1/3] selftests/bpf: Use cpu_number only on arches that have it Date: Tue, 12 Oct 2021 04:32:16 +0200 Message-Id: <20211012023218.399568-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012023218.399568-1-iii@linux.ibm.com> References: <20211012023218.399568-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: vTuccsjHYX8zwnplm3xVYGEn_97kD7Sa X-Proofpoint-GUID: DKaW5zZTMfq-d_Vx87WsO89eUcSxdrtx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-11_11,2021-10-11_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 impostorscore=0 mlxscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110120008 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net cpu_number exists only on Intel and aarch64, so skip the test involing it on other arches. An alternative would be to replace it with an exported non-ifdefed primitive-typed percpu variable from the common code, but there appears to be none. Signed-off-by: Ilya Leoshkevich --- tools/testing/selftests/bpf/prog_tests/btf_dump.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/btf_dump.c b/tools/testing/selftests/bpf/prog_tests/btf_dump.c index 87f9df653e4e..12f457b6786d 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf_dump.c +++ b/tools/testing/selftests/bpf/prog_tests/btf_dump.c @@ -778,8 +778,10 @@ static void test_btf_dump_struct_data(struct btf *btf, struct btf_dump *d, static void test_btf_dump_var_data(struct btf *btf, struct btf_dump *d, char *str) { +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_number", int, BTF_F_COMPACT, "int cpu_number = (int)100", 100); +#endif TEST_BTF_DUMP_VAR(btf, d, NULL, str, "cpu_profile_flip", int, BTF_F_COMPACT, "static int cpu_profile_flip = (int)2", 2); } From patchwork Tue Oct 12 02:32:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12551315 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DA3AC433EF for ; Tue, 12 Oct 2021 02:32:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E32A060EE5 for ; Tue, 12 Oct 2021 02:32:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231199AbhJLCel (ORCPT ); Mon, 11 Oct 2021 22:34:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:16074 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230505AbhJLCek (ORCPT ); Mon, 11 Oct 2021 22:34:40 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19C0VQ8G024569; Mon, 11 Oct 2021 22:32:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=TDkItwA/7DTCNuq3Zua+Gnm4cCHUDv4Iq5gdeASIEeI=; b=ljKvr7iTBk3UoAZhWRPRw13lpHVqbc+gh3qFTKz16XpUVdZxvRAvEbfYUIpHAgJMRnbc Sy7v6aNu+DwPaOXvP8GdSj1+s//B+l7jJAHdXl/D2teBLIavfI1kwN/VN8hA+riSmwtS Z01iZ8MSZ96BON4pJa8mLFQoNHpZmNDZrHdd1Xd1K7n4xrHCJg68aktZly/rXGIwQkR5 8xe8mynuO+LWwOx2pkzAIGyQ0yhUIqX/f2jdplrhS9iVjK2/8YfNrAkG4T/rU90hEMtC lBeXm1vPghzqu6c4R81vVi63hCYs3ilqFl2zZcfvo6M2qr9zRrwyRtGzPI3OEEso4JI2 4w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bmyw5hmyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 22:32:28 -0400 Received: from m0098396.ppops.net (m0098396.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19C2Vh7s023318; Mon, 11 Oct 2021 22:32:27 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bmyw5hmyb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 22:32:27 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19C2BPqc020151; Tue, 12 Oct 2021 02:32:25 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma04fra.de.ibm.com with ESMTP id 3bk2qa21dp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Oct 2021 02:32:25 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19C2WLpX2294378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Oct 2021 02:32:21 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8BE2E11C05E; Tue, 12 Oct 2021 02:32:21 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2AC7B11C04C; Tue, 12 Oct 2021 02:32:21 +0000 (GMT) Received: from vm.lan (unknown [9.145.45.184]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 12 Oct 2021 02:32:21 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich Subject: [PATCH bpf-next 2/3] libbpf: Fix dumping big-endian bitfields Date: Tue, 12 Oct 2021 04:32:17 +0200 Message-Id: <20211012023218.399568-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012023218.399568-1-iii@linux.ibm.com> References: <20211012023218.399568-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: K7zYQE4B_cQpvJ2wH0NB9CAC9xcykF3Q X-Proofpoint-ORIG-GUID: Pz-C3VrKqwiGeJmRKN2TeE3nyLHZbtiv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-11_11,2021-10-11_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 phishscore=0 clxscore=1015 malwarescore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110120008 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net On big-endian arches not only bytes, but also bits are numbered in reverse order (see e.g. S/390 ELF ABI Supplement, but this is also true for other big-endian arches as well). Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/btf_dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index ad6df97295ae..ab45771d0cb4 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -1577,14 +1577,15 @@ static int btf_dump_get_bitfield_value(struct btf_dump *d, /* Bitfield value retrieval is done in two steps; first relevant bytes are * stored in num, then we left/right shift num to eliminate irrelevant bits. */ - nr_copy_bits = bit_sz + bits_offset; nr_copy_bytes = t->size; #if __BYTE_ORDER == __LITTLE_ENDIAN for (i = nr_copy_bytes - 1; i >= 0; i--) num = num * 256 + bytes[i]; + nr_copy_bits = bit_sz + bits_offset; #elif __BYTE_ORDER == __BIG_ENDIAN for (i = 0; i < nr_copy_bytes; i++) num = num * 256 + bytes[i]; + nr_copy_bits = nr_copy_bytes * 8 - bits_offset; #else # error "Unrecognized __BYTE_ORDER__" #endif From patchwork Tue Oct 12 02:32:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 12551317 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BE7CC433FE for ; Tue, 12 Oct 2021 02:32:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C5DD60F21 for ; Tue, 12 Oct 2021 02:32:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230505AbhJLCel (ORCPT ); Mon, 11 Oct 2021 22:34:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47246 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230362AbhJLCek (ORCPT ); Mon, 11 Oct 2021 22:34:40 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19C2Bn2F003854; Mon, 11 Oct 2021 22:32:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=nsY0Xq+rxFEiF00RuE84NF6M/ZTAF7lGUFj030HOzXM=; b=l/5r2EeW4TsfFDA6RJ8CYFBXI6iD2iA4u8wKaUo6DMysoWnsZGLStroCTQ2yX6I41Ymv aVlb+l1wvqPXe5r1f3y8XDr0xKCCAB9NR/J4XP2YS8bXJj7n1RlsWiVFE1cQ/J/CcpXU x3GSxdW+VzbaMjpa3Qjx/z30IbAWANQiUQ81R/H+2rZZw5jsswHglIAUiEYCnSgKkysa PxgHFx1vDu0b0LhaL6MyHtvYIJyZyDUJXyyDBII2Rqafi5J5XWmJkqoGb6ytacVjR0Ib rhccvBxBmxRbJfAlsNKXd8dt/pDxTahJTMA+MqMqSL0JBvsMnuQLWxCcyQdmcz/JlEX2 QA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bn1c188ec-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 22:32:27 -0400 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19C2Uda2011783; Mon, 11 Oct 2021 22:32:27 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bn1c188e1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Oct 2021 22:32:27 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 19C2BPKZ030567; Tue, 12 Oct 2021 02:32:25 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma04ams.nl.ibm.com with ESMTP id 3bk2q9ue4t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Oct 2021 02:32:25 +0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19C2WMUu48234920 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Oct 2021 02:32:22 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4193F11C069; Tue, 12 Oct 2021 02:32:22 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DFE9411C050; Tue, 12 Oct 2021 02:32:21 +0000 (GMT) Received: from vm.lan (unknown [9.145.45.184]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 12 Oct 2021 02:32:21 +0000 (GMT) From: Ilya Leoshkevich To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Ilya Leoshkevich Subject: [PATCH bpf-next 3/3] libbpf: Fix dumping __int128 Date: Tue, 12 Oct 2021 04:32:18 +0200 Message-Id: <20211012023218.399568-4-iii@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211012023218.399568-1-iii@linux.ibm.com> References: <20211012023218.399568-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gN-ibB6v_x4r22lxkTJBaZ4yTR3vA8pf X-Proofpoint-GUID: vY_DfBdUcBFXgdeCaCShrl1K8Vk8g868 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-11_11,2021-10-11_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 mlxlogscore=999 lowpriorityscore=0 priorityscore=1501 suspectscore=0 phishscore=0 impostorscore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110120008 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net On s390 __int128 can be 8-byte aligned, therefore in libbpf will occasionally consider variables of this type non-aligned and try to dump them as a bitfield, which is supported for at most 64-bit integers. Fix by using the same trick as btf_dump_float_data(): copy non-aligned values to the local buffer. Signed-off-by: Ilya Leoshkevich --- tools/lib/bpf/btf_dump.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index ab45771d0cb4..d8264c1762e8 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -1672,9 +1672,10 @@ static int btf_dump_int_data(struct btf_dump *d, { __u8 encoding = btf_int_encoding(t); bool sign = encoding & BTF_INT_SIGNED; + char buf[16] __aligned(16); int sz = t->size; - if (sz == 0) { + if (sz == 0 || sz > sizeof(buf)) { pr_warn("unexpected size %d for id [%u]\n", sz, type_id); return -EINVAL; } @@ -1682,8 +1683,10 @@ static int btf_dump_int_data(struct btf_dump *d, /* handle packed int data - accesses of integers not aligned on * int boundaries can cause problems on some platforms. */ - if (!ptr_is_aligned(data, sz)) - return btf_dump_bitfield_data(d, t, data, 0, 0); + if (!ptr_is_aligned(data, sz)) { + memcpy(buf, data, sz); + data = buf; + } switch (sz) { case 16: {