[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y+KCHOkrumS1I/Th@dev-arch.thelio-3990X>
Date: Tue, 7 Feb 2023 09:53:48 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc: kernel test robot <lkp@...el.com>,
Nick Desaulniers <ndesaulniers@...gle.com>,
Tom Rix <trix@...hat.com>, llvm@...ts.linux.dev,
oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for
vgetcpu.
On Tue, Feb 07, 2023 at 11:46:33AM +0100, Sebastian Andrzej Siewior wrote:
> The 64bit register constrains in __arch_hweight64() can not be
> fulfilled in a 32bit build. The function is only declared, not used
> within vclock_gettime.c and gcc does not care. LLVM complains and
> aborts.
>
> Move the "fake a 32 bit kernel configuration" bits from vclock_gettime.c
> into a common header file. Use this from vclock_gettime.c and vgetcpu.c.
>
> Fixes: 92d33063c081a ("x86/vdso: Provide getcpu for x86-32.")
> Reported-by: kernel test robot <lkp@...el.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Thank you so much for the fix! Boris inquired why this happens with
clang and I wrote a little blurb here if that is helpful at all:
https://lore.kernel.org/Y+J+UQ1vAKr6RHuH@dev-arch.thelio-3990X/
Regardless, this works for me.
Tested-by: Nathan Chancellor <nathan@...nel.org>
> ---
> arch/x86/entry/vdso/vdso32/fake_32bit_build.h | 25 +++++++++++++++++
> arch/x86/entry/vdso/vdso32/vclock_gettime.c | 27 +------------------
> arch/x86/entry/vdso/vdso32/vgetcpu.c | 1 +
> 3 files changed, 27 insertions(+), 26 deletions(-)
> create mode 100644 arch/x86/entry/vdso/vdso32/fake_32bit_build.h
>
> diff --git a/arch/x86/entry/vdso/vdso32/fake_32bit_build.h b/arch/x86/entry/vdso/vdso32/fake_32bit_build.h
> new file mode 100644
> index 0000000000000..db1b15f686e32
> --- /dev/null
> +++ b/arch/x86/entry/vdso/vdso32/fake_32bit_build.h
> @@ -0,0 +1,25 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifdef CONFIG_X86_64
> +
> +/*
> + * in case of a 32 bit VDSO for a 64 bit kernel fake a 32 bit kernel
> + * configuration
> + */
> +#undef CONFIG_64BIT
> +#undef CONFIG_X86_64
> +#undef CONFIG_COMPAT
> +#undef CONFIG_PGTABLE_LEVELS
> +#undef CONFIG_ILLEGAL_POINTER_VALUE
> +#undef CONFIG_SPARSEMEM_VMEMMAP
> +#undef CONFIG_NR_CPUS
> +#undef CONFIG_PARAVIRT_XXL
> +
> +#define CONFIG_X86_32 1
> +#define CONFIG_PGTABLE_LEVELS 2
> +#define CONFIG_PAGE_OFFSET 0
> +#define CONFIG_ILLEGAL_POINTER_VALUE 0
> +#define CONFIG_NR_CPUS 1
> +
> +#define BUILD_VDSO32_64
> +
> +#endif
> diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime.c b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
> index 283ed9d004267..86981decfea83 100644
> --- a/arch/x86/entry/vdso/vdso32/vclock_gettime.c
> +++ b/arch/x86/entry/vdso/vdso32/vclock_gettime.c
> @@ -1,29 +1,4 @@
> // SPDX-License-Identifier: GPL-2.0
> #define BUILD_VDSO32
> -
> -#ifdef CONFIG_X86_64
> -
> -/*
> - * in case of a 32 bit VDSO for a 64 bit kernel fake a 32 bit kernel
> - * configuration
> - */
> -#undef CONFIG_64BIT
> -#undef CONFIG_X86_64
> -#undef CONFIG_COMPAT
> -#undef CONFIG_PGTABLE_LEVELS
> -#undef CONFIG_ILLEGAL_POINTER_VALUE
> -#undef CONFIG_SPARSEMEM_VMEMMAP
> -#undef CONFIG_NR_CPUS
> -#undef CONFIG_PARAVIRT_XXL
> -
> -#define CONFIG_X86_32 1
> -#define CONFIG_PGTABLE_LEVELS 2
> -#define CONFIG_PAGE_OFFSET 0
> -#define CONFIG_ILLEGAL_POINTER_VALUE 0
> -#define CONFIG_NR_CPUS 1
> -
> -#define BUILD_VDSO32_64
> -
> -#endif
> -
> +#include "fake_32bit_build.h"
> #include "../vclock_gettime.c"
> diff --git a/arch/x86/entry/vdso/vdso32/vgetcpu.c b/arch/x86/entry/vdso/vdso32/vgetcpu.c
> index b777f84ffae9b..3a9791f5e9989 100644
> --- a/arch/x86/entry/vdso/vdso32/vgetcpu.c
> +++ b/arch/x86/entry/vdso/vdso32/vgetcpu.c
> @@ -1,2 +1,3 @@
> // SPDX-License-Identifier: GPL-2.0
> +#include "fake_32bit_build.h"
> #include "../vgetcpu.c"
> --
> 2.39.1
>
Powered by blists - more mailing lists