All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ
@ 2024-04-17  6:04 Eric Biggers
  2024-04-18 14:24 ` Dave Hansen
  2024-04-18 15:38 ` [tip: x86/urgent] " tip-bot2 for Eric Biggers
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Biggers @ 2024-04-17  6:04 UTC (permalink / raw)
  To: x86; +Cc: linux-crypto, linux-kernel

From: Eric Biggers <ebiggers@google.com>

Fix cpuid_deps[] to list the correct dependencies for GFNI, VAES, and
VPCLMULQDQ.  These features don't depend on AVX512, and there exist CPUs
that support these features but not AVX512.  GFNI actually doesn't even
depend on AVX.

This prevents GFNI from being unnecessarily disabled if AVX is disabled
to mitigate the GDS vulnerability.

This also prevents all three features from being unnecessarily disabled
if AVX512VL (or its dependency AVX512F) were to be disabled, but it
looks like there isn't any case where this happens anyway.

Fixes: c128dbfa0f87 ("x86/cpufeatures: Enable new SSE/AVX/AVX512 CPU features")
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
 arch/x86/kernel/cpu/cpuid-deps.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index b7174209d855..946813d816bf 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -42,11 +42,14 @@ static const struct cpuid_dep cpuid_deps[] = {
 	{ X86_FEATURE_PCLMULQDQ,		X86_FEATURE_XMM2      },
 	{ X86_FEATURE_SSSE3,			X86_FEATURE_XMM2,     },
 	{ X86_FEATURE_F16C,			X86_FEATURE_XMM2,     },
 	{ X86_FEATURE_AES,			X86_FEATURE_XMM2      },
 	{ X86_FEATURE_SHA_NI,			X86_FEATURE_XMM2      },
+	{ X86_FEATURE_GFNI,			X86_FEATURE_XMM2      },
 	{ X86_FEATURE_FMA,			X86_FEATURE_AVX       },
+	{ X86_FEATURE_VAES,			X86_FEATURE_AVX       },
+	{ X86_FEATURE_VPCLMULQDQ,		X86_FEATURE_AVX       },
 	{ X86_FEATURE_AVX2,			X86_FEATURE_AVX,      },
 	{ X86_FEATURE_AVX512F,			X86_FEATURE_AVX,      },
 	{ X86_FEATURE_AVX512IFMA,		X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512PF,			X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512ER,			X86_FEATURE_AVX512F   },
@@ -54,13 +57,10 @@ static const struct cpuid_dep cpuid_deps[] = {
 	{ X86_FEATURE_AVX512DQ,			X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512BW,			X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512VL,			X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512VBMI,		X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512_VBMI2,		X86_FEATURE_AVX512VL  },
-	{ X86_FEATURE_GFNI,			X86_FEATURE_AVX512VL  },
-	{ X86_FEATURE_VAES,			X86_FEATURE_AVX512VL  },
-	{ X86_FEATURE_VPCLMULQDQ,		X86_FEATURE_AVX512VL  },
 	{ X86_FEATURE_AVX512_VNNI,		X86_FEATURE_AVX512VL  },
 	{ X86_FEATURE_AVX512_BITALG,		X86_FEATURE_AVX512VL  },
 	{ X86_FEATURE_AVX512_4VNNIW,		X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512_4FMAPS,		X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512_VPOPCNTDQ,		X86_FEATURE_AVX512F   },

base-commit: 20cb38a7af88dc40095da7c2c9094da3873fea23
-- 
2.44.0


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

* Re: [PATCH] x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ
  2024-04-17  6:04 [PATCH] x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ Eric Biggers
@ 2024-04-18 14:24 ` Dave Hansen
  2024-04-18 15:38 ` [tip: x86/urgent] " tip-bot2 for Eric Biggers
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Hansen @ 2024-04-18 14:24 UTC (permalink / raw)
  To: Eric Biggers, x86; +Cc: linux-crypto, linux-kernel

On 4/16/24 23:04, Eric Biggers wrote:
> Fix cpuid_deps[] to list the correct dependencies for GFNI, VAES, and
> VPCLMULQDQ.  These features don't depend on AVX512, and there exist CPUs
> that support these features but not AVX512.  GFNI actually doesn't even
> depend on AVX.
> 
> This prevents GFNI from being unnecessarily disabled if AVX is disabled
> to mitigate the GDS vulnerability.

Looks like the original commit was quite confused.  Thanks for finding this.

Acked-by: Dave Hansen <dave.hansen@linux.intel.com>


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

* [tip: x86/urgent] x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ
  2024-04-17  6:04 [PATCH] x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ Eric Biggers
  2024-04-18 14:24 ` Dave Hansen
@ 2024-04-18 15:38 ` tip-bot2 for Eric Biggers
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Eric Biggers @ 2024-04-18 15:38 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Eric Biggers, Borislav Petkov (AMD), Dave Hansen, x86, linux-kernel

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

Commit-ID:     9543f6e26634537997b6e909c20911b7bf4876de
Gitweb:        https://git.kernel.org/tip/9543f6e26634537997b6e909c20911b7bf4876de
Author:        Eric Biggers <ebiggers@google.com>
AuthorDate:    Tue, 16 Apr 2024 23:04:34 -07:00
Committer:     Borislav Petkov (AMD) <bp@alien8.de>
CommitterDate: Thu, 18 Apr 2024 17:27:52 +02:00

x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ

Fix cpuid_deps[] to list the correct dependencies for GFNI, VAES, and
VPCLMULQDQ.  These features don't depend on AVX512, and there exist CPUs
that support these features but not AVX512.  GFNI actually doesn't even
depend on AVX.

This prevents GFNI from being unnecessarily disabled if AVX is disabled
to mitigate the GDS vulnerability.

This also prevents all three features from being unnecessarily disabled
if AVX512VL (or its dependency AVX512F) were to be disabled, but it
looks like there isn't any case where this happens anyway.

Fixes: c128dbfa0f87 ("x86/cpufeatures: Enable new SSE/AVX/AVX512 CPU features")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lore.kernel.org/r/20240417060434.47101-1-ebiggers@kernel.org
---
 arch/x86/kernel/cpu/cpuid-deps.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/cpuid-deps.c b/arch/x86/kernel/cpu/cpuid-deps.c
index b717420..946813d 100644
--- a/arch/x86/kernel/cpu/cpuid-deps.c
+++ b/arch/x86/kernel/cpu/cpuid-deps.c
@@ -44,7 +44,10 @@ static const struct cpuid_dep cpuid_deps[] = {
 	{ X86_FEATURE_F16C,			X86_FEATURE_XMM2,     },
 	{ X86_FEATURE_AES,			X86_FEATURE_XMM2      },
 	{ X86_FEATURE_SHA_NI,			X86_FEATURE_XMM2      },
+	{ X86_FEATURE_GFNI,			X86_FEATURE_XMM2      },
 	{ X86_FEATURE_FMA,			X86_FEATURE_AVX       },
+	{ X86_FEATURE_VAES,			X86_FEATURE_AVX       },
+	{ X86_FEATURE_VPCLMULQDQ,		X86_FEATURE_AVX       },
 	{ X86_FEATURE_AVX2,			X86_FEATURE_AVX,      },
 	{ X86_FEATURE_AVX512F,			X86_FEATURE_AVX,      },
 	{ X86_FEATURE_AVX512IFMA,		X86_FEATURE_AVX512F   },
@@ -56,9 +59,6 @@ static const struct cpuid_dep cpuid_deps[] = {
 	{ X86_FEATURE_AVX512VL,			X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512VBMI,		X86_FEATURE_AVX512F   },
 	{ X86_FEATURE_AVX512_VBMI2,		X86_FEATURE_AVX512VL  },
-	{ X86_FEATURE_GFNI,			X86_FEATURE_AVX512VL  },
-	{ X86_FEATURE_VAES,			X86_FEATURE_AVX512VL  },
-	{ X86_FEATURE_VPCLMULQDQ,		X86_FEATURE_AVX512VL  },
 	{ X86_FEATURE_AVX512_VNNI,		X86_FEATURE_AVX512VL  },
 	{ X86_FEATURE_AVX512_BITALG,		X86_FEATURE_AVX512VL  },
 	{ X86_FEATURE_AVX512_4VNNIW,		X86_FEATURE_AVX512F   },

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

end of thread, other threads:[~2024-04-18 15:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17  6:04 [PATCH] x86/cpufeatures: Fix dependencies for GFNI, VAES, and VPCLMULQDQ Eric Biggers
2024-04-18 14:24 ` Dave Hansen
2024-04-18 15:38 ` [tip: x86/urgent] " tip-bot2 for Eric Biggers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.