public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build
@ 2023-12-04  8:47 Arnd Bergmann
  2023-12-04  8:47 ` [PATCH 2/2] x86: rework CONFIG_X86_PAE dependency Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Arnd Bergmann @ 2023-12-04  8:47 UTC (permalink / raw)
  To: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86
  Cc: Arnd Bergmann, Boris Ostrovsky, H. Peter Anvin, xen-devel,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Xen only supports modern CPUs even when running a 32-bit kernel, and it now
requires a kernel built for a 64 byte (or larger) cache line:

In file included from <command-line>:
In function 'xen_vcpu_setup',
    inlined from 'xen_vcpu_setup_restore' at arch/x86/xen/enlighten.c:111:3,
    inlined from 'xen_vcpu_restore' at arch/x86/xen/enlighten.c:141:3:
include/linux/compiler_types.h:435:45: error: call to '__compiletime_assert_287' declared with attribute error: BUILD_BUG_ON failed: sizeof(*vcpup) > SMP_CACHE_BYTES
arch/x86/xen/enlighten.c:166:9: note: in expansion of macro 'BUILD_BUG_ON'
  166 |         BUILD_BUG_ON(sizeof(*vcpup) > SMP_CACHE_BYTES);
      |         ^~~~~~~~~~~~

Enforce the dependency with a whitelist of CPU configurations. In normal
distro kernels, CONFIG_X86_GENERIC is enabled, and this works fine. When this
is not set, still allow Xen to be built on kernels that target a 64-bit
capable CPU.

Fixes: db2832309a82 ("x86/xen: fix percpu vcpu_info allocation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/xen/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
index 9b1ec5d8c99c..a65fc2ae15b4 100644
--- a/arch/x86/xen/Kconfig
+++ b/arch/x86/xen/Kconfig
@@ -9,6 +9,7 @@ config XEN
 	select PARAVIRT_CLOCK
 	select X86_HV_CALLBACK_VECTOR
 	depends on X86_64 || (X86_32 && X86_PAE)
+	depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MCORE2 || MATOM || MK8)
 	depends on X86_LOCAL_APIC && X86_TSC
 	help
 	  This is the Linux Xen port.  Enabling this will allow the
-- 
2.39.2


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

* [PATCH 2/2] x86: rework CONFIG_X86_PAE dependency
  2023-12-04  8:47 [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Arnd Bergmann
@ 2023-12-04  8:47 ` Arnd Bergmann
  2023-12-19 12:13   ` [tip: x86/build] x86/Kconfig: Rework " tip-bot2 for Arnd Bergmann
  2023-12-04 12:59 ` [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Juergen Gross
  2023-12-14 12:01 ` Alyssa Ross
  2 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2023-12-04  8:47 UTC (permalink / raw)
  To: Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86
  Cc: Arnd Bergmann, H. Peter Anvin, Peter Zijlstra, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

While looking at a Xen Kconfig dependency issue, I tried to understand the
exact dependencies for CONFIG_X86_PAE, which is selected by CONFIG_HIGHMEM64G
but can also be enabled manually.

Apparently the dependencies for CONFIG_HIGHMEM64G are strictly about CPUs
that do support PAE, but the actual feature can be incorrectly enabled on
older CPUs as well. The CONFIG_X86_CMPXCHG64 dependencies on the other hand
include X86_PAE because cmpxchg8b is requried for PAE to work.

Rework this for readability and correctness, using a positive list of CPUs
that support PAE in a new X86_HAVE_PAE symbol that can serve as a dependency
for both X86_PAE and HIGHMEM64G as well as simplify the X86_CMPXCHG64
dependency list.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
--
This did not solve the original problem of the Xen dependencies on
64 byte cache lines, as there are a number of CPUs that support PAE
but have 32 byte L1 cache lines.
---
 arch/x86/Kconfig     | 4 ++--
 arch/x86/Kconfig.cpu | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 17a6b304fc0c..c53ebc86ce4f 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1412,7 +1412,7 @@ config HIGHMEM4G
 
 config HIGHMEM64G
 	bool "64GB"
-	depends on !M486SX && !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !MWINCHIP3D && !MK6
+	depends on X86_HAVE_PAE
 	select X86_PAE
 	help
 	  Select this if you have a 32-bit processor and more than 4
@@ -1469,7 +1469,7 @@ config HIGHMEM
 
 config X86_PAE
 	bool "PAE (Physical Address Extension) Support"
-	depends on X86_32 && !HIGHMEM4G
+	depends on X86_32 && X86_HAVE_PAE
 	select PHYS_ADDR_T_64BIT
 	select SWIOTLB
 	help
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 00468adf180f..b9224cf2ee4d 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -362,9 +362,13 @@ config X86_TSC
 	def_bool y
 	depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
 
+config X86_HAVE_PAE
+	def_bool y
+	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC7 || MCORE2 || MATOM || X86_64
+
 config X86_CMPXCHG64
 	def_bool y
-	depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586TSC || M586MMX || MATOM || MGEODE_LX || MGEODEGX1 || MK6 || MK7 || MK8
+	depends on X86_HAVE_PAE || M586TSC || M586MMX || MK6 || MK7
 
 # this should be set for all -march=.. options where the compiler
 # generates cmov.
-- 
2.39.2


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

* Re: [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build
  2023-12-04  8:47 [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Arnd Bergmann
  2023-12-04  8:47 ` [PATCH 2/2] x86: rework CONFIG_X86_PAE dependency Arnd Bergmann
@ 2023-12-04 12:59 ` Juergen Gross
  2023-12-14 12:01 ` Alyssa Ross
  2 siblings, 0 replies; 5+ messages in thread
From: Juergen Gross @ 2023-12-04 12:59 UTC (permalink / raw)
  To: Arnd Bergmann, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86
  Cc: Arnd Bergmann, Boris Ostrovsky, H. Peter Anvin, xen-devel,
	linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 1245 bytes --]

On 04.12.23 09:47, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Xen only supports modern CPUs even when running a 32-bit kernel, and it now
> requires a kernel built for a 64 byte (or larger) cache line:
> 
> In file included from <command-line>:
> In function 'xen_vcpu_setup',
>      inlined from 'xen_vcpu_setup_restore' at arch/x86/xen/enlighten.c:111:3,
>      inlined from 'xen_vcpu_restore' at arch/x86/xen/enlighten.c:141:3:
> include/linux/compiler_types.h:435:45: error: call to '__compiletime_assert_287' declared with attribute error: BUILD_BUG_ON failed: sizeof(*vcpup) > SMP_CACHE_BYTES
> arch/x86/xen/enlighten.c:166:9: note: in expansion of macro 'BUILD_BUG_ON'
>    166 |         BUILD_BUG_ON(sizeof(*vcpup) > SMP_CACHE_BYTES);
>        |         ^~~~~~~~~~~~
> 
> Enforce the dependency with a whitelist of CPU configurations. In normal
> distro kernels, CONFIG_X86_GENERIC is enabled, and this works fine. When this
> is not set, still allow Xen to be built on kernels that target a 64-bit
> capable CPU.
> 
> Fixes: db2832309a82 ("x86/xen: fix percpu vcpu_info allocation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen


[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]

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

* Re: [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build
  2023-12-04  8:47 [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Arnd Bergmann
  2023-12-04  8:47 ` [PATCH 2/2] x86: rework CONFIG_X86_PAE dependency Arnd Bergmann
  2023-12-04 12:59 ` [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Juergen Gross
@ 2023-12-14 12:01 ` Alyssa Ross
  2 siblings, 0 replies; 5+ messages in thread
From: Alyssa Ross @ 2023-12-14 12:01 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Juergen Gross, Thomas Gleixner, Ingo Molnar, Borislav Petkov,
	Dave Hansen, x86, Boris Ostrovsky, H. Peter Anvin, xen-devel,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1901 bytes --]

On Mon, Dec 04, 2023 at 09:47:01AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Xen only supports modern CPUs even when running a 32-bit kernel, and it now
> requires a kernel built for a 64 byte (or larger) cache line:
>
> In file included from <command-line>:
> In function 'xen_vcpu_setup',
>     inlined from 'xen_vcpu_setup_restore' at arch/x86/xen/enlighten.c:111:3,
>     inlined from 'xen_vcpu_restore' at arch/x86/xen/enlighten.c:141:3:
> include/linux/compiler_types.h:435:45: error: call to '__compiletime_assert_287' declared with attribute error: BUILD_BUG_ON failed: sizeof(*vcpup) > SMP_CACHE_BYTES
> arch/x86/xen/enlighten.c:166:9: note: in expansion of macro 'BUILD_BUG_ON'
>   166 |         BUILD_BUG_ON(sizeof(*vcpup) > SMP_CACHE_BYTES);
>       |         ^~~~~~~~~~~~
>
> Enforce the dependency with a whitelist of CPU configurations. In normal
> distro kernels, CONFIG_X86_GENERIC is enabled, and this works fine. When this
> is not set, still allow Xen to be built on kernels that target a 64-bit
> capable CPU.
>
> Fixes: db2832309a82 ("x86/xen: fix percpu vcpu_info allocation")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---

This fixes 32-bit distro kernel builds in Nixpkgs, which regressed
with a recent stable kernel update.  Thanks!

Tested-by: Alyssa Ross <hi@alyssa.is>

>  arch/x86/xen/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/xen/Kconfig b/arch/x86/xen/Kconfig
> index 9b1ec5d8c99c..a65fc2ae15b4 100644
> --- a/arch/x86/xen/Kconfig
> +++ b/arch/x86/xen/Kconfig
> @@ -9,6 +9,7 @@ config XEN
>  	select PARAVIRT_CLOCK
>  	select X86_HV_CALLBACK_VECTOR
>  	depends on X86_64 || (X86_32 && X86_PAE)
> +	depends on X86_64 || (X86_GENERIC || MPENTIUM4 || MCORE2 || MATOM || MK8)
>  	depends on X86_LOCAL_APIC && X86_TSC
>  	help
>  	  This is the Linux Xen port.  Enabling this will allow the
> --
> 2.39.2
>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* [tip: x86/build] x86/Kconfig: Rework CONFIG_X86_PAE dependency
  2023-12-04  8:47 ` [PATCH 2/2] x86: rework CONFIG_X86_PAE dependency Arnd Bergmann
@ 2023-12-19 12:13   ` tip-bot2 for Arnd Bergmann
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Arnd Bergmann @ 2023-12-19 12:13 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Arnd Bergmann, Borislav Petkov (AMD), x86, linux-kernel

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

Commit-ID:     88a2b4edda3d0709727be53f4423b0b832d91de3
Gitweb:        https://git.kernel.org/tip/88a2b4edda3d0709727be53f4423b0b832d91de3
Author:        Arnd Bergmann <arnd@arndb.de>
AuthorDate:    Mon, 04 Dec 2023 09:47:02 +01:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Tue, 19 Dec 2023 13:03:06 +01:00

x86/Kconfig: Rework CONFIG_X86_PAE dependency

While looking at a Xen Kconfig dependency issue, I tried to understand the
exact dependencies for CONFIG_X86_PAE, which is selected by CONFIG_HIGHMEM64G
but can also be enabled manually.

Apparently the dependencies for CONFIG_HIGHMEM64G are strictly about CPUs
that do support PAE, but the actual feature can be incorrectly enabled on
older CPUs as well. The CONFIG_X86_CMPXCHG64 dependencies on the other hand
include X86_PAE because cmpxchg8b is requried for PAE to work.

Rework this for readability and correctness, using a positive list of CPUs
that support PAE in a new X86_HAVE_PAE symbol that can serve as a dependency
for both X86_PAE and HIGHMEM64G as well as simplify the X86_CMPXCHG64
dependency list.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231204084722.3789473-2-arnd@kernel.org
---
 arch/x86/Kconfig     | 4 ++--
 arch/x86/Kconfig.cpu | 6 +++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3762f41..4692380 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1415,7 +1415,7 @@ config HIGHMEM4G
 
 config HIGHMEM64G
 	bool "64GB"
-	depends on !M486SX && !M486 && !M586 && !M586TSC && !M586MMX && !MGEODE_LX && !MGEODEGX1 && !MCYRIXIII && !MELAN && !MWINCHIPC6 && !MWINCHIP3D && !MK6
+	depends on X86_HAVE_PAE
 	select X86_PAE
 	help
 	  Select this if you have a 32-bit processor and more than 4
@@ -1472,7 +1472,7 @@ config HIGHMEM
 
 config X86_PAE
 	bool "PAE (Physical Address Extension) Support"
-	depends on X86_32 && !HIGHMEM4G
+	depends on X86_32 && X86_HAVE_PAE
 	select PHYS_ADDR_T_64BIT
 	select SWIOTLB
 	help
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 00468ad..b9224cf 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -362,9 +362,13 @@ config X86_TSC
 	def_bool y
 	depends on (MWINCHIP3D || MCRUSOE || MEFFICEON || MCYRIXIII || MK7 || MK6 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || MK8 || MVIAC3_2 || MVIAC7 || MGEODEGX1 || MGEODE_LX || MCORE2 || MATOM) || X86_64
 
+config X86_HAVE_PAE
+	def_bool y
+	depends on MCRUSOE || MEFFICEON || MCYRIXIII || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MK8 || MVIAC7 || MCORE2 || MATOM || X86_64
+
 config X86_CMPXCHG64
 	def_bool y
-	depends on X86_PAE || X86_64 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || M586TSC || M586MMX || MATOM || MGEODE_LX || MGEODEGX1 || MK6 || MK7 || MK8
+	depends on X86_HAVE_PAE || M586TSC || M586MMX || MK6 || MK7
 
 # this should be set for all -march=.. options where the compiler
 # generates cmov.

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

end of thread, other threads:[~2023-12-19 12:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-04  8:47 [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Arnd Bergmann
2023-12-04  8:47 ` [PATCH 2/2] x86: rework CONFIG_X86_PAE dependency Arnd Bergmann
2023-12-19 12:13   ` [tip: x86/build] x86/Kconfig: Rework " tip-bot2 for Arnd Bergmann
2023-12-04 12:59 ` [PATCH 1/2] x86/xen: add CPU dependencies for 32-bit build Juergen Gross
2023-12-14 12:01 ` Alyssa Ross

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox