All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rusty Russell <rusty@rustcorp.com.au>
To: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: linux-kernel@vger.kernel.org,
	Paul Gortmaker <paul.gortmaker@windriver.com>
Subject: Re: [PATCH 2/2] modpost: don't emit section mismatch warnings for compiler optimizations
Date: Mon, 20 Apr 2015 11:32:12 +0930	[thread overview]
Message-ID: <87wq17pnff.fsf@rustcorp.com.au> (raw)
In-Reply-To: <1429471248-4641-2-git-send-email-paul.gortmaker@windriver.com>

Paul Gortmaker <paul.gortmaker@windriver.com> writes:
> Currently an allyesconfig build [gcc-4.9.1] can generate the following:
>
>    WARNING: vmlinux.o(.text.unlikely+0x3864): Section mismatch in
>    reference from the function cpumask_empty.constprop.3() to the
>    variable .init.data:nmi_ipi_mask
>
> which comes from the cpumask_empty usage in arch/x86/kernel/nmi_selftest.c.

Thanks for the excellent explanation and patches.

Applied!
Rusty.

>
> Normally we would not see a symbol entry for cpumask_empty since it is:
>
> 	static inline bool cpumask_empty(const struct cpumask *srcp)
>
> however in this case, the variant of the symbol gets emitted when GCC does
> constant propagation optimization.
>
> Fix things up so that any locally optimized constprop variants don't warn
> when accessing variables that live in the __init sections.
>
> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
> ---
>  scripts/mod/modpost.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index b18cecb6bf5a..572f1e4a2626 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -908,6 +908,9 @@ static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
>  static const char *const init_exit_sections[] =
>  	{ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
>  
> +/* all text sections */
> +static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL };
> +
>  /* data section */
>  static const char *const data_sections[] = { DATA_SECTIONS, NULL };
>  
> @@ -926,6 +929,7 @@ static const char *const data_sections[] = { DATA_SECTIONS, NULL };
>  static const char *const head_sections[] = { ".head.text*", NULL };
>  static const char *const linker_symbols[] =
>  	{ "__init_begin", "_sinittext", "_einittext", NULL };
> +static const char *const optim_symbols[] = { "*.constprop.*", NULL };
>  
>  enum mismatch {
>  	TEXT_TO_ANY_INIT,
> @@ -1127,6 +1131,17 @@ static const struct sectioncheck *section_mismatch(
>   *   This pattern is identified by
>   *   refsymname = __init_begin, _sinittext, _einittext
>   *
> + * Pattern 5:
> + *   GCC may optimize static inlines when fed constant arg(s) resulting
> + *   in functions like cpumask_empty() -- generating an associated symbol
> + *   cpumask_empty.constprop.3 that appears in the audit.  If the const that
> + *   is passed in comes from __init, like say nmi_ipi_mask, we get a
> + *   meaningless section warning.  May need to add isra symbols too...
> + *   This pattern is identified by
> + *   tosec   = init section
> + *   fromsec = text section
> + *   refsymname = *.constprop.*
> + *
>   **/
>  static int secref_whitelist(const struct sectioncheck *mismatch,
>  			    const char *fromsec, const char *fromsym,
> @@ -1159,6 +1174,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
>  	if (match(tosym, linker_symbols))
>  		return 0;
>  
> +	/* Check for pattern 5 */
> +	if (match(fromsec, text_sections) &&
> +	    match(tosec, init_sections) &&
> +	    match(fromsym, optim_symbols))
> +		return 0;
> +
>  	return 1;
>  }
>  
> -- 
> 2.2.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

      reply	other threads:[~2015-04-20  2:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-19 19:20 [PATCH 1/2] modpost: expand pattern matching to support substring matches Paul Gortmaker
2015-04-19 19:20 ` [PATCH 2/2] modpost: don't emit section mismatch warnings for compiler optimizations Paul Gortmaker
2015-04-20  2:02   ` Rusty Russell [this message]

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=87wq17pnff.fsf@rustcorp.com.au \
    --to=rusty@rustcorp.com.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul.gortmaker@windriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.