Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp818736imm; Fri, 31 Aug 2018 14:18:46 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbcU/vtVgpDfCGkWqLOrCyYdTD7GJGmOkploV+xwaXCFJOL48lRYlV9/zgsnzgG0vCQrfbw X-Received: by 2002:a62:4494:: with SMTP id m20-v6mr17953207pfi.205.1535750326008; Fri, 31 Aug 2018 14:18:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535750325; cv=none; d=google.com; s=arc-20160816; b=T1uRoENu4d/k7wMkthY2nv+PD+I3+6mY6OFtEvo2Ea33QeDpYfrSK1oF/0ICMRBiaO Ikwes3qHSySS5KDPo9UQuMQ9XSUyPIZ1R2JfGEKKF+FgVqVDB0MS/f44P7izGdMXCrmC vmQlGRhOR9daqwlGHiDRc8doF6cUY48bl9lqdkrhYqpRLXdupzSRgKtFBYbV3eMqVPVV T6Tj4qDaitAmL7k10MXQ+knk65GkUyhxSmCUS0RXYyIwc9R3arRQPUVm9EkZWTWLMwQy NsIPVBLcBdNV5Rnjq46JctT9V0Y4SslhQG6RmMtBiP2B6WvFZUsL20fLmvtdr7PBrLDy Gl+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=bio1/EvjYxG92soGhk1gFCdvf45JsVdwiwH2NlU2Hm0=; b=B2PVZ79Y1aaJU5RQCDQefTFY2jL7eyl7ikTwsSb8b0SbPgoc29mJ5uZ32WcT3uDN3H uUt2z7MFT5i717RFwaYcwZfCPSR9aTkTQ5QCFm/lN7XFaGDXipRT11bg2aNQdxX51bIT Fz5vhQ94IArf7Ypw77DT/+I2zKIShLmBuLei+tdQMd1CpEoSNAPczSRz1kuzkh12Mbfn 33aKfWd2xWnw2Ai0JbBYUl+E7zpK716ADV4/A6vs+9H4d0yoRR330+psrNr/+XqMQLjb XbJeEu2rdcF6R9bNsB+zW/snXAvD04NgZPY5wGVtW6TRN6XjE4job1nKo11iIaFVX3MJ gBlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="PiV/2GNv"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w11-v6si8916217pgm.616.2018.08.31.14.18.30; Fri, 31 Aug 2018 14:18:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="PiV/2GNv"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727342AbeIAB0O (ORCPT + 99 others); Fri, 31 Aug 2018 21:26:14 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36061 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726869AbeIAB0O (ORCPT ); Fri, 31 Aug 2018 21:26:14 -0400 Received: by mail-pl1-f195.google.com with SMTP id e11-v6so6006159plb.3 for ; Fri, 31 Aug 2018 14:16:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bio1/EvjYxG92soGhk1gFCdvf45JsVdwiwH2NlU2Hm0=; b=PiV/2GNvYLQvt6gm1u0nn1nGZae5RR1Ks+t6ow695ZsvNI7C6LQRhgOtbHnb8p7MpX QVna0qENLQ6Y7YlCJ35aGv7Wvu5IiERFq2XkS4DcBC0wY7XPnM8Qoy+FuTC9hTp2v3u+ Ar/mXhNU5uu/A8KS0h1aDSKDklvhwkW9mqQsJ0kiilXd6/0EX2P2awnXvLNJ2tQvLncA vSDSxfIws4Cwgt2AdaSLN0NNsCFYvcqKP241XcED+ky1F0RaQaxwcHbPFxdY+wooZaCa LokMFWv+X95j89whgeTGheO/OlvljvgVzwB+yjbNzrZ8jR4j9NAMLNlRSyD1T213cp+Y HhiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bio1/EvjYxG92soGhk1gFCdvf45JsVdwiwH2NlU2Hm0=; b=S1XBzbtAzwVa9P1WHxWq0Bjd3UgKI53Ka0jv8Z9AG+pV+HEtkaQ82Sf4u4bN5PaDlA t+BSBU12vBFujSNMYN3lHvbIk3U1IdKyVFFWhrXo4LubOyKW5tDmrR5esBTTTSlKcPOG n+gvztnnsJog9u8ehTLaEpuuIjfsCJuO1VUZrdaND7ILIfs6BMovBgvf1Z0uX0YanDE7 B27W+PVJZFjfq4hUqOAg4YfJufNqMX/Za4drOvBPrMtnKlQGLeXfnJKOeWnOapqizpOT oCuHrI85+W4yjeLsZ9SimSoMeIXcs6Ciw5HFtnxwDRJWGX+OPiMRIYuvbp8AP7am0KwY hUMw== X-Gm-Message-State: APzg51AIgUa7/Rw8hqmgJThQ37bCZiA5FxjkGnM1Oe814sW4WJ79Ui0G gUHrnBJTX74mr4CWfGIYCvvwTaxilSiDmva5Zo6YGQ== X-Received: by 2002:a17:902:7102:: with SMTP id a2-v6mr17247231pll.217.1535750215857; Fri, 31 Aug 2018 14:16:55 -0700 (PDT) MIME-Version: 1.0 References: <20180831170514.24665-1-miguel.ojeda.sandonis@gmail.com> <20180831170514.24665-4-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180831170514.24665-4-miguel.ojeda.sandonis@gmail.com> From: Nick Desaulniers Date: Fri, 31 Aug 2018 14:16:44 -0700 Message-ID: Subject: Re: [PATCH 4/7] Compiler Attributes: homogenize __must_be_array To: Miguel Ojeda Cc: Linus Torvalds , LKML , efriedma@codeaurora.org, sparse@chrisli.org, Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg KH , Masahiro Yamada , joe@perches.com, asmadeus@codewreck.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 31, 2018 at 10:05 AM Miguel Ojeda wrote: > > Different definitions of __must_be_array: > > * gcc: disabled for __CHECKER__ > > * clang: same definition as gcc's, but without __CHECKER__ > > * intel: the comment claims __builtin_types_compatible_p() > is unsupported; but icc seems to support it since 13.0.1 > (released in 2012). See https://godbolt.org/z/S0l6QQ Indeed. It seems that if we can't find a contact for ICC, then 13.0.1 (the oldest version supported by godbolt) is a best effort, IMO. If we end up adding patches for minimal compiler versions, maybe v13.0.1 is a good minimal for ICC. But I would really defer to someone who has an install of ICC (not me). > > Therefore, we can remove all of them and have a single definition > in compiler.h > > Cc: Eli Friedman > Cc: Christopher Li > Cc: Kees Cook > Cc: Ingo Molnar > Cc: Geert Uytterhoeven > Cc: Arnd Bergmann > Cc: Greg Kroah-Hartman > Cc: Masahiro Yamada > Cc: Joe Perches > Cc: Dominique Martinet > Cc: Nick Desaulniers > Cc: Linus Torvalds > Signed-off-by: Miguel Ojeda > --- > include/linux/compiler-clang.h | 1 - > include/linux/compiler-gcc.h | 7 ------- > include/linux/compiler-intel.h | 3 --- > include/linux/compiler.h | 7 +++++++ > 4 files changed, 7 insertions(+), 11 deletions(-) > > diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h > index efda74f4eeba..0aee694d3ab8 100644 > --- a/include/linux/compiler-clang.h > +++ b/include/linux/compiler-clang.h > @@ -41,6 +41,5 @@ > * compilers, like ICC. > */ > #define barrier() __asm__ __volatile__("" : : : "memory") > -#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) > #define __assume_aligned(a, ...) \ > __attribute__((assume_aligned(a, ## __VA_ARGS__))) > diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h > index dbfbecf703f8..66e1eb8822d9 100644 > --- a/include/linux/compiler-gcc.h > +++ b/include/linux/compiler-gcc.h > @@ -68,13 +68,6 @@ > */ > #define uninitialized_var(x) x = x > > -#ifdef __CHECKER__ > -#define __must_be_array(a) 0 > -#else > -/* &a[0] degrades to a pointer: a different type from an array */ > -#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) > -#endif > - > #ifdef RETPOLINE > #define __noretpoline __attribute__((indirect_branch("keep"))) > #endif > diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h > index 4c7f9befa9f6..18bd4362deaa 100644 > --- a/include/linux/compiler-intel.h > +++ b/include/linux/compiler-intel.h > @@ -29,9 +29,6 @@ > */ > #define OPTIMIZER_HIDE_VAR(var) barrier() > > -/* Intel ECC compiler doesn't support __builtin_types_compatible_p() */ > -#define __must_be_array(a) 0 > - > #endif > > /* icc has this, but it's called _bswap16 */ > diff --git a/include/linux/compiler.h b/include/linux/compiler.h > index e0e55eb3f242..e4a702f99e50 100644 > --- a/include/linux/compiler.h > +++ b/include/linux/compiler.h > @@ -357,4 +357,11 @@ static inline void *offset_to_ptr(const int *off) > compiletime_assert(__native_word(t), \ > "Need native word sized stores/loads for atomicity.") > > +#ifdef __CHECKER__ > +#define __must_be_array(a) 0 > +#else > +/* &a[0] degrades to a pointer: a different type from an array */ > +#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0])) > +#endif > + > #endif /* __LINUX_COMPILER_H */ > -- > 2.17.1 > Reviewed-by: Nick Desaulniers -- Thanks, ~Nick Desaulniers