From: Randy Dunlap <rdunlap@infradead.org>
To: Nathan Chancellor <natechancellor@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH v2] x86/pgtable: Always inline p4d_index
Date: Wed, 16 Jan 2019 09:12:12 -0800 [thread overview]
Message-ID: <a6cbf31b-b0f8-5787-61be-86b22b6b8d98@infradead.org> (raw)
In-Reply-To: <20190116134158.344-1-natechancellor@gmail.com>
On 1/16/19 5:41 AM, Nathan Chancellor wrote:
> When building an allyesconfig build with Clang, the kernel fails to link
> arch/x86/platform/efi/efi_64.o because of a failed BUILD_BUG_ON:
>
> ld: arch/x86/platform/efi/efi_64.o: in function `efi_sync_low_kernel_mappings':
> (.text+0x8e5): undefined reference to `__compiletime_assert_277'
>
> Since there are several BUILD_BUG_ONs in efi_64.c, I isolated it down to
> the following:
>
> BUILD_BUG_ON(p4d_index(EFI_VA_END) != p4d_index(MODULES_END));
>
> After some research, it turns out that there is a new config option
> called NO_AUTO_INLINE, which adds '-fno-inline-functions' to
> KBUILD_CFLAGS so that the compiler does not auto inline small functions,
> which causes this BUILD_BUG_ON to fail because p4d_index is no longer an
> integer constant expression.
>
> According to the help text of the config, functions explicitly marked
> inline should still be inlined. As it turns out, GCC and Clang both
> support '-fno-inline-functions' but Clang only inlines functions when
> they are marked with an always inline annotation[1].
>
> Since it's expected that p4d_index should always be inlined so that its
> value can be evaluated at build time, mark it as __always_inline.
>
> [1]: https://github.com/llvm/llvm-project/blob/84cecfcb3db7/clang/lib/Frontend/CompilerInvocation.cpp#L638-L657
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/256
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Hi,
I see the same build error when using gcc 4.8.5 (SUSE Linux).
This patch fixes that build error.
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Thanks.
> ---
>
> v1 -> v2:
>
> * Add Nick's Reviewed-by tag.
>
> * Update the GitHub URL to use the official LLVM repository and pin to a
> SHA so that it is always valid, as suggested by Nick.
>
> arch/x86/include/asm/pgtable.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
> index 40616e805292..f78e53382498 100644
> --- a/arch/x86/include/asm/pgtable.h
> +++ b/arch/x86/include/asm/pgtable.h
> @@ -918,7 +918,7 @@ static inline int p4d_bad(p4d_t p4d)
> }
> #endif /* CONFIG_PGTABLE_LEVELS > 3 */
>
> -static inline unsigned long p4d_index(unsigned long address)
> +static __always_inline unsigned long p4d_index(unsigned long address)
> {
> return (address >> P4D_SHIFT) & (PTRS_PER_P4D - 1);
> }
>
--
~Randy
next prev parent reply other threads:[~2019-01-16 17:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-10 23:45 [PATCH] x86/pgtable: Always inline p4d_index Nathan Chancellor
2018-12-11 23:08 ` Nick Desaulniers
2019-01-16 13:41 ` [PATCH v2] " Nathan Chancellor
2019-01-16 17:12 ` Randy Dunlap [this message]
2019-01-16 21:54 ` Thomas Gleixner
2019-01-17 1:01 ` Nathan Chancellor
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=a6cbf31b-b0f8-5787-61be-86b22b6b8d98@infradead.org \
--to=rdunlap@infradead.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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).