linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Laura Abbott <labbott@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
	Martin Sebor <msebor@gcc.gnu.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Andrey Konovalov <andreyknvl@google.com>,
	Kees Cook <keescook@chromium.org>,
	Sean Christopherson <sean.j.christopherson@intel.com>,
	Jessica Yu <jeyu@kernel.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	James Morris <james.morris@microsoft.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Borislav Petkov <bp@suse.de>, Matt Mullins <mmullins@fb.com>,
	Vincent Whitchurch <vincent.whitchurch@axis.com>,
	WANG Chao <chao.wang@ucloud.cn>
Subject: Re: [PATCH 0/3] Clean the new GCC 9 -Wmissing-attributes warnings
Date: Sat, 9 Feb 2019 11:44:09 +0100	[thread overview]
Message-ID: <CAKv+Gu83rXGH5hVdHXM=65zQkc5FtG86xMccT7WByUFy9BmXkQ@mail.gmail.com> (raw)
In-Reply-To: <20190209000840.11018-1-miguel.ojeda.sandonis@gmail.com>

On Sat, 9 Feb 2019 at 01:09, Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> The upcoming GCC 9 release extends the -Wmissing-attributes warnings
> (enabled by -Wall) to C and aliases: it warns when particular function
> attributes are missing in the aliases but not in their target, e.g.:
>
>     void __cold f(void) {}

Apologies if I missed any discussions on this topic, but I would argue
that 'cold' is not an attribute that has to be applied to the function
pointer as well as each of its targets, since it basically decides the
placement in the binary, and it doesn't affect the nature of the code
being referenced.

Permitting a function pointer to point to 'cold' functions only if it
is annotated as 'cold' itself makes no sense whatsoever, and there
could be valid cases where a function pointer may point at either cold
or non-cold functions.

For other attributes, the situation is clearly different, e.g., a
__pure function pointer to a non-pure function is obviously a bug,
since the compiler could make assumptions based on the function
pointer type that do not hold for the function it points to at
runtime.

I don't see how the 'cold' attribute could have any such effect, so I
wonder if it isn't simply a bug that we have to report to GCC?



>     void __alias("f") g(void);
>
> diagnoses:
>
>     warning: 'g' specifies less restrictive attribute than
>     its target 'f': 'cold' [-Wmissing-attributes]
>
> These patch series clean these new warnings. Most of them are caused
> by the module_init/exit macros.
>
> The first patch has been in -next for a long time already, and an alternative
> solution (only __cold) for module.h as well. However, since we decided
> to go with the new __copy attribute, I will leave the series for a few days
> again and send the PR for -rc7.
>
> Link: https://lore.kernel.org/lkml/20190125104353.2791-1-labbott@redhat.com/
>
> Miguel Ojeda (3):
>   lib/crc32.c: mark crc32_le_base/__crc32c_le_base aliases as __pure
>   Compiler Attributes: add support for __copy (gcc >= 9)
>   include/linux/module.h: copy __init/__exit attrs to
>     init/cleanup_module
>
>  include/linux/compiler_attributes.h | 14 ++++++++++++++
>  include/linux/module.h              |  4 ++--
>  lib/crc32.c                         |  4 ++--
>  3 files changed, 18 insertions(+), 4 deletions(-)
>
> --
> 2.17.1
>

  parent reply	other threads:[~2019-02-09 10:44 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-09  0:08 [PATCH 0/3] Clean the new GCC 9 -Wmissing-attributes warnings Miguel Ojeda
2019-02-09  0:08 ` [PATCH 1/3] lib/crc32.c: mark crc32_le_base/__crc32c_le_base aliases as __pure Miguel Ojeda
2019-02-09  0:08 ` [PATCH 2/3] Compiler Attributes: add support for __copy (gcc >= 9) Miguel Ojeda
2019-02-09  0:41   ` Nick Desaulniers
2019-02-09 12:36     ` Miguel Ojeda
2019-02-09  0:08 ` [PATCH 3/3] include/linux/module.h: copy __init/__exit attrs to init/cleanup_module Miguel Ojeda
2019-02-11 15:01   ` Jessica Yu
2019-02-09 10:44 ` Ard Biesheuvel [this message]
2019-02-09 11:19   ` [PATCH 0/3] Clean the new GCC 9 -Wmissing-attributes warnings Miguel Ojeda
2019-02-09 11:25     ` Ard Biesheuvel
2019-02-09 12:31       ` Miguel Ojeda
2019-02-11 16:21         ` Martin Sebor
2019-02-11 18:20           ` Ard Biesheuvel
2019-02-09 20:32 ` Laura Abbott
2019-02-13 17:30   ` Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKv+Gu83rXGH5hVdHXM=65zQkc5FtG86xMccT7WByUFy9BmXkQ@mail.gmail.com' \
    --to=ard.biesheuvel@linaro.org \
    --cc=andreyknvl@google.com \
    --cc=arnd@arndb.de \
    --cc=bp@suse.de \
    --cc=catalin.marinas@arm.com \
    --cc=chao.wang@ucloud.cn \
    --cc=herbert@gondor.apana.org.au \
    --cc=james.morris@microsoft.com \
    --cc=jeyu@kernel.org \
    --cc=keescook@chromium.org \
    --cc=krzk@kernel.org \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=miguel.ojeda.sandonis@gmail.com \
    --cc=mmullins@fb.com \
    --cc=msebor@gcc.gnu.org \
    --cc=ndesaulniers@google.com \
    --cc=sean.j.christopherson@intel.com \
    --cc=vincent.whitchurch@axis.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).