From patchwork Mon Sep 3 20:33:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2708B16B1 for ; Mon, 3 Sep 2018 20:34:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17EC329324 for ; Mon, 3 Sep 2018 20:34:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C35929328; Mon, 3 Sep 2018 20:34:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 903A829324 for ; Mon, 3 Sep 2018 20:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728665AbeIDAzl (ORCPT ); Mon, 3 Sep 2018 20:55:41 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50759 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbeIDAzl (ORCPT ); Mon, 3 Sep 2018 20:55:41 -0400 Received: by mail-wm0-f65.google.com with SMTP id s12-v6so2269535wmc.0; Mon, 03 Sep 2018 13:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZhryjHGsWzeSzxD0NW3OWSaZ8RANYxnQY/DMq4IP8+M=; b=KevZ8PILOJ52LFCPLGi6B7+4pQstK7gmLMNbSBzIkDwJzNW0MelnEvLkzfJsKtNTse 2Wgo1/Plo0uWL9xQ7KjW0HhsOnPR0d5H8jRl/5cPxJrv72bYm2eC8wGhqclf0CKSugc5 1SkrfX0rIt72u3eIKpArRrOR9OvT8Dhpc96U/U50ycGtvTS/xTOZK1CivenSl5MW5mUX lSAev42Wt1gVVCNWquD4FPhhzf8tH3MA4WLCx8EqPGlp2oQ4ArdmfbdLNMBy6O8jUKSC DMyPNQtgL4Txw6gif4G7XSITir8fBeqCnPFxEWTvI3ud7mr0VZAO6Hk4AnbDcCgOZyOi fuVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZhryjHGsWzeSzxD0NW3OWSaZ8RANYxnQY/DMq4IP8+M=; b=Oz1egg4gko+g67NIEyp0hV06b1h+sXqvXF3MDnT9ci4XRayXhtofVor7dMOWfGNZxh 7nezSpeIzSye8A6fjO39LH20bjSL63F/E13QspXqSDyNF9YngF092wrDEDQRspYVoRJM 6nn//dP4nVGVNCUsW7duXsYbnlZj0V8jtX65/WEgwD4L6/F+zziz8we8AX1SkzLXIMHS 4Ee8vTCD4BX3sI9KQzLktGGow7AvUg6651WGOZvnJu4eL1r7621aALtq8JqWC7DTgKZ9 /GkNG8EOwZqnokSmZQRcdsM09n9z+uoZcrn6/qPUp/ZdCtKjKjz5NyB0jKQ4eXiUiLjl 06pQ== X-Gm-Message-State: APzg51CID8tbFfarh2NNFdKX3RupGTWGpeVLad8rEKHMbO50ndPayf2O +f1xXssayuEhs75nBytj96E= X-Google-Smtp-Source: ANB0VdYbX5Oa31laIZImtJpmZTii5ksCZCkd6tq0A71C7EaK6DpActd73FsXCpmzoGW/IY1HgP78vg== X-Received: by 2002:a1c:d946:: with SMTP id q67-v6mr5934162wmg.156.1536006828434; Mon, 03 Sep 2018 13:33:48 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:47 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH 01/12] Compiler Attributes: remove unused attributes Date: Mon, 3 Sep 2018 22:33:05 +0200 Message-Id: <20180903203316.16183-2-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP __optimize and __deprecate_for_modules are unused in the whole kernel tree. Simply drop them. Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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: Linus Torvalds Cc: linux-sparse@vger.kernel.org Reviewed-by: Nick Desaulniers Signed-off-by: Miguel Ojeda --- include/linux/compiler-gcc.h | 2 -- include/linux/compiler.h | 4 ---- include/linux/compiler_types.h | 1 - 3 files changed, 7 deletions(-) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 763bbad1e258..0a2d06677d83 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -95,8 +95,6 @@ #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) -#define __optimize(level) __attribute__((__optimize__(level))) - #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) #ifndef __CHECKER__ diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 681d866efb1e..7c0157d50964 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -301,10 +301,6 @@ static inline void *offset_to_ptr(const int *off) #endif /* __ASSEMBLY__ */ -#ifndef __optimize -# define __optimize(level) -#endif - /* Compile time object size, -1 for unknown */ #ifndef __compiletime_object_size # define __compiletime_object_size(obj) -1 diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 3525c179698c..b6534292ea33 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -108,7 +108,6 @@ struct ftrace_likely_data { /* Don't. Just don't. */ #define __deprecated -#define __deprecated_for_modules #endif /* __KERNEL__ */ From patchwork Mon Sep 3 20:33:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586381 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D90FA139B for ; Mon, 3 Sep 2018 20:34:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8AF729324 for ; Mon, 3 Sep 2018 20:34:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BC32229328; Mon, 3 Sep 2018 20:34:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC89329324 for ; Mon, 3 Sep 2018 20:34:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727552AbeIDAzo (ORCPT ); Mon, 3 Sep 2018 20:55:44 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34602 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbeIDAzn (ORCPT ); Mon, 3 Sep 2018 20:55:43 -0400 Received: by mail-wm0-f68.google.com with SMTP id j25-v6so9714960wmc.1; Mon, 03 Sep 2018 13:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0nSFCzTHwEx3uHSnN/pA7EXvGdKx2RttjcOzGdkhYLw=; b=ZaCB9sCu+QlhRgpLNGXFF+QHCalQR8h6y41cX4ADpO8Y1jXk3ymhamIHKh8UWafeFr yyRtvQqAv91CuzqtwrZ3X8b+xfLvEN7U1hQ5V1yu4gZUEC1NZ9jNSl01t8DqqH0tY/DV JGbuvha8iy5r7/jWq5R5No5N5m6A12SPAPTLVF7nZQIlgDi5z+URgcAxt8klkTqzDOSW UfZ7B0g4pwEaOLwebZlycDO8HHftW29MLZnJLH0jI4uI4q/oQ0KBUdu63hrikHLPbklA QLj9RsSDYXly8EW+6XG3hTZ/oa0hLMdM9Q8J0oDqcbxOgHIBwUuZfBHDwVLiwkFU6Uwm ojfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0nSFCzTHwEx3uHSnN/pA7EXvGdKx2RttjcOzGdkhYLw=; b=XV+2l2YWvK/j/x5MEp+xgYsIdCvUN/M++BFn9nR/nnq2zFnjHVJRGgX6QXHBa0t1PG lFtZRTW9qiaDwdlJ0iqo7Cl3vA+dIRm194RT9svGrx4Cmf2VF3ziljAKvKD/r++k6+N7 8hbDbmiD/Fu3mYfxmkCBLn18thCGwfjG1Y0+P2soYMYRie5t3ctYL91RwyAV2sWZgRIG uOY4u9QpIhRPYywKRFSNgeihlJSUlQZ2ZN8UMT1znzt0EHYSaiBgfuW1AOlNR537Qmf2 rMJydrNZbwnpknZJPeWbjzwKBvjNUwMc5CjrebvWNoakVSsqthNQZq/D4W1w0YwEDild OPUA== X-Gm-Message-State: APzg51AJ0l1l5FWqFdo0qHlQe8yFL2RLvKHEigEB8kmaW+EF9VFRHhcD vz9tzanNqan2hPCCYzATadc= X-Google-Smtp-Source: ANB0VdYCzbvR9yc1CnE2kyhp/fsCKPfe6/Dm/FYHnzoMrQ2mKQLzDbLpPuWkezRpc/1Y7bI2OUCbyQ== X-Received: by 2002:a1c:dfc4:: with SMTP id w187-v6mr114401wmg.162.1536006829787; Mon, 03 Sep 2018 13:33:49 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:49 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH 02/12] Compiler Attributes: always use the extra-underscores syntax Date: Mon, 3 Sep 2018 22:33:06 +0200 Message-Id: <20180903203316.16183-3-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The attribute syntax optionally allows to surround attribute names with "__" in order to avoid collisions with macros of the same name (see https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html). This homogenizes all attributes to use the syntax with underscores. While there are currently only a handful of cases of some TUs defining macros like "error" which may collide with the attributes, this should prevent futures surprises. This has been done only for "standard" attributes supported by the major compilers. In other words, those of third-party tools (e.g. sparse, plugins...) have not been changed for the moment. Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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: Linus Torvalds Cc: linux-sparse@vger.kernel.org Reviewed-by: Nick Desaulniers Signed-off-by: Miguel Ojeda --- include/linux/compiler-clang.h | 2 +- include/linux/compiler-gcc.h | 14 ++++++------ include/linux/compiler-intel.h | 2 +- include/linux/compiler.h | 8 +++---- include/linux/compiler_types.h | 40 +++++++++++++++++----------------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index b1ce500fe8b3..d11cad61ba5c 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -21,7 +21,7 @@ #define __SANITIZE_ADDRESS__ #endif -#define __no_sanitize_address __attribute__((no_sanitize("address"))) +#define __no_sanitize_address __attribute__((__no_sanitize__("address"))) /* * Not all versions of clang implement the the type-generic versions diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 0a2d06677d83..371b6fa2d074 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -76,7 +76,7 @@ #endif #ifdef RETPOLINE -#define __noretpoline __attribute__((indirect_branch("keep"))) +#define __noretpoline __attribute__((__indirect_branch__("keep"))) #endif /* @@ -91,15 +91,15 @@ * GCC 4.[56] currently fail to enforce this, so we must do so ourselves. * See GCC PR44290. */ -#define __naked __attribute__((naked)) noinline __noclone notrace +#define __naked __attribute__((__naked__)) noinline __noclone notrace #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) #ifndef __CHECKER__ -#define __compiletime_warning(message) __attribute__((warning(message))) -#define __compiletime_error(message) __attribute__((error(message))) +#define __compiletime_warning(message) __attribute__((__warning__(message))) +#define __compiletime_error(message) __attribute__((__error__(message))) #ifdef LATENT_ENTROPY_PLUGIN #define __latent_entropy __attribute__((latent_entropy)) @@ -148,7 +148,7 @@ * optimizer that something else uses this function or variable, thus preventing * this. */ -#define __visible __attribute__((externally_visible)) +#define __visible __attribute__((__externally_visible__)) /* gcc version specific checks */ @@ -205,7 +205,7 @@ * should not be applied to that function. * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 */ -#define __no_sanitize_address __attribute__((no_sanitize_address)) +#define __no_sanitize_address __attribute__((__no_sanitize_address__)) #endif #if GCC_VERSION >= 50100 @@ -213,7 +213,7 @@ * Mark structures as requiring designated initializers. * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html */ -#define __designated_init __attribute__((designated_init)) +#define __designated_init __attribute__((__designated_init__)) #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 #endif diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index 4c7f9befa9f6..fef8bb3e53ef 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -42,4 +42,4 @@ * and may be redefined here because they should not be shared with other * compilers, like clang. */ -#define __visible __attribute__((externally_visible)) +#define __visible __attribute__((__externally_visible__)) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 7c0157d50964..ec4a28bad2c6 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -24,7 +24,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, long ______r; \ static struct ftrace_likely_data \ __attribute__((__aligned__(4))) \ - __attribute__((section("_ftrace_annotated_branch"))) \ + __attribute__((__section__("_ftrace_annotated_branch"))) \ ______f = { \ .data.func = __func__, \ .data.file = __FILE__, \ @@ -60,7 +60,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, int ______r; \ static struct ftrace_branch_data \ __attribute__((__aligned__(4))) \ - __attribute__((section("_ftrace_branch"))) \ + __attribute__((__section__("_ftrace_branch"))) \ ______f = { \ .func = __func__, \ .file = __FILE__, \ @@ -146,7 +146,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, extern typeof(sym) sym; \ static const unsigned long __kentry_##sym \ __used \ - __attribute__((section("___kentry" "+" #sym ), used)) \ + __attribute__((__section__("___kentry" "+" #sym ), used)) \ = (unsigned long)&sym; #endif @@ -287,7 +287,7 @@ unsigned long read_word_at_a_time(const void *addr) * visible to the compiler. */ #define __ADDRESSABLE(sym) \ - static void * __attribute__((section(".discard.addressable"), used)) \ + static void * __attribute__((__section__(".discard.addressable"), used)) \ __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; /** diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index b6534292ea33..2bc0f94df38e 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -195,26 +195,26 @@ struct ftrace_likely_data { * would be. * [...] */ -#define __pure __attribute__((pure)) -#define __aligned(x) __attribute__((aligned(x))) -#define __aligned_largest __attribute__((aligned)) -#define __printf(a, b) __attribute__((format(printf, a, b))) -#define __scanf(a, b) __attribute__((format(scanf, a, b))) -#define __maybe_unused __attribute__((unused)) -#define __always_unused __attribute__((unused)) -#define __mode(x) __attribute__((mode(x))) +#define __pure __attribute__((__pure__)) +#define __aligned(x) __attribute__((__aligned__(x))) +#define __aligned_largest __attribute__((__aligned__)) +#define __printf(a, b) __attribute__((__format__(printf, a, b))) +#define __scanf(a, b) __attribute__((__format__(scanf, a, b))) +#define __maybe_unused __attribute__((__unused__)) +#define __always_unused __attribute__((__unused__)) +#define __mode(x) __attribute__((__mode__(x))) #define __malloc __attribute__((__malloc__)) #define __used __attribute__((__used__)) -#define __noreturn __attribute__((noreturn)) -#define __packed __attribute__((packed)) -#define __weak __attribute__((weak)) -#define __alias(symbol) __attribute__((alias(#symbol))) -#define __cold __attribute__((cold)) +#define __noreturn __attribute__((__noreturn__)) +#define __packed __attribute__((__packed__)) +#define __weak __attribute__((__weak__)) +#define __alias(symbol) __attribute__((__alias__(#symbol))) +#define __cold __attribute__((__cold__)) #define __section(S) __attribute__((__section__(#S))) #ifdef CONFIG_ENABLE_MUST_CHECK -#define __must_check __attribute__((warn_unused_result)) +#define __must_check __attribute__((__warn_unused_result__)) #else #define __must_check #endif @@ -222,7 +222,7 @@ struct ftrace_likely_data { #if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__) #define notrace __attribute__((hotpatch(0, 0))) #else -#define notrace __attribute__((no_instrument_function)) +#define notrace __attribute__((__no_instrument_function__)) #endif #define __compiler_offsetof(a, b) __builtin_offsetof(a, b) @@ -234,7 +234,7 @@ struct ftrace_likely_data { * defined so the gnu89 semantics are the default. */ #ifdef __GNUC_STDC_INLINE__ -# define __gnu_inline __attribute__((gnu_inline)) +# define __gnu_inline __attribute__((__gnu_inline__)) #else # define __gnu_inline #endif @@ -254,17 +254,17 @@ struct ftrace_likely_data { #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) #define inline \ - inline __attribute__((always_inline, unused)) notrace __gnu_inline + inline __attribute__((__always_inline__, __unused__)) notrace __gnu_inline #else -#define inline inline __attribute__((unused)) notrace __gnu_inline +#define inline inline __attribute__((__unused__)) notrace __gnu_inline #endif #define __inline__ inline #define __inline inline -#define noinline __attribute__((noinline)) +#define noinline __attribute__((__noinline__)) #ifndef __always_inline -#define __always_inline inline __attribute__((always_inline)) +#define __always_inline inline __attribute__((__always_inline__)) #endif /* From patchwork Mon Sep 3 20:33:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17EC4112B for ; Mon, 3 Sep 2018 20:34:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0755E29323 for ; Mon, 3 Sep 2018 20:34:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF91629329; Mon, 3 Sep 2018 20:34:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6560629323 for ; Mon, 3 Sep 2018 20:34:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbeIDAzo (ORCPT ); Mon, 3 Sep 2018 20:55:44 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:45527 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbeIDAzn (ORCPT ); Mon, 3 Sep 2018 20:55:43 -0400 Received: by mail-wr1-f65.google.com with SMTP id 20-v6so1712696wrb.12; Mon, 03 Sep 2018 13:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DF6EgP2im+TL2Bj+0aBYVQPMWJB603xa+lUoFLMY8Fw=; b=N3ZeJBUUTuoGb3LLWWOs3VIwCM49YoDhwtHAGNM4msavD6YT9RCx33qsSpzbACBN6t KAzcIdLB61VIXGAtRyIgkTvFbO6ZSbHXG+JflQzL4jq+QnF2DrmGA9FhQ2W2aUTu7LEj vBLbmKCfRYXqGJljckX4235jYDM2YiWNtSRuG1MbXH0xD6O/bWxJKaoZFpgAcG4BiHv8 GzZctzko2W14rXEkCQnEuV+apaxQRl+q70aMLCeoMH/IcLVNfJQmz3KAn/qS60yZA7Xz h0Tbz8L0kgUFxU8PKLF9SJ+n5G7+uNrVHk0P/LowPq9zuPk0UJdlDB90vla6i2qKI0Nq mvRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DF6EgP2im+TL2Bj+0aBYVQPMWJB603xa+lUoFLMY8Fw=; b=aZAAn1/dOhuuGNrfwTUWDFLjjvEx0SWGro7yKYyqgd1JHY7j67/Sw/6A4Led9TSeXH GuF6Pu00hxRZ/Wh7neVJmzeUTMBWVtDTAJx0QEikkHG/DSL035ppZ91gjEGnbvP7mfwc mxfHH6Z/DQ+Fm/C7SiU2iC6/eCnyD8jxUmaPtzRYC2aw4ifshSMoWWFiV4187X9y+TSZ rK1lPpETYPTkm+zqSEbDEV1x/l4lLIFQ7AuHt9qBJQa738keQx7MX28f9Fi3qQUfJn82 Hl8gOYdWmMi32WdAVx+vzahNF9KX2T36m5sjfalFwWCe35yiX7QfL3doNOXl4J9xUZ+g 8hYA== X-Gm-Message-State: APzg51Dd+0+sGOGaUK/NKBwNPMseAYhXTgXc3sQb3lcjth4MZgodxy29 +Uqxj8afqpMuTQpoinl5+y4= X-Google-Smtp-Source: ANB0VdajEQG88h/5EjDl4FcNGP04S1HHL2onUqoMdqD+iGOA3RZ5GBELkQxzB8t38HN9GQ9y/VH4Ow== X-Received: by 2002:a5d:66d2:: with SMTP id k18-v6mr20496480wrw.154.1536006831167; Mon, 03 Sep 2018 13:33:51 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:50 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH 03/12] Compiler Attributes: remove unneeded tests Date: Mon, 3 Sep 2018 22:33:07 +0200 Message-Id: <20180903203316.16183-4-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Attributes const and always_inline have tests around them which are unneeded, since they are supported by gcc >= 4.6, clang >= 3 and icc >= 13. https://godbolt.org/z/DFPq37 In the case of gnu_inline, we do not need to test for __GNUC_STDC_INLINE__ because, regardless of the current inlining behavior, we can simply always force the old GCC inlining behavior by using the attribute in all cases. Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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: Linus Torvalds Cc: linux-sparse@vger.kernel.org Reviewed-by: Nick Desaulniers Signed-off-by: Miguel Ojeda --- include/linux/compiler_types.h | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 2bc0f94df38e..759b3fea9216 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -158,10 +158,6 @@ struct ftrace_likely_data { (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) -#ifndef __attribute_const__ -#define __attribute_const__ __attribute__((__const__)) -#endif - #ifndef __noclone #define __noclone #endif @@ -196,6 +192,7 @@ struct ftrace_likely_data { * [...] */ #define __pure __attribute__((__pure__)) +#define __attribute_const__ __attribute__((__const__)) #define __aligned(x) __attribute__((__aligned__(x))) #define __aligned_largest __attribute__((__aligned__)) #define __printf(a, b) __attribute__((__format__(printf, a, b))) @@ -211,7 +208,8 @@ struct ftrace_likely_data { #define __alias(symbol) __attribute__((__alias__(#symbol))) #define __cold __attribute__((__cold__)) #define __section(S) __attribute__((__section__(#S))) - +#define __gnu_inline __attribute__((__gnu_inline__)) +#define __always_inline inline __attribute__((__always_inline__)) #ifdef CONFIG_ENABLE_MUST_CHECK #define __must_check __attribute__((__warn_unused_result__)) @@ -227,18 +225,6 @@ struct ftrace_likely_data { #define __compiler_offsetof(a, b) __builtin_offsetof(a, b) -/* - * Feature detection for gnu_inline (gnu89 extern inline semantics). Either - * __GNUC_STDC_INLINE__ is defined (not using gnu89 extern inline semantics, - * and we opt in to the gnu89 semantics), or __GNUC_STDC_INLINE__ is not - * defined so the gnu89 semantics are the default. - */ -#ifdef __GNUC_STDC_INLINE__ -# define __gnu_inline __attribute__((__gnu_inline__)) -#else -# define __gnu_inline -#endif - /* * Force always-inline if the user requests it so via the .config. * GCC does not warn about unused static inline functions for @@ -263,10 +249,6 @@ struct ftrace_likely_data { #define __inline inline #define noinline __attribute__((__noinline__)) -#ifndef __always_inline -#define __always_inline inline __attribute__((__always_inline__)) -#endif - /* * Rather then using noinline to prevent stack consumption, use * noinline_for_stack instead. For documentation reasons. From patchwork Mon Sep 3 20:33:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5FEC5139B for ; Mon, 3 Sep 2018 20:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 514D329324 for ; Mon, 3 Sep 2018 20:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44F2629328; Mon, 3 Sep 2018 20:34:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE3AB29324 for ; Mon, 3 Sep 2018 20:34:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729245AbeIDA4b (ORCPT ); Mon, 3 Sep 2018 20:56:31 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54350 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728876AbeIDAzp (ORCPT ); Mon, 3 Sep 2018 20:55:45 -0400 Received: by mail-wm0-f66.google.com with SMTP id c14-v6so2242981wmb.4; Mon, 03 Sep 2018 13:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5ELqCquol9uLIAR1HjMyJP27IPe/3rVJEhfvVxeS1Hw=; b=PZ8lRtcqCAREJWRk7OxHdLuKGL+jzw1ZlDYOrrlBzTe/zJ3OId2+DCFk/hheMvFJze MJoyCY4mGKR24QbUfRkTJDA3Vj2tmCbQiiW0+lczSfEmp5CmkRfqPWFa21sMQbj/qppz KVOwRfQQT3B7zSjqUzxoPNmRPMbguD9V9LmkocXOIs9mu3mAC+WYbgCu6wb5mOogArmn 5u2b85UYjehJ/XYANLn0vCcTrwUBOO8FomriMxyguHOr5UJUwqIIIoqZotbtroHexW1X EPds6Ced997TL+QYG3DspwJkOXHIRFKdIO6CTxF+YmbwFs8ZjyzIhX1yPsB3Fl99PsvH UbbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5ELqCquol9uLIAR1HjMyJP27IPe/3rVJEhfvVxeS1Hw=; b=IRqgWvZnhxluAT5x2qZ1frIYK8BVojHIw2PDtefqJM/eedw/zHymd39qu726QGkTOu iI1tuMKIQsIf4vgdcclGD7wME404E61X1kNrpGxCzpoEI4ChDCSJuoTl7kSDn6d7k2Sp txXpwUo1g+/W8/L1/m9M6rW6K8eiM9h5CztRHexMMEs/8iQq4Ov3QWx6pAolhGQYxFOO Y9dOHpGhR1zqiXu0QEE9wGwNx2laZGEfBG9SbsMzShiJRe7b/PhfJEiGxsUDCAZHfiAk WmFmCrDPSp5uRwc/5/NtRkKIJmdQmdzn8LJQnvSTQUzfF+AzB/pRabHW5E7Pp/4sD9du 7Dpw== X-Gm-Message-State: APzg51BB1y2Bb7xrh6D9OXRSCwlSVidsgpX1IUpCXdqGd268xf0b/ZV8 wB7hNz9g/z1DjZMz02F0Vy4= X-Google-Smtp-Source: ANB0VdaUn36qgIxj0m4yhJJofzQE3fQN9+UIPEVgqfvXEdDIq3n8tlld4j5U9SglnXPaQMEes7+vJQ== X-Received: by 2002:a1c:cf08:: with SMTP id f8-v6mr6412283wmg.27.1536006832580; Mon, 03 Sep 2018 13:33:52 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:51 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH 04/12] Compiler Attributes: homogenize __must_be_array Date: Mon, 3 Sep 2018 22:33:08 +0200 Message-Id: <20180903203316.16183-5-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Therefore, we can remove all of them and have a single definition in compiler.h Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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: Linus Torvalds Cc: linux-sparse@vger.kernel.org Reviewed-by: Nick Desaulniers 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 d11cad61ba5c..fa9532f8d885 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 371b6fa2d074..76f4907ef707 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 fef8bb3e53ef..6004b4588bd4 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 ec4a28bad2c6..165b1d5683ed 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 */ From patchwork Mon Sep 3 20:33:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1099112B for ; Mon, 3 Sep 2018 20:34:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B237229324 for ; Mon, 3 Sep 2018 20:34:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A68CE29328; Mon, 3 Sep 2018 20:34:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3218929324 for ; Mon, 3 Sep 2018 20:34:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728987AbeIDAzr (ORCPT ); Mon, 3 Sep 2018 20:55:47 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:34823 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbeIDAzq (ORCPT ); Mon, 3 Sep 2018 20:55:46 -0400 Received: by mail-wr1-f65.google.com with SMTP id j26-v6so1779883wre.2; Mon, 03 Sep 2018 13:33:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KSmd8Leci7Jq2YnVlQ1QxGK80ki+uToFeuQJJ1eS4UY=; b=icDclaID20kA2vZHgCRuEH4RbRbFT934AX/qUMq6Cy/ckNBZxCU2fbeKsc+HJlreL3 4Kv+dXU1P9xGZfiSzASm13oxUWOIQKLTcZfleLfJ05j/1uXFhGFf3VySD8QwWg8uUjQv z+q1eHAZTpv6ZKxs9Jgjowx6JkJOy0YYVNVhbujWzX33+eB8rUQQZ/VSO/Vhog0cANxl srWpZ4zPNNV8TSXLNxQCDBxjWzhLDzgmKKJfARKvzX5h+6Cp4dY0m0K8nFlgiBmnHPK/ 12RkoufbGeVMJz9BsiIMK3r5xXriYbjgEzro79aKtandHseG2bCnhErsuhShks+5W8Do Szmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KSmd8Leci7Jq2YnVlQ1QxGK80ki+uToFeuQJJ1eS4UY=; b=NJBDXMieSQ657XgD45duw+zsdYr+ApQVx0ESqcmabg7hKAbwwuDJxo27FKGO5ZZiYh 8z/eb2Hii+fTDzk5Q4rG9yISa4L6A2Niw705/U3LUHGZfTBabr8gLzIMoEuBpiPgJL1o z0zOtdxSSGDvbSiqRG5JGf1g5bcg/lRIc+es+13JAJNU6NcNRoB+e/PL5e+laNjEgMrC nHVX4iE6he/6497zw5hqlwScZT8zjuzzGu7eOw3cSOGBHAXutfCIOnrbDiLxcY80iqTc eZVCX8jDDYMUrc+HWSmSC1zT4NRUqx5gr72jUaC/gmKmGPKOrRemgxXR+1F+25e32gj4 yplg== X-Gm-Message-State: APzg51CaFZHDioqK38GUID8YAYgv285xmE9NjE3IcPPyqVVJ0GMmZvsX nRiZYcuHk1h3WyuNYV1Ydk8= X-Google-Smtp-Source: ANB0Vdbs8rVQYZxMUubvVWWHkOb1n3a26S04W6xwv7J7JNE1Eh/UTzi/YfQLSjHkJWciUdri1qlCew== X-Received: by 2002:a5d:550a:: with SMTP id b10-v6mr21413137wrv.228.1536006834015; Mon, 03 Sep 2018 13:33:54 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:53 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , Nick Desaulniers , linux-sparse@vger.kernel.org Subject: [PATCH 05/12] Compiler Attributes: naked was fixed in gcc 4.6 Date: Mon, 3 Sep 2018 22:33:09 +0200 Message-Id: <20180903203316.16183-6-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 9c695203a7dd ("compiler-gcc.h: gcc-4.5 needs noclone and noinline on __naked functions") added noinline and noclone as a workaround for a gcc 4.5 bug, which was resolved in 4.6.0. Since now the minimum gcc supported version is 4.6, we can clean it up. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44290 and https://godbolt.org/z/h6NMIL Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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 Cc: linux-sparse@vger.kernel.org Signed-off-by: Miguel Ojeda --- include/linux/compiler-gcc.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 76f4907ef707..4cd5e9264bce 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -77,14 +77,8 @@ * to trace naked functions because then mcount is called without * stack and frame pointer being set up and there is no chance to * restore the lr register to the value before mcount was called. - * - * The asm() bodies of naked functions often depend on standard calling - * conventions, therefore they must be noinline and noclone. - * - * GCC 4.[56] currently fail to enforce this, so we must do so ourselves. - * See GCC PR44290. */ -#define __naked __attribute__((__naked__)) noinline __noclone notrace +#define __naked __attribute__((__naked__)) notrace #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) From patchwork Mon Sep 3 20:33:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01220139B for ; Mon, 3 Sep 2018 20:34:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E572929324 for ; Mon, 3 Sep 2018 20:34:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0BBE29329; Mon, 3 Sep 2018 20:34:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 535F229324 for ; Mon, 3 Sep 2018 20:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729016AbeIDAzs (ORCPT ); Mon, 3 Sep 2018 20:55:48 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35901 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbeIDAzr (ORCPT ); Mon, 3 Sep 2018 20:55:47 -0400 Received: by mail-wr1-f68.google.com with SMTP id m27-v6so1780964wrf.3; Mon, 03 Sep 2018 13:33:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+B+9bm1THTOeBY7olqboSx+3ofE8Jtp1C0MIwvpUxT4=; b=hNVNqqKGEpV7IIiybj5escRX0NUAk2HKivO21i7TVFypVICPGLMOgDgnITakCxT0nE TThZFKdJk+OjIeO1aJE0a6xzWIU1HSSuRqoX13KDMyecRXHxbVomImJg6Z0vaW9FXhcz K+oHj4vuQOCCYYr7lMGWnHy8FP3tC4oO2wngJ2dLzwGUOCO5zT/d936/1eeLrRXhy1e4 Wfmqp00oLO2Wo/oCfIzLNEaLQFeeQbevlxwPkjIud0jAdyjFxuF/O1d+kbEFgfvcLW1c //LCMJzoSS42IIE0qElLlxUkJ9sRHNy5HZ/kfMcDBgQP9YILRadbBDdU/tt9e5YfCnRw nWEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+B+9bm1THTOeBY7olqboSx+3ofE8Jtp1C0MIwvpUxT4=; b=XMq21c7S+jArKixdjlQvyROR313pX2BdqfrHudgtl4Oi7dBxfsNl2fSnwVsZCxp7KQ 0zRud/M4u13of5ALiEw2lutqL69ktarqbOuLXcHVA/lSYlNcoMOSAnaJ/FkjwvNhc2ru HnP4rqEfI92D76AR343DCEspo4uG4K3nQq+ktiMGpxQ3xG0wyK27Z0huJdRZayq0kxRd ZIR7kn2T5p1csCTLrBxubohIDw6vRKdt6JKI8UYfbpiZTBKGZkH8khD+68ESvisdTnQq KYxVXx7Vsj3Qpa6XLoS9MFXqTqNbUJvfUlEnqXbuWxyY63MxSHMZnp+GzdFGOprMLWUJ WHGA== X-Gm-Message-State: APzg51DIA5P6IMtNbYhfGhffEZHxCpy60mWQtHWbz7acFGfJc3R8Dz0I lAAc5rfeqdB/sqBXtoRgklE= X-Google-Smtp-Source: ANB0Vdbv4HAkRKanQ/bhDWSwjMyyCCnISGbNh4r32Rsqe5H9bksxp2BQS8Q4rcbj3BeERw4mCXRxQg== X-Received: by 2002:a5d:5450:: with SMTP id w16-v6mr21575181wrv.4.1536006835354; Mon, 03 Sep 2018 13:33:55 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:54 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , Nick Desaulniers , linux-sparse@vger.kernel.org Subject: [PATCH 06/12] Compiler Attributes: naked can be shared Date: Mon, 3 Sep 2018 22:33:10 +0200 Message-Id: <20180903203316.16183-7-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The naked attribute is supported by at least gcc >= 4.6 (for ARM, which is the only current user), gcc >= 8 (for x86), clang >= 3.1 and icc >= 13. See https://godbolt.org/z/350Dyc Therefore, move it out of compiler-gcc.h so that the definition is shared by all compilers. Cc: Rasmus Villemoes Cc: Luc Van Oostenryck Cc: Eli Friedman Cc: Christopher Li Cc: Kees Cook Cc: Ingo Molnar Cc: Geert Uytterhoeven Cc: Greg Kroah-Hartman Cc: Masahiro Yamada Cc: Joe Perches Cc: Dominique Martinet Cc: Nick Desaulniers Cc: Linus Torvalds Cc: linux-sparse@vger.kernel.org Suggested-by: Arnd Bergmann Signed-off-by: Miguel Ojeda --- include/linux/compiler-gcc.h | 8 -------- include/linux/compiler_types.h | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 4cd5e9264bce..3b32bbfa5a49 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -72,14 +72,6 @@ #define __noretpoline __attribute__((__indirect_branch__("keep"))) #endif -/* - * it doesn't make sense on ARM (currently the only user of __naked) - * to trace naked functions because then mcount is called without - * stack and frame pointer being set up and there is no chance to - * restore the lr register to the value before mcount was called. - */ -#define __naked __attribute__((__naked__)) notrace - #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 759b3fea9216..f182f2ef3227 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -223,6 +223,14 @@ struct ftrace_likely_data { #define notrace __attribute__((__no_instrument_function__)) #endif +/* + * it doesn't make sense on ARM (currently the only user of __naked) + * to trace naked functions because then mcount is called without + * stack and frame pointer being set up and there is no chance to + * restore the lr register to the value before mcount was called. + */ +#define __naked __attribute__((__naked__)) notrace + #define __compiler_offsetof(a, b) __builtin_offsetof(a, b) /* From patchwork Mon Sep 3 20:33:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586363 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E7A26112B for ; Mon, 3 Sep 2018 20:34:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDD992931D for ; Mon, 3 Sep 2018 20:34:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEF2829324; Mon, 3 Sep 2018 20:34:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D28202931D for ; Mon, 3 Sep 2018 20:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbeIDAzu (ORCPT ); Mon, 3 Sep 2018 20:55:50 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:41620 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbeIDAzt (ORCPT ); Mon, 3 Sep 2018 20:55:49 -0400 Received: by mail-wr1-f66.google.com with SMTP id z96-v6so1742391wrb.8; Mon, 03 Sep 2018 13:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HoCi5EJzB+/PbEERt2xyXHFMzpFbJL9r+GdGJgj/E2I=; b=Skx0JzuzOifbH6Nu73FZZulPhYCoy3WAHSwkgknIK7riIm3YwzVs+waTWb1cNxZtVE VkljYkOsx8v3stytWW1mgYxYy6bmV76ypJ2+f3uNy6fNHNFbN7h8B4CjDTqdBjptm3KO 7CZPBNWMH4OsPbDuG/Ul8wKoyllhlKj/4qDOqwANo0D4MaBiS74aW4D3HJmf/0NzJVWt rvBKxCOC3MDEebpsDlSdrYki/S20yYioFtUXt2lnBJvpTkTUu0EE5CfTS380S2MxY0ZL QSs5JZmqrfCTJyNhRCh2dIyvESJZZqnBA1VBOwcKx8s34uXqigHg49uOk3WYf96O2T9t 5BbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HoCi5EJzB+/PbEERt2xyXHFMzpFbJL9r+GdGJgj/E2I=; b=jGD4MJEbnMCvbwgF/qObRhufYoRQx6XiVUjiuzO2+GrjJk7sRUc92WODq7+kWfVXa4 1tVxTCfDIjNiiOqOUvouno9RCwlzDKgvDneU2ABStZKcMnCXZqyAOT0u2t7l2WQ1DymU Q1e1tZfWIJdOjhCghmwkN0ar0BUQQzTmAReLeahdYizYTiC4Vuw233u2Ssg5iUBdvzE3 zs6wf+lhsqbdR/EvRyymoozDGknwaZjH+TVVX28XP1rg5uLBMzjnjPfn8Djjnmxu1G45 MXgRi61Kt8Jv7/IczK6omeVy8QGyH7VVnDBFiF2idL9wdfe+GT+oxIZkghgBV182a7J1 qPfw== X-Gm-Message-State: APzg51DQrlC/b3j7/QAWJaYIwIWivr9fbKaK+ikrgZjyV5oRO2srDhLW Fub1mOwjd2HsbNG+BfgIdyU= X-Google-Smtp-Source: ANB0VdbZb23hl5yC72x74//5yieVjzAtxnS1CcRJsCLFbrc43giXsUnFM9kteBQUwueSjE2MTwOXQQ== X-Received: by 2002:adf:8919:: with SMTP id s25-v6mr20133892wrs.89.1536006836762; Mon, 03 Sep 2018 13:33:56 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:56 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH 07/12] Compiler Attributes: remove unneeded sparse (__CHECKER__) tests Date: Mon, 3 Sep 2018 22:33:11 +0200 Message-Id: <20180903203316.16183-8-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sparse knows about a few more attributes now, so we can remove the __CHECKER__ conditions from them (which, in turn, allow us to move some of them later on to compiler_attributes.h). * assume_aligned: since sparse's commit ffc860b ("sparse: ignore __assume_aligned__ attribute"), included in 0.5.1 * error: since sparse's commit 0a04210 ("sparse: Add 'error' to ignored attributes"), included in 0.5.0 * hotpatch: since sparse's commit 6043210 ("sparse/parse.c: ignore hotpatch attribute"), included in 0.5.1 * warning: since sparse's commit 977365d ("Avoid "attribute 'warning': unknown attribute" warning"), included in 0.4.2 On top of that, __must_be_array does not need it either because: * Even ancient versions of sparse do not have a problem * BUILD_BUG_ON_ZERO() is currently disabled for __CHECKER__ Cc: Rasmus Villemoes 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: Linus Torvalds Cc: linux-sparse@vger.kernel.org Acked-by: Luc Van Oostenryck Reviewed-by: Nick Desaulniers Signed-off-by: Miguel Ojeda --- include/linux/compiler-gcc.h | 6 ++---- include/linux/compiler.h | 4 ---- include/linux/compiler_types.h | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 3b32bbfa5a49..1ca6a51cfaa9 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -76,14 +76,12 @@ #define __compiletime_object_size(obj) __builtin_object_size(obj, 0) -#ifndef __CHECKER__ #define __compiletime_warning(message) __attribute__((__warning__(message))) #define __compiletime_error(message) __attribute__((__error__(message))) -#ifdef LATENT_ENTROPY_PLUGIN +#if defined(LATENT_ENTROPY_PLUGIN) && !defined(__CHECKER__) #define __latent_entropy __attribute__((latent_entropy)) #endif -#endif /* __CHECKER__ */ /* * calling noreturn functions, __builtin_unreachable() and __builtin_trap() @@ -131,7 +129,7 @@ /* gcc version specific checks */ -#if GCC_VERSION >= 40900 && !defined(__CHECKER__) +#if GCC_VERSION >= 40900 /* * __assume_aligned(n, k): Tell the optimizer that the returned * pointer can be assumed to be k modulo n. The second argument is diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 165b1d5683ed..4030a2940d6b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -357,11 +357,7 @@ 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 */ diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index f182f2ef3227..65b10b1e2a59 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -217,7 +217,7 @@ struct ftrace_likely_data { #define __must_check #endif -#if defined(CC_USING_HOTPATCH) && !defined(__CHECKER__) +#if defined(CC_USING_HOTPATCH) #define notrace __attribute__((hotpatch(0, 0))) #else #define notrace __attribute__((__no_instrument_function__)) From patchwork Mon Sep 3 20:33:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7890C139B for ; Mon, 3 Sep 2018 20:34:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69BCA2931D for ; Mon, 3 Sep 2018 20:34:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DD9129323; Mon, 3 Sep 2018 20:34:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 004CD2931D for ; Mon, 3 Sep 2018 20:34:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727702AbeIDA4S (ORCPT ); Mon, 3 Sep 2018 20:56:18 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:46401 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728627AbeIDAzu (ORCPT ); Mon, 3 Sep 2018 20:55:50 -0400 Received: by mail-wr1-f66.google.com with SMTP id a108-v6so1708683wrc.13; Mon, 03 Sep 2018 13:33:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tyByUs7kt2t4Ku+/20W32lHPeOdyJrtaUHJ/yr5hQMo=; b=ZYL5GRvgiZuVpzeQoLjNVuo3SjZV4wiqwKjt72UxEy3/CI/NThuoHZebRsr69Yx51C geaZaii6XxeV7jF19TTSrSiFGRDMDF11eVFN9IvXgV5G0iwPATAADEuwtn8y+CVk3zSD KWvGL24iLJ82v4DpqvomBRlmO/ocChDBPssYFjC2c7YuKYuAijO4RWOgGk2NxZo5RnG5 dK1K36pyNTon/4LAp4Yd+6vgUHf8U783ALsKkvpo679mXGk+QWgwzx5Nk+25wR4iDw21 6oYRG1ASbKdvrxv9kbQcAvoQip9C4XcS4U0vjPCgFkoHaLO0wy+O2/dRJtibIt2gwyjs Y3iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tyByUs7kt2t4Ku+/20W32lHPeOdyJrtaUHJ/yr5hQMo=; b=A9754KgxfMw3QEhMoyhOhMoj6PJK0Q89fpl4dINHW4LIfa/6DYHPgKu5knKN2KoJLi eLy99Bp8OX/9LCGPTiTudpSEMl/xjALFEqZtnnHzLZXKXeZuK8NjMW2g7c3Am5uj52fy tXsOELJiAB7Ki+GhVagthKBmXSTXE8PM/s67fcwvejbLh/q41Osay1R+Lk0k4GyJglRm Hn9B2RpEbI3lSg4rQu+NXd/vb6l5Bk5voKlS8vhxaU6XlTZJ0HuzFj73H6Gt5Kq6ztvF bLkpukhITbsrCFCwsvyIKk/mF8EpCg1LciXsgr7pmSHFjUSrUjqOkV3JFQZcmSKOW5qh dwrw== X-Gm-Message-State: APzg51DQYwh9vjbhDOCOnH42py49uhRgy0/wkxzPXOl0NBgHhFBMXRJj GLqQbfRO4j4uv64eqaV+Tik= X-Google-Smtp-Source: ANB0VdZeBaJtJEPL6a3LpSD3Q2x8NhsIMTZ8asPCyF11kwWL8GCJ3APMy3Z7rwdjFb+JhtFrwG/Ang== X-Received: by 2002:adf:f0c8:: with SMTP id x8-v6mr587292wro.49.1536006838204; Mon, 03 Sep 2018 13:33:58 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:57 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , Nick Desaulniers , linux-sparse@vger.kernel.org Subject: [PATCH 08/12] Compiler Attributes: add missing SPDX ID in compiler_types.h Date: Mon, 3 Sep 2018 22:33:12 +0200 Message-Id: <20180903203316.16183-9-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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 Cc: linux-sparse@vger.kernel.org Signed-off-by: Miguel Ojeda --- include/linux/compiler_types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 65b10b1e2a59..0cb40df59418 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ #ifndef __LINUX_COMPILER_TYPES_H #define __LINUX_COMPILER_TYPES_H From patchwork Mon Sep 3 20:33:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1320112B for ; Mon, 3 Sep 2018 20:34:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFC5A2931D for ; Mon, 3 Sep 2018 20:34:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A32B029323; Mon, 3 Sep 2018 20:34:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3FF392931D for ; Mon, 3 Sep 2018 20:34:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729079AbeIDAzy (ORCPT ); Mon, 3 Sep 2018 20:55:54 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:40268 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727850AbeIDAzx (ORCPT ); Mon, 3 Sep 2018 20:55:53 -0400 Received: by mail-wm0-f66.google.com with SMTP id 207-v6so2161502wme.5; Mon, 03 Sep 2018 13:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3ar2B314HH9EOET4QKOtTyIzw9U/fFMOeE7Jnv3QIxk=; b=EBqpl+qBVPjZOjbmgY3HWXG2nfbOa9xTjdGFJqOZST5Q9eHqOiadPuQ0Td5TfcV4tn z+DvB9xQYzpv044BRoA5WQjtBMZ5i9+vKha68Y6Oz6UpqaVV1u64ByLm2BzzFHrs4bJS p/rKaf3WgbF8AsaOAnW+nBcy4nEpJVhV4HvxqxBwenipHrzUy/Ggkrv+yrMdIOOvNvFr 1qksEs4gbXg90xf9To1sKoajcENZ4CBY/zHRWgiRyDiSjcA4SwTjv0T+ci1zyWNnsToe KfErfqqkveBZOzDrWOjwU2KMp2v4sHjULXNx0CXi1VEohYPsCqd3KDnU0lVXm+oQFhbS 0zjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3ar2B314HH9EOET4QKOtTyIzw9U/fFMOeE7Jnv3QIxk=; b=mPf+GYSPrJ+/sLrrlUG5pLKlHzQRO51kuL8KNbX0I+lQKJTUwaUNw16diVr+O5esZN iEF9s6XnoKeZS/Bzorhm2neM47dtYb5eFlKwmH8XzZErJUqBfrcJH3S2KBqdqL6ZF1Nl UkyaI0Sai0fnOxxxe+MvDMP00zdtJvKMbbRWKl0dSJmDgcXKfahW1s3YFGyYxZVHBDZH ymFJSY0Mx++S1lutIRvukM3aVpAUp4q9Lp/wXTI4Ach7bziQbPR2af/XlkGpi7b3vgOw 3mNSNzkBHmU145y86dzdbS1d/towzA5icqf7EW8S0+7HbdkQAdBKBxrECXZG/FmBKLiq +TVw== X-Gm-Message-State: APzg51CgcZPKvUzmR/3g2FG7mffdnN6cBNpQMUGfeQjOrgQFobZBZhjl tZUSCn6F7UHY/UtJgrRlTew= X-Google-Smtp-Source: ANB0VdbQYrFn2N/zhkUmXMQMw3+HmIpcf26zvqWbDg2uO+qj0QK+dpD5yQ78xeRGW8IQ40BkeyfpuA== X-Received: by 2002:a1c:ac07:: with SMTP id v7-v6mr619640wme.110.1536006839731; Mon, 03 Sep 2018 13:33:59 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:33:59 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , Nick Desaulniers , linux-sparse@vger.kernel.org Subject: [PATCH 09/12] Compiler Attributes: use feature checks instead of version checks Date: Mon, 3 Sep 2018 22:33:13 +0200 Message-Id: <20180903203316.16183-10-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Instead of using version checks per-compiler to define (or not) each attribute, use __has_attribute to test for them, following the cleanup started with commit 815f0ddb346c ("include/linux/compiler*.h: make compiler-*.h mutually exclusive"), which is supported on gcc >= 5, clang >= 2.9 and icc >= 17. In the meantime, to support 4.6 <= gcc < 5, we implement __has_attribute by hand. All the attributes that can be unconditionally defined and directly map to compiler attribute(s) (even if optional) have been moved to a new file include/linux/compiler_attributes.h In an effort to make the file as regular as possible, comments stating the purpose of attributes have been removed. Instead, links to the compiler docs have been added (i.e. to gcc and, if available, to clang as well). In addition, they have been sorted. Finally, if an attribute is optional (i.e. if it is guarded by __has_attribute), the reason has been stated for future reference. Cc: Rasmus Villemoes 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 Cc: linux-sparse@vger.kernel.org Reviewed-by: Luc Van Oostenryck Signed-off-by: Miguel Ojeda --- include/linux/compiler-clang.h | 4 - include/linux/compiler-gcc.h | 51 ------ include/linux/compiler-intel.h | 6 - include/linux/compiler_attributes.h | 239 ++++++++++++++++++++++++++++ include/linux/compiler_types.h | 69 +------- 5 files changed, 245 insertions(+), 124 deletions(-) create mode 100644 include/linux/compiler_attributes.h diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h index fa9532f8d885..3e7dafb3ea80 100644 --- a/include/linux/compiler-clang.h +++ b/include/linux/compiler-clang.h @@ -21,8 +21,6 @@ #define __SANITIZE_ADDRESS__ #endif -#define __no_sanitize_address __attribute__((__no_sanitize__("address"))) - /* * Not all versions of clang implement the the type-generic versions * of the builtin overflow checkers. Fortunately, clang implements @@ -41,5 +39,3 @@ * compilers, like ICC. */ #define barrier() __asm__ __volatile__("" : : : "memory") -#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 1ca6a51cfaa9..cfac027e1625 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -108,9 +108,6 @@ __builtin_unreachable(); \ } while (0) -/* Mark a function definition as prohibited from being cloned. */ -#define __noclone __attribute__((__noclone__, __optimize__("no-tracer"))) - #if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__) #define __randomize_layout __attribute__((randomize_layout)) #define __no_randomize_layout __attribute__((no_randomize_layout)) @@ -119,32 +116,6 @@ #define randomized_struct_fields_end } __randomize_layout; #endif -/* - * When used with Link Time Optimization, gcc can optimize away C functions or - * variables which are referenced only from assembly code. __visible tells the - * optimizer that something else uses this function or variable, thus preventing - * this. - */ -#define __visible __attribute__((__externally_visible__)) - -/* gcc version specific checks */ - -#if GCC_VERSION >= 40900 -/* - * __assume_aligned(n, k): Tell the optimizer that the returned - * pointer can be assumed to be k modulo n. The second argument is - * optional (default 0), so we use a variadic macro to make the - * shorthand. - * - * Beware: Do not apply this to functions which may return - * ERR_PTRs. Also, it is probably unwise to apply it to functions - * returning extra information in the low bits (but in that case the - * compiler should see some alignment anyway, when the return value is - * massaged by 'flags = ptr & 3; ptr &= ~3;'). - */ -#define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__))) -#endif - /* * GCC 'asm goto' miscompiles certain code sequences: * @@ -176,32 +147,10 @@ #define KASAN_ABI_VERSION 3 #endif -#if GCC_VERSION >= 40902 -/* - * Tell the compiler that address safety instrumentation (KASAN) - * should not be applied to that function. - * Conflicts with inlining: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67368 - */ -#define __no_sanitize_address __attribute__((__no_sanitize_address__)) -#endif - #if GCC_VERSION >= 50100 -/* - * Mark structures as requiring designated initializers. - * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html - */ -#define __designated_init __attribute__((__designated_init__)) #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 #endif -#if !defined(__noclone) -#define __noclone /* not needed */ -#endif - -#if !defined(__no_sanitize_address) -#define __no_sanitize_address -#endif - /* * Turn individual warnings and errors on and off locally, depending * on version. diff --git a/include/linux/compiler-intel.h b/include/linux/compiler-intel.h index 6004b4588bd4..517bd14e1222 100644 --- a/include/linux/compiler-intel.h +++ b/include/linux/compiler-intel.h @@ -34,9 +34,3 @@ /* icc has this, but it's called _bswap16 */ #define __HAVE_BUILTIN_BSWAP16__ #define __builtin_bswap16 _bswap16 - -/* The following are for compatibility with GCC, from compiler-gcc.h, - * and may be redefined here because they should not be shared with other - * compilers, like clang. - */ -#define __visible __attribute__((__externally_visible__)) diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h new file mode 100644 index 000000000000..ac7bf47ee9cd --- /dev/null +++ b/include/linux/compiler_attributes.h @@ -0,0 +1,239 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_COMPILER_ATTRIBUTES_H +#define __LINUX_COMPILER_ATTRIBUTES_H + +/* + * The attributes in this file are unconditionally defined and they directly + * map to compiler attribute(s) -- except those that are optional. + * + * Any other "attributes" (i.e. those that depend on a configuration option, + * on a compiler, on an architecture, on plugins, on other attributes...) + * should be defined elsewhere (e.g. compiler_types.h or compiler-*.h). + * + * This file is meant to be sorted (by actual attribute name, + * not by #define identifier). Use the __attribute__((__name__)) syntax + * (i.e. with underscores) to avoid future collisions with other macros. + * If an attribute is optional, state the reason in the comment. + */ + +/* + * To check for optional attributes, we use __has_attribute, which is supported + * on gcc >= 5, clang >= 2.9 and icc >= 17. In the meantime, to support + * 4.6 <= gcc < 5, we implement __has_attribute by hand. + * + * sparse does not support __has_attribute (yet) and defines __GNUC_MINOR__ + * depending on the compiler used to build it; however, these attributes have + * no semantic effects for sparse, so it does not matter. Also note that, + * in order to avoid sparse's warnings, even the unsupported ones must be + * defined to 0. + */ +#ifndef __has_attribute +# define __has_attribute(x) __GCC4_has_attribute_##x +# define __GCC4_has_attribute___assume_aligned__ (__GNUC_MINOR__ >= 9) +# define __GCC4_has_attribute___designated_init__ 0 +# define __GCC4_has_attribute___externally_visible__ 1 +# define __GCC4_has_attribute___noclone__ 1 +# define __GCC4_has_attribute___optimize__ 1 +# define __GCC4_has_attribute___no_sanitize_address__ (__GNUC_MINOR__ >= 8) +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute + */ +#define __alias(symbol) __attribute__((__alias__(#symbol))) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-aligned-variable-attribute + */ +#define __aligned(x) __attribute__((__aligned__(x))) +#define __aligned_largest __attribute__((__aligned__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute + * clang: mentioned + */ +#define __always_inline inline __attribute__((__always_inline__)) + +/* + * The second argument is optional (default 0), so we use a variadic macro + * to make the shorthand. + * + * Beware: Do not apply this to functions which may return + * ERR_PTRs. Also, it is probably unwise to apply it to functions + * returning extra information in the low bits (but in that case the + * compiler should see some alignment anyway, when the return value is + * massaged by 'flags = ptr & 3; ptr &= ~3;'). + * + * Optional: only supported since gcc >= 4.9 + * Optional: not supported by icc + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-assume_005faligned-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#assume-aligned + */ +#if __has_attribute(__assume_aligned__) +# define __assume_aligned(a, ...) __attribute__((__assume_aligned__(a, ## __VA_ARGS__))) +#else +# define __assume_aligned(a, ...) +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-cold-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#index-cold-label-attribute + */ +#define __cold __attribute__((__cold__)) + +/* + * Note the long name. + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute + */ +#define __attribute_const__ __attribute__((__const__)) + +/* + * Don't. Just don't. See commit 771c035372a0 ("deprecate the '__deprecated' + * attribute warnings entirely and for good") for more information. + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-deprecated-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-deprecated-type-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-deprecated-variable-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html#index-deprecated-enumerator-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#deprecated + */ +#define __deprecated + +/* + * Optional: only supported since gcc >= 5.1 + * Optional: not supported by clang + * Optional: not supported by icc + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-designated_005finit-type-attribute + */ +#if __has_attribute(__designated_init__) +# define __designated_init __attribute__((__designated_init__)) +#else +# define __designated_init +#endif + +/* + * Optional: not supported by clang + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-externally_005fvisible-function-attribute + */ +#if __has_attribute(__externally_visible__) +# define __visible __attribute__((__externally_visible__)) +#else +# define __visible +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-format-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#format + */ +#define __printf(a, b) __attribute__((__format__(printf, a, b))) +#define __scanf(a, b) __attribute__((__format__(scanf, a, b))) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-gnu_005finline-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#gnu-inline + */ +#define __gnu_inline __attribute__((__gnu_inline__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute + */ +#define __malloc __attribute__((__malloc__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-mode-type-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-mode-variable-attribute + */ +#define __mode(x) __attribute__((__mode__(x))) + +/* + * Optional: not supported by clang + * Note: icc does not recognize gcc's no-tracer + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noclone-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-optimize-function-attribute + */ +#if __has_attribute(__noclone__) +# if __has_attribute(__optimize__) +# define __noclone __attribute__((__noclone__, __optimize__("no-tracer"))) +# else +# define __noclone __attribute__((__noclone__)) +# endif +#else +# define __noclone +#endif + +/* + * Note the missing underscores. + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute + * clang: mentioned + */ +#define noinline __attribute__((__noinline__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn + * clang: https://clang.llvm.org/docs/AttributeReference.html#id1 + */ +#define __noreturn __attribute__((__noreturn__)) + +/* + * Optional: only supported since gcc >= 4.8 + * Optional: not supported by icc + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fsanitize_005faddress-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#no-sanitize-address-no-address-safety-analysis + */ +#if __has_attribute(__no_sanitize_address__) +# define __no_sanitize_address __attribute__((__no_sanitize_address__)) +#else +# define __no_sanitize_address +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-packed-type-attribute + * clang: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-packed-variable-attribute + */ +#define __packed __attribute__((__packed__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute + */ +#define __pure __attribute__((__pure__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-section-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-section-variable-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#section-declspec-allocate + */ +#define __section(S) __attribute__((__section__(#S))) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-unused-type-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#index-unused-label-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#maybe-unused-unused + */ +#define __always_unused __attribute__((__unused__)) +#define __maybe_unused __attribute__((__unused__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-used-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute + */ +#define __used __attribute__((__used__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute + */ +#define __weak __attribute__((__weak__)) + +#endif /* __LINUX_COMPILER_ATTRIBUTES_H */ diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 0cb40df59418..0919865473d1 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -55,6 +55,9 @@ extern void __chk_io_ptr(const volatile void __iomem *); #ifdef __KERNEL__ +/* Attributes */ +#include + /* Compiler specific macros. */ #ifdef __clang__ #include @@ -79,12 +82,6 @@ extern void __chk_io_ptr(const volatile void __iomem *); #include #endif -/* - * Generic compiler-independent macros required for kernel - * build go below this comment. Actual compiler/compiler version - * specific implementations come from the above header files - */ - struct ftrace_branch_data { const char *func; const char *file; @@ -107,9 +104,6 @@ struct ftrace_likely_data { unsigned long constant; }; -/* Don't. Just don't. */ -#define __deprecated - #endif /* __KERNEL__ */ #endif /* __ASSEMBLY__ */ @@ -119,10 +113,6 @@ struct ftrace_likely_data { * compilers. We don't consider that to be an error, so set them to nothing. * For example, some of them are for compiler specific plugins. */ -#ifndef __designated_init -# define __designated_init -#endif - #ifndef __latent_entropy # define __latent_entropy #endif @@ -140,17 +130,6 @@ struct ftrace_likely_data { # define randomized_struct_fields_end #endif -#ifndef __visible -#define __visible -#endif - -/* - * Assume alignment of return value. - */ -#ifndef __assume_aligned -#define __assume_aligned(a, ...) -#endif - /* Are two types/vars the same type (ignoring qualifiers)? */ #define __same_type(a, b) __builtin_types_compatible_p(typeof(a), typeof(b)) @@ -159,10 +138,6 @@ struct ftrace_likely_data { (sizeof(t) == sizeof(char) || sizeof(t) == sizeof(short) || \ sizeof(t) == sizeof(int) || sizeof(t) == sizeof(long)) -#ifndef __noclone -#define __noclone -#endif - /* Helpers for emitting diagnostics in pragmas. */ #ifndef __diag #define __diag(string) @@ -182,36 +157,6 @@ struct ftrace_likely_data { #define __diag_error(compiler, version, option, comment) \ __diag_ ## compiler(version, error, option) -/* - * From the GCC manual: - * - * Many functions have no effects except the return value and their - * return value depends only on the parameters and/or global - * variables. Such a function can be subject to common subexpression - * elimination and loop optimization just as an arithmetic operator - * would be. - * [...] - */ -#define __pure __attribute__((__pure__)) -#define __attribute_const__ __attribute__((__const__)) -#define __aligned(x) __attribute__((__aligned__(x))) -#define __aligned_largest __attribute__((__aligned__)) -#define __printf(a, b) __attribute__((__format__(printf, a, b))) -#define __scanf(a, b) __attribute__((__format__(scanf, a, b))) -#define __maybe_unused __attribute__((__unused__)) -#define __always_unused __attribute__((__unused__)) -#define __mode(x) __attribute__((__mode__(x))) -#define __malloc __attribute__((__malloc__)) -#define __used __attribute__((__used__)) -#define __noreturn __attribute__((__noreturn__)) -#define __packed __attribute__((__packed__)) -#define __weak __attribute__((__weak__)) -#define __alias(symbol) __attribute__((__alias__(#symbol))) -#define __cold __attribute__((__cold__)) -#define __section(S) __attribute__((__section__(#S))) -#define __gnu_inline __attribute__((__gnu_inline__)) -#define __always_inline inline __attribute__((__always_inline__)) - #ifdef CONFIG_ENABLE_MUST_CHECK #define __must_check __attribute__((__warn_unused_result__)) #else @@ -248,15 +193,13 @@ struct ftrace_likely_data { */ #if !defined(CONFIG_ARCH_SUPPORTS_OPTIMIZED_INLINING) || \ !defined(CONFIG_OPTIMIZE_INLINING) -#define inline \ - inline __attribute__((__always_inline__, __unused__)) notrace __gnu_inline +#define inline __always_inline __gnu_inline __maybe_unused notrace #else -#define inline inline __attribute__((__unused__)) notrace __gnu_inline +#define inline inline __gnu_inline __maybe_unused notrace #endif #define __inline__ inline -#define __inline inline -#define noinline __attribute__((__noinline__)) +#define __inline inline /* * Rather then using noinline to prevent stack consumption, use From patchwork Mon Sep 3 20:33:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586371 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8D22112B for ; Mon, 3 Sep 2018 20:34:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D950A2931D for ; Mon, 3 Sep 2018 20:34:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDA7E29323; Mon, 3 Sep 2018 20:34:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 610622931D for ; Mon, 3 Sep 2018 20:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729080AbeIDAzy (ORCPT ); Mon, 3 Sep 2018 20:55:54 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37418 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729079AbeIDAzx (ORCPT ); Mon, 3 Sep 2018 20:55:53 -0400 Received: by mail-wr1-f66.google.com with SMTP id u12-v6so1763502wrr.4; Mon, 03 Sep 2018 13:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VqRqOGZ4G4JNA6fITKU0kaGxJLv/GQRGqVshL6cqUnI=; b=A7dAQwnOCtPnkh9wwQe3CpCyq8Vs+lmQREw47ahv3vjNKPZCzSzuEv1bmKssLspqno xd4JSpFb0Kzi+X2VofhHKHk1Bc+9BxqOGbCwbik19Ijzht7lCahBpRpMXBlq5fh/mZDP ENzi9nJ5I+Q+Sdg0Jn/qBect0qWfaW2QJMO957rU6GdfTJ+KL5a/MB4gQEYYSdVY9Tvw UkqX5C5WM3A7/tW+X7WkKenwrI42a/z2wqpyNa25SYrZQUbneR5P3HBx2LRc3YheROYx pZovZDT+B+bsEyK7N0bZvGQLhlAyJY3OB4VxGbGJ89pD3oPkI7pWrc6/vi3LnZmccNxw oeyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VqRqOGZ4G4JNA6fITKU0kaGxJLv/GQRGqVshL6cqUnI=; b=XfSzBrjSEVyC0283rtEM8jn+EayBtP4JueDxfPQzM+xlANw7GUFchIpo/TcBk4RLCm w5+F41nY0oq9aocfGKhmaT1QGA52Q83J2V+H+rSr05grsEYaA3Lzn6m/T5Cn0jJI5Ahx 8/cQmltTTFIgrlTKf7PKcHx3fhXUlUJr18m+ziB7HXETT9Ek0Nd/832vwFg+Sb44js8g i2fzvloHN2yhZdPhrQCM1RRRYAtFqiSG5E1CiohmHSMEIXrWKV90y/gzUr1JHN+39uN5 poUUDIoZI2CDqimy38XpjB1+0b0O0HOjnbGO36z5PU75MTGSdv9aJl6/KVjSJpMXLi6O NZyw== X-Gm-Message-State: APzg51CNis6lWyC3sus+87Kz4UjAV4cEwj2KlpN2eBpOz6QYYj1mW24W KXcx8c/o6m/kg6Mn+Tm9dac= X-Google-Smtp-Source: ANB0VdaC2O2j/3WXWW4ExhS5xM025jXAMQa2R1YofjjnG+XZNzIOGXTxPbz4srbFstTmzJvXCbWyJw== X-Received: by 2002:a5d:4684:: with SMTP id u4-v6mr21062416wrq.76.1536006841130; Mon, 03 Sep 2018 13:34:01 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.33.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:34:00 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , Nick Desaulniers , linux-sparse@vger.kernel.org Subject: [PATCH 10/12] Compiler Attributes: KENTRY used twice the "used" attribute Date: Mon, 3 Sep 2018 22:33:14 +0200 Message-Id: <20180903203316.16183-11-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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 Cc: linux-sparse@vger.kernel.org Signed-off-by: Miguel Ojeda Reviewed-by: Nick Desaulniers --- include/linux/compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 4030a2940d6b..17ee9165ca51 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -146,7 +146,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, extern typeof(sym) sym; \ static const unsigned long __kentry_##sym \ __used \ - __attribute__((__section__("___kentry" "+" #sym ), used)) \ + __attribute__((__section__("___kentry" "+" #sym ))) \ = (unsigned long)&sym; #endif From patchwork Mon Sep 3 20:33:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 03694139B for ; Mon, 3 Sep 2018 20:34:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8E602931D for ; Mon, 3 Sep 2018 20:34:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DC80C29323; Mon, 3 Sep 2018 20:34:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EFBD2931D for ; Mon, 3 Sep 2018 20:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729144AbeIDAz5 (ORCPT ); Mon, 3 Sep 2018 20:55:57 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:54361 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727729AbeIDAzz (ORCPT ); Mon, 3 Sep 2018 20:55:55 -0400 Received: by mail-wm0-f68.google.com with SMTP id c14-v6so2243310wmb.4; Mon, 03 Sep 2018 13:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mdM1ZM+LvQmT66Azdcl1HKYOqFIc4f0Rj8Ky6vdAJJc=; b=a5k8Sg3NL9gVL6qR9DyR/MNPb5wKijroR6gXCu52IIlrcvufuK7A7j8+IlvJW6O4wC hkGUanZgx9mHR1a9yB00mM0eYxtlepY3JldlC5N4WRWR23VEPeGnO3+G5OCT7AnP+wDj D+8n7CxUMkRIKojhwyDtSChMhy2ZVQ4IgdmS2WLNihNIsY8HIpCD/aiElZY9VQGjA5FT Y1eTWQ0hYrSlw60n9qQ1VnpqJ8Af7mhvqm7ie8xoB8XEXxBXmaH5o/5C3G79E3qG9qLg ve0+SRIWZMqjwhNyfp6VYCEdWvc5qXKj6eFhwkP2T9hhXdgTnUs2tVn3sRe4+rhdgU5N 1t4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mdM1ZM+LvQmT66Azdcl1HKYOqFIc4f0Rj8Ky6vdAJJc=; b=Lyvjn7vv9lNL7rQWdDlpRAUIB76CZ4PoMEb4cUeqsoEgELZv6pI/MwlMGv1b88fZq/ NIXFj6hueWHN2LzYtJrWmJbd9gtjZbuyg5tQAlJ4b4/ysRal+MQOVF8f4Ri2P71ftAwR JerVSZiLJeOdCAs+4Y8rI4Ou2wTFotk+ShVqD3FR7iczWtgK3XpAngDapnwC6R3UfT2F 3IWYLhD6Xmydkl6Crxl9UbqJXXbcEBgwyCfza51Po5g16I3DbHHxRAy7o4DkCTQRKgcl XhaGvbk8FkdZniWop1Bje82ZkAOWKCcdSiVs1Mf9YBPB/0N+nnl+T2dUQWeBfx3UqsVQ 4mRQ== X-Gm-Message-State: APzg51C/gM2E+E9OJjPMjzgjrWS3/BRuRGZa5Yf1ibkTeQ9iXG8KP2kD hrVYwCRkE23sgqu7r8Bajso= X-Google-Smtp-Source: ANB0VdYQOusjGWqdO+RUCjkTOc3AjU3nRbCt9zeYkHAtXwre0E0u176DUy2T2S/o6sqhgkfSvH9x1Q== X-Received: by 2002:a1c:4887:: with SMTP id v129-v6mr5839130wma.129.1536006842732; Mon, 03 Sep 2018 13:34:02 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.34.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:34:02 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , linux-sparse@vger.kernel.org Subject: [PATCH 11/12] Compiler Attributes: remove uses of __attribute__ from compiler.h Date: Mon, 3 Sep 2018 22:33:15 +0200 Message-Id: <20180903203316.16183-12-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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: Linus Torvalds Cc: linux-sparse@vger.kernel.org Suggested-by: Nick Desaulniers Reviewed-by: Nick Desaulniers Signed-off-by: Miguel Ojeda --- include/linux/compiler.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 17ee9165ca51..b5fb034fa6fa 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -23,8 +23,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, #define __branch_check__(x, expect, is_constant) ({ \ long ______r; \ static struct ftrace_likely_data \ - __attribute__((__aligned__(4))) \ - __attribute__((__section__("_ftrace_annotated_branch"))) \ + __aligned(4) \ + __section("_ftrace_annotated_branch") \ ______f = { \ .data.func = __func__, \ .data.file = __FILE__, \ @@ -59,8 +59,8 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, ({ \ int ______r; \ static struct ftrace_branch_data \ - __attribute__((__aligned__(4))) \ - __attribute__((__section__("_ftrace_branch"))) \ + __aligned(4) \ + __section("_ftrace_branch") \ ______f = { \ .func = __func__, \ .file = __FILE__, \ @@ -146,7 +146,7 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, extern typeof(sym) sym; \ static const unsigned long __kentry_##sym \ __used \ - __attribute__((__section__("___kentry" "+" #sym ))) \ + __section("___kentry" "+" #sym ) \ = (unsigned long)&sym; #endif @@ -287,7 +287,7 @@ unsigned long read_word_at_a_time(const void *addr) * visible to the compiler. */ #define __ADDRESSABLE(sym) \ - static void * __attribute__((__section__(".discard.addressable"), used)) \ + static void * __section(".discard.addressable") __used \ __PASTE(__addressable_##sym, __LINE__) = (void *)&sym; /** From patchwork Mon Sep 3 20:33:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 10586365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EB9DC139B for ; Mon, 3 Sep 2018 20:34:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD2AF2931D for ; Mon, 3 Sep 2018 20:34:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0DE129323; Mon, 3 Sep 2018 20:34:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E16672931D for ; Mon, 3 Sep 2018 20:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729172AbeIDAz6 (ORCPT ); Mon, 3 Sep 2018 20:55:58 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:33207 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727784AbeIDAz5 (ORCPT ); Mon, 3 Sep 2018 20:55:57 -0400 Received: by mail-wm0-f65.google.com with SMTP id r1-v6so7523335wmh.0; Mon, 03 Sep 2018 13:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=znhKATxSpbkpApPLKvpo/RP4a7pgZj+EIzOmJtisvm4=; b=G3fGzuJ8YAXjLEgorIVa9LBuBMxP2AmACUEmpXHr0Mqnx5H2P1f33bsFU1ybS0lOO6 O7+9jJ4Z7dJswrHEowKjhOcQTo+BLcCmsYDjOxVttJ+BckBlS2T+70ppRKepIIVNdqNi Pwv79Jk1uTaroUYgt6zECHd0Gx0fQOEG9sPPbOTnqvH5nLGZRbTq0UIOnlVxPbWFtETT iSYEmXBROtc1nUFXKFEih3n+DVI8XsjUMM/uLvCtbwqy5+63sQRFFCeIDAGSHhRLFm1w ndMvVMqiF/5iLo28uZMs8Iz3lOpGeBLODyND76efpcjWailAsYvlovXTDznxtgWcIc4D XJ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=znhKATxSpbkpApPLKvpo/RP4a7pgZj+EIzOmJtisvm4=; b=IOqZAO9FMuWz4PKMWqifW9xPtGjgALWmbMX5EaOgklTIWwKtxi2n7tcDC2xwxeyN8M P8fb/HmD5fP2+aobs67GLePDuWjJEmzXKjqJA8aZlYdK887tTP9z6NqFQDFyz2TpWH5N NyZkTLhxMKtlRxjthfvpOJ1vSlA07PMr6FpMvrE+zN9Kt99//Lm3bxwcJ1mpvHNzxsgD TNRUlIUZ2+hdM+udVZHQ0kcF0pYnZ1TYTkQJUVmyuaLIar31MvjHb+LGcm/TJTPV2sDL 0tsx5j4H7oR/m2k0qIJegGk2omLeECPkJiTRCPkG3xxOFNQTvWh8ZGehxeuwLCotHH6u CN5w== X-Gm-Message-State: APzg51D8WavOw1j3tnB0SvmRc6JFhI2csEsF4TPlyWtSyjOirgTZqyum 1J5iIp77VALoKumxFxeCBwu1X6fuHIc= X-Google-Smtp-Source: ANB0VdaNuTgx+ecVabi+TjVYZ6aXQsJrRDw08xQeVKWcudJG4q4jgYmVtaln+97uR+FQX99cZVHD4g== X-Received: by 2002:a1c:230f:: with SMTP id j15-v6mr629820wmj.124.1536006844302; Mon, 03 Sep 2018 13:34:04 -0700 (PDT) Received: from localhost.localdomain (62.83.35.8.dyn.user.ono.com. [62.83.35.8]) by smtp.gmail.com with ESMTPSA id 132-v6sm12354870wmd.13.2018.09.03.13.34.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Sep 2018 13:34:03 -0700 (PDT) From: Miguel Ojeda To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, Miguel Ojeda , Jonathan Corbet , Rasmus Villemoes , Luc Van Oostenryck , Eli Friedman , Christopher Li , Kees Cook , Ingo Molnar , Geert Uytterhoeven , Arnd Bergmann , Greg Kroah-Hartman , Masahiro Yamada , Joe Perches , Dominique Martinet , Nick Desaulniers , linux-sparse@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH 12/12] Compiler Attributes: add Doc/process/programming-language.rst Date: Mon, 3 Sep 2018 22:33:16 +0200 Message-Id: <20180903203316.16183-13-miguel.ojeda.sandonis@gmail.com> In-Reply-To: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> References: <20180903203316.16183-1-miguel.ojeda.sandonis@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cc: Jonathan Corbet Cc: Rasmus Villemoes Cc: Luc Van Oostenryck 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 Cc: linux-sparse@vger.kernel.org Cc: linux-doc@vger.kernel.org Signed-off-by: Miguel Ojeda --- Documentation/process/index.rst | 1 + .../process/programming-language.rst | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Documentation/process/programming-language.rst diff --git a/Documentation/process/index.rst b/Documentation/process/index.rst index 37bd0628b6ee..c56f24a22d2a 100644 --- a/Documentation/process/index.rst +++ b/Documentation/process/index.rst @@ -23,6 +23,7 @@ Below are the essential guides that every developer should read. code-of-conflict development-process submitting-patches + programming-language coding-style maintainer-pgp-guide email-clients diff --git a/Documentation/process/programming-language.rst b/Documentation/process/programming-language.rst new file mode 100644 index 000000000000..674f28ae7f73 --- /dev/null +++ b/Documentation/process/programming-language.rst @@ -0,0 +1,44 @@ +.. _programming_language: + +Programming Language +==================== + +The kernel is written in the C programming language [c-language]_. +More precisely, the kernel is typically compiled with ``gcc`` [gcc]_ +under ``-std=gnu89`` [gcc-c-dialect-options]_: the GNU dialect of ISO C90 +(including some C99 features). + +This dialect contains many extensions to the language [gnu-extensions]_, +and many of them are used within the kernel as a matter of course. + +There is some support for compiling the kernel with ``clang`` [clang]_ +and ``icc`` [icc]_ for several of the architectures, although at the time +of writing it is not completed, requiring third-party patches. + +Attributes +---------- + +One of the common extensions used throughout the kernel are attributes +[gcc-attribute-syntax]_. Attributes allow to introduce +implementation-defined semantics to language entities (like variables, +functions or types) without having to make significant syntactic changes +to the language (e.g. adding a new keyword) [n2049]_. + +In some cases, attributes are optional (i.e. a compiler not supporting them +should still produce proper code, even if it is slower or does not perform +as many compile-time checks/diagnostics). + +The kernel defines pseudo-keywords (e.g. ``__pure``) instead of using +directly the GNU attribute syntax (e.g. ``__attribute__((pure))``). + +Please refer to ``include/linux/compiler_attributes.h`` for more information. + +.. [c-language] http://www.open-std.org/jtc1/sc22/wg14/www/standards +.. [gcc] https://gcc.gnu.org +.. [clang] https://clang.llvm.org +.. [icc] https://software.intel.com/en-us/c-compilers +.. [gcc-c-dialect-options] https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html +.. [gnu-extensions] https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html +.. [gcc-attribute-syntax] https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html +.. [n2049] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2049.pdf +