lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmw3cdffW+wMowrs05h-CBhHbuMJ22UFhWMfh6A5Lyxcw@mail.gmail.com>
Date:   Tue, 11 Dec 2018 15:08:51 -0800
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>, mingo@...hat.com,
        bp@...en8.de, hpa@...or.com, x86@...nel.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86/pgtable: Always inline p4d_index

On Mon, Dec 10, 2018 at 3:46 PM Nathan Chancellor
<natechancellor@...il.com> 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-mirror/clang/blob/master/lib/Frontend/CompilerInvocation.cpp#L637-L656

(resending as text-plain; why does gmail silently switch it back to html...)

Just some top secret github-fu: this link is bound to break over time
as the source changes.  While on that page, if you hit `y`, it's
hotkeyed to update the URL to pin it to a SHA.  That is a little more
robust (the branch or even the tree could still disappear, or history
gets rewritten (hopefully not on a master branch, but I've seen it
happen accidentally (Firefox OS))).

This doesn't look like an invasive change to me, though I'm curious
about the usefulness of CONFIG_NO_AUTO_INLINE if the kernel is still
compiled at -O2.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
Thanks for sending!

>
> Link: https://github.com/ClangBuiltLinux/linux/issues/256
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> ---
>  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);
>  }
> --
> 2.20.0
>


-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ