linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [tip:x86/vdso 3/4] arch/x86/include/asm/arch_hweight.h:49:15: error: invalid input size for constraint 'D'
@ 2023-02-07  5:39 kernel test robot
  2023-02-07 10:46 ` [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu Sebastian Andrzej Siewior
  0 siblings, 1 reply; 5+ messages in thread
From: kernel test robot @ 2023-02-07  5:39 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: llvm, oe-kbuild-all, linux-kernel, x86, Thomas Gleixner

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/vdso
head:   5646bbd6684acf5c9b9dedb863b7d2f6f5a330fb
commit: 92d33063c081a82d25dd08a9cce03947c8ed9164 [3/4] x86/vdso: Provide getcpu for x86-32.
config: x86_64-randconfig-r031-20230206 (https://download.01.org/0day-ci/archive/20230207/202302071338.m7nBGR5i-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=92d33063c081a82d25dd08a9cce03947c8ed9164
        git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
        git fetch --no-tags tip x86/vdso
        git checkout 92d33063c081a82d25dd08a9cce03947c8ed9164
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from arch/x86/entry/vdso/vdso32/vgetcpu.c:2:
   In file included from arch/x86/entry/vdso/vdso32/../vgetcpu.c:8:
   In file included from include/linux/kernel.h:22:
   In file included from include/linux/bitops.h:68:
   In file included from arch/x86/include/asm/bitops.h:420:
>> arch/x86/include/asm/arch_hweight.h:49:15: error: invalid input size for constraint 'D'
                            : REG_IN (w));
                                      ^
   In file included from arch/x86/entry/vdso/vdso32/vgetcpu.c:2:
   In file included from arch/x86/entry/vdso/vdso32/../vgetcpu.c:8:
   In file included from include/linux/kernel.h:25:
   In file included from include/linux/math.h:6:
>> arch/x86/include/asm/div64.h:85:34: error: invalid output size for constraint '=a'
           asm ("mulq %2; divq %3" : "=a" (q)
                                           ^
   In file included from arch/x86/entry/vdso/vdso32/vgetcpu.c:2:
   arch/x86/entry/vdso/vdso32/../vgetcpu.c:13:1: warning: no previous prototype for function '__vdso_getcpu' [-Wmissing-prototypes]
   __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
   ^
   arch/x86/entry/vdso/vdso32/../vgetcpu.c:12:9: note: declare 'static' if the function is not intended to be used outside of this translation unit
   notrace long
           ^
           static 
   1 warning and 2 errors generated.


vim +/D +49 arch/x86/include/asm/arch_hweight.h

d61931d89be506 Borislav Petkov 2010-03-05  35  
d14edb1648221e Denys Vlasenko  2015-08-04  36  #ifdef CONFIG_X86_32
d61931d89be506 Borislav Petkov 2010-03-05  37  static inline unsigned long __arch_hweight64(__u64 w)
d61931d89be506 Borislav Petkov 2010-03-05  38  {
d61931d89be506 Borislav Petkov 2010-03-05  39  	return  __arch_hweight32((u32)w) +
d61931d89be506 Borislav Petkov 2010-03-05  40  		__arch_hweight32((u32)(w >> 32));
d14edb1648221e Denys Vlasenko  2015-08-04  41  }
d61931d89be506 Borislav Petkov 2010-03-05  42  #else
d14edb1648221e Denys Vlasenko  2015-08-04  43  static __always_inline unsigned long __arch_hweight64(__u64 w)
d14edb1648221e Denys Vlasenko  2015-08-04  44  {
f5967101e9de12 Borislav Petkov 2016-05-30  45  	unsigned long res;
d14edb1648221e Denys Vlasenko  2015-08-04  46  
566b62a3676cae Uros Bizjak     2018-10-14  47  	asm (ALTERNATIVE("call __sw_hweight64", "popcntq %1, %0", X86_FEATURE_POPCNT)
d61931d89be506 Borislav Petkov 2010-03-05  48  			 : "="REG_OUT (res)
d61931d89be506 Borislav Petkov 2010-03-05 @49  			 : REG_IN (w));
d61931d89be506 Borislav Petkov 2010-03-05  50  
d61931d89be506 Borislav Petkov 2010-03-05  51  	return res;
d61931d89be506 Borislav Petkov 2010-03-05  52  }
d14edb1648221e Denys Vlasenko  2015-08-04  53  #endif /* CONFIG_X86_32 */
d61931d89be506 Borislav Petkov 2010-03-05  54  

:::::: The code at line 49 was first introduced by commit
:::::: d61931d89be506372d01a90d1755f6d0a9fafe2d x86: Add optimized popcnt variants

:::::: TO: Borislav Petkov <borislav.petkov@amd.com>
:::::: CC: H. Peter Anvin <hpa@zytor.com>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu.
  2023-02-07  5:39 [tip:x86/vdso 3/4] arch/x86/include/asm/arch_hweight.h:49:15: error: invalid input size for constraint 'D' kernel test robot
@ 2023-02-07 10:46 ` Sebastian Andrzej Siewior
  2023-02-07 16:45   ` Damian Tometzki
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Sebastian Andrzej Siewior @ 2023-02-07 10:46 UTC (permalink / raw)
  To: kernel test robot, Nathan Chancellor, Nick Desaulniers, Tom Rix
  Cc: llvm, oe-kbuild-all, linux-kernel, x86, Thomas Gleixner,
	Andy Lutomirski, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin

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@intel.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu.
  2023-02-07 10:46 ` [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu Sebastian Andrzej Siewior
@ 2023-02-07 16:45   ` Damian Tometzki
  2023-02-07 16:53   ` Nathan Chancellor
  2023-02-07 18:31   ` [tip: x86/vdso] " tip-bot2 for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 5+ messages in thread
From: Damian Tometzki @ 2023-02-07 16:45 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: kernel test robot, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	llvm, oe-kbuild-all, linux-kernel, x86, Thomas Gleixner,
	Andy Lutomirski, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin

Hello Sebastian,
Linux Kernel build 6.2.0rc7 was successfully with clang-17.

Many Thanks
Damian Tometzki


On Tue, 07. Feb 11:46, 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@intel.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>  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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu.
  2023-02-07 10:46 ` [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu Sebastian Andrzej Siewior
  2023-02-07 16:45   ` Damian Tometzki
@ 2023-02-07 16:53   ` Nathan Chancellor
  2023-02-07 18:31   ` [tip: x86/vdso] " tip-bot2 for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 5+ messages in thread
From: Nathan Chancellor @ 2023-02-07 16:53 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: kernel test robot, Nick Desaulniers, Tom Rix, llvm,
	oe-kbuild-all, linux-kernel, x86, Thomas Gleixner,
	Andy Lutomirski, Ingo Molnar, Borislav Petkov, Dave Hansen,
	H. Peter Anvin

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@intel.com>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.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@kernel.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
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [tip: x86/vdso] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu
  2023-02-07 10:46 ` [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu Sebastian Andrzej Siewior
  2023-02-07 16:45   ` Damian Tometzki
  2023-02-07 16:53   ` Nathan Chancellor
@ 2023-02-07 18:31   ` tip-bot2 for Sebastian Andrzej Siewior
  2 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Sebastian Andrzej Siewior @ 2023-02-07 18:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: kernel test robot, Sebastian Andrzej Siewior,
	Borislav Petkov (AMD),
	x86, linux-kernel

The following commit has been merged into the x86/vdso branch of tip:

Commit-ID:     877cff5296faa6ef312f8002216bbf73bea006c7
Gitweb:        https://git.kernel.org/tip/877cff5296faa6ef312f8002216bbf73bea006c7
Author:        Sebastian Andrzej Siewior <bigeasy@linutronix.de>
AuthorDate:    Tue, 07 Feb 2023 11:46:33 +01:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 07 Feb 2023 18:20:41 +01:00

x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu

The 64bit register constrains in __arch_hweight64() cannot be
fulfilled in a 32-bit build. The function is only declared but not used
within vclock_gettime.c and gcc does not care. LLVM complains and
aborts. Reportedly because it validates extended asm even if latter
would get compiled out, see

  https://lore.kernel.org/r/Y%2BJ%2BUQ1vAKr6RHuH@dev-arch.thelio-3990X

i.e., a long standing design difference between gcc and LLVM.

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.

  [ bp: Add background info from Nathan. ]

Fixes: 92d33063c081a ("x86/vdso: Provide getcpu for x86-32.")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/Y+IsCWQdXEr8d9Vy@linutronix.de
---
 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 0000000..db1b15f
--- /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 283ed9d..86981de 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 b777f84..3a9791f 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"

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-07 18:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07  5:39 [tip:x86/vdso 3/4] arch/x86/include/asm/arch_hweight.h:49:15: error: invalid input size for constraint 'D' kernel test robot
2023-02-07 10:46 ` [PATCH] x86/vdso: Fake 32bit VDSO build on 64bit compile for vgetcpu Sebastian Andrzej Siewior
2023-02-07 16:45   ` Damian Tometzki
2023-02-07 16:53   ` Nathan Chancellor
2023-02-07 18:31   ` [tip: x86/vdso] " tip-bot2 for Sebastian Andrzej Siewior

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).