From patchwork Tue Sep 1 15:09:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 248917 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp4356356ilg; Tue, 1 Sep 2020 08:41:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3G5CVS6ZCJb3idnkLr5uPFBvx1GyW9Aes9kOm5qVN/lFAV349u9QhQgghgGt2kc4fTNyd X-Received: by 2002:a17:906:5856:: with SMTP id h22mr1943129ejs.480.1598974888624; Tue, 01 Sep 2020 08:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598974888; cv=none; d=google.com; s=arc-20160816; b=XaEoqFvMdtUvC9JMOtAmBIuUXiqfJ84Tp7/gOnaPO58VwE54f3XOUr9Xs/NMi62nbz ojPfAsSpJjawAu/CCwKQcHYYrqOur6XI4+/dKsDoA/JeCNytn23N3gxkOMThXn2ZEirn dO/iW1Su1303GZOhsB4Y/+ilBd2lMBXO8vxL42K2mhDHmoiyNxzM/U2f9y9Q7cyMitaX kx1Gp87If1iGLlnA9HA3QAnU+glANicGNuedEK+Oa6tCVxsDVEOoPI20y8KcAplRXmOS q1CiPfa88CpAiMefhcTM4WADSiT5n9/FK1Y0MM5SB/o3t+++TgxcMP2LldseOOysx3iB ja3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HhxrtUSln7W6VoqrsTz6loMdkh9rpPIZqqg07ilYZ60=; b=AkLgyPOcxG1J200G3k0qcptpxZYFS5Ic63Vtgvk/qP924l7/uHapB9PX0CImb90CET qv+i95IPGIfichConKLOKZj54i/byB7EXIbokA+kbtbJp+FX+pkJjGKHLBGDAEnl4jo1 c8hwf9zWryCm3pnARQxmWzClTm9o305oTpnGL9aAPsxXpmj2FSwVqvMWcE82MNAAKZsS rKtwIEy0FsfZzMM9bi4efWRyZyUUdfrH0jdsqEFcRH6EUyJmZnvW7ubNbvR6SOAcDO/r FhkFJTsGL1zW4vqlnDBNjjl4R+IWQH+/BOT4ShpYXgEXHOLQOPz6Gf1syYVuLfWn+upb zVDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2o3puX4L; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si730199edv.310.2020.09.01.08.41.28; Tue, 01 Sep 2020 08:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2o3puX4L; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730067AbgIAPlY (ORCPT + 15 others); Tue, 1 Sep 2020 11:41:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:53478 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731522AbgIAPlX (ORCPT ); Tue, 1 Sep 2020 11:41:23 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A201207D3; Tue, 1 Sep 2020 15:41:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598974882; bh=oTARuwR/1mchUtNNkLCWoveYMMVPoNEEk5qgz+NHa2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2o3puX4LdfREOdIkju8FJpXmKEDIdLm46Uro/b2J06doTcgT6GqeiQtN5kCGugjek w/2g1wA1nZnP7XBRkk6Sw5xGu/gP3NWRLFUh/Llctofa6cMmc6SQMdo/fH9StBgqJl aEBHIqj9O2QBSdcnxB9ja4RN8odpI1GcjNzkFCrU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jakov Petrina , Jean-Philippe Brucker , Alexei Starovoitov , Andrii Nakryiko , Sasha Levin Subject: [PATCH 5.8 127/255] libbpf: Handle GCC built-in types for Arm NEON Date: Tue, 1 Sep 2020 17:09:43 +0200 Message-Id: <20200901151006.813605878@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901151000.800754757@linuxfoundation.org> References: <20200901151000.800754757@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jean-Philippe Brucker [ Upstream commit 702eddc77a905782083b14ccd05b23840675fd18 ] When building Arm NEON (SIMD) code from lib/raid6/neon.uc, GCC emits DWARF information using a base type "__Poly8_t", which is internal to GCC and not recognized by Clang. This causes build failures when building with Clang a vmlinux.h generated from an arm64 kernel that was built with GCC. vmlinux.h:47284:9: error: unknown type name '__Poly8_t' typedef __Poly8_t poly8x16_t[16]; ^~~~~~~~~ The polyX_t types are defined as unsigned integers in the "Arm C Language Extension" document (101028_Q220_00_en). Emit typedefs based on standard integer types for the GCC internal types, similar to those emitted by Clang. Including linux/kernel.h to use ARRAY_SIZE() incidentally redefined max(), causing a build bug due to different types, hence the seemingly unrelated change. Reported-by: Jakov Petrina Signed-off-by: Jean-Philippe Brucker Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20200812143909.3293280-1-jean-philippe@linaro.org Signed-off-by: Sasha Levin --- tools/lib/bpf/btf_dump.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c index bbb4303172606..4edf76c5a7101 100644 --- a/tools/lib/bpf/btf_dump.c +++ b/tools/lib/bpf/btf_dump.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "btf.h" #include "hashmap.h" #include "libbpf.h" @@ -548,6 +549,9 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 id, bool through_ptr) } } +static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id, + const struct btf_type *t); + static void btf_dump_emit_struct_fwd(struct btf_dump *d, __u32 id, const struct btf_type *t); static void btf_dump_emit_struct_def(struct btf_dump *d, __u32 id, @@ -670,6 +674,9 @@ static void btf_dump_emit_type(struct btf_dump *d, __u32 id, __u32 cont_id) switch (kind) { case BTF_KIND_INT: + /* Emit type alias definitions if necessary */ + btf_dump_emit_missing_aliases(d, id, t); + tstate->emit_state = EMITTED; break; case BTF_KIND_ENUM: @@ -869,7 +876,7 @@ static void btf_dump_emit_struct_def(struct btf_dump *d, btf_dump_printf(d, ": %d", m_sz); off = m_off + m_sz; } else { - m_sz = max(0, btf__resolve_size(d->btf, m->type)); + m_sz = max(0LL, btf__resolve_size(d->btf, m->type)); off = m_off + m_sz * 8; } btf_dump_printf(d, ";"); @@ -889,6 +896,32 @@ static void btf_dump_emit_struct_def(struct btf_dump *d, btf_dump_printf(d, " __attribute__((packed))"); } +static const char *missing_base_types[][2] = { + /* + * GCC emits typedefs to its internal __PolyX_t types when compiling Arm + * SIMD intrinsics. Alias them to standard base types. + */ + { "__Poly8_t", "unsigned char" }, + { "__Poly16_t", "unsigned short" }, + { "__Poly64_t", "unsigned long long" }, + { "__Poly128_t", "unsigned __int128" }, +}; + +static void btf_dump_emit_missing_aliases(struct btf_dump *d, __u32 id, + const struct btf_type *t) +{ + const char *name = btf_dump_type_name(d, id); + int i; + + for (i = 0; i < ARRAY_SIZE(missing_base_types); i++) { + if (strcmp(name, missing_base_types[i][0]) == 0) { + btf_dump_printf(d, "typedef %s %s;\n\n", + missing_base_types[i][1], name); + break; + } + } +} + static void btf_dump_emit_enum_fwd(struct btf_dump *d, __u32 id, const struct btf_type *t) {