From: Greg Kroah-Hartman Date: Wed, 27 Mar 2024 10:41:56 +0000 (+0100) Subject: fix up some mis-applied kvm patches X-Git-Tag: v6.7.12~231 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c0205e737d350dc713147c4cff98da966ee1e019;p=thirdparty%2Fkernel%2Fstable-queue.git fix up some mis-applied kvm patches --- diff --git a/queue-5.10/kvm-x86-update-kvm-only-leaf-handling-to-allow-for-100-kvm-only-leafs.patch b/queue-5.10/kvm-x86-update-kvm-only-leaf-handling-to-allow-for-100-kvm-only-leafs.patch deleted file mode 100644 index 6c22b295784..00000000000 --- a/queue-5.10/kvm-x86-update-kvm-only-leaf-handling-to-allow-for-100-kvm-only-leafs.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 047c7229906152fb85c23dc18fd25a00cd7cb4de Mon Sep 17 00:00:00 2001 -From: Sean Christopherson -Date: Fri, 25 Nov 2022 20:58:39 +0800 -Subject: KVM: x86: Update KVM-only leaf handling to allow for 100% KVM-only leafs - -From: Sean Christopherson - -commit 047c7229906152fb85c23dc18fd25a00cd7cb4de upstream. - -Rename kvm_cpu_cap_init_scattered() to kvm_cpu_cap_init_kvm_defined() in -anticipation of adding KVM-only CPUID leafs that aren't recognized by the -kernel and thus not scattered, i.e. for leafs that are 100% KVM-defined. - -Adjust/add comments to kvm_only_cpuid_leafs and KVM_X86_FEATURE to -document how to create new kvm_only_cpuid_leafs entries for scattered -features as well as features that are entirely unknown to the kernel. - -No functional change intended. - -Signed-off-by: Sean Christopherson -Message-Id: <20221125125845.1182922-3-jiaxi.chen@linux.intel.com> -Signed-off-by: Paolo Bonzini -Signed-off-by: Greg Kroah-Hartman ---- - arch/x86/kvm/cpuid.c | 8 ++++---- - arch/x86/kvm/reverse_cpuid.h | 18 +++++++++++++++--- - 2 files changed, 19 insertions(+), 7 deletions(-) - -diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c -index ff2e9734e5c1..73c3c6dc6e7b 100644 ---- a/arch/x86/kvm/cpuid.c -+++ b/arch/x86/kvm/cpuid.c -@@ -549,9 +549,9 @@ static __always_inline void __kvm_cpu_cap_mask(unsigned int leaf) - } - - static __always_inline --void kvm_cpu_cap_init_scattered(enum kvm_only_cpuid_leafs leaf, u32 mask) -+void kvm_cpu_cap_init_kvm_defined(enum kvm_only_cpuid_leafs leaf, u32 mask) - { -- /* Use kvm_cpu_cap_mask for non-scattered leafs. */ -+ /* Use kvm_cpu_cap_mask for leafs that aren't KVM-only. */ - BUILD_BUG_ON(leaf < NCAPINTS); - - kvm_cpu_caps[leaf] = mask; -@@ -561,7 +561,7 @@ void kvm_cpu_cap_init_scattered(enum kvm_only_cpuid_leafs leaf, u32 mask) - - static __always_inline void kvm_cpu_cap_mask(enum cpuid_leafs leaf, u32 mask) - { -- /* Use kvm_cpu_cap_init_scattered for scattered leafs. */ -+ /* Use kvm_cpu_cap_init_kvm_defined for KVM-only leafs. */ - BUILD_BUG_ON(leaf >= NCAPINTS); - - kvm_cpu_caps[leaf] &= mask; -@@ -670,7 +670,7 @@ void kvm_set_cpu_caps(void) - F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd - ); - -- kvm_cpu_cap_init_scattered(CPUID_12_EAX, -+ kvm_cpu_cap_init_kvm_defined(CPUID_12_EAX, - SF(SGX1) | SF(SGX2) - ); - -diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h -index a19d473d0184..443a6b3e66c0 100644 ---- a/arch/x86/kvm/reverse_cpuid.h -+++ b/arch/x86/kvm/reverse_cpuid.h -@@ -7,9 +7,9 @@ - #include - - /* -- * Hardware-defined CPUID leafs that are scattered in the kernel, but need to -- * be directly used by KVM. Note, these word values conflict with the kernel's -- * "bug" caps, but KVM doesn't use those. -+ * Hardware-defined CPUID leafs that are either scattered by the kernel or are -+ * unknown to the kernel, but need to be directly used by KVM. Note, these -+ * word values conflict with the kernel's "bug" caps, but KVM doesn't use those. - */ - enum kvm_only_cpuid_leafs { - CPUID_12_EAX = NCAPINTS, -@@ -18,6 +18,18 @@ enum kvm_only_cpuid_leafs { - NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS, - }; - -+/* -+ * Define a KVM-only feature flag. -+ * -+ * For features that are scattered by cpufeatures.h, __feature_translate() also -+ * needs to be updated to translate the kernel-defined feature into the -+ * KVM-defined feature. -+ * -+ * For features that are 100% KVM-only, i.e. not defined by cpufeatures.h, -+ * forego the intermediate KVM_X86_FEATURE and directly define X86_FEATURE_* so -+ * that X86_FEATURE_* can be used in KVM. No __feature_translate() handling is -+ * needed in this case. -+ */ - #define KVM_X86_FEATURE(w, f) ((w)*32 + (f)) - - /* Intel-defined SGX sub-features, CPUID level 0x12 (EAX). */ --- -2.44.0 - diff --git a/queue-5.10/series b/queue-5.10/series index b54bb3d6fe4..aca95c98c55 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -1,4 +1,3 @@ documentation-hw-vuln-update-spectre-doc.patch x86-cpu-support-amd-automatic-ibrs.patch x86-bugs-use-sysfs_emit.patch -kvm-x86-update-kvm-only-leaf-handling-to-allow-for-100-kvm-only-leafs.patch diff --git a/queue-5.15/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch b/queue-5.15/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch index d09ea19494f..2ec9750c382 100644 --- a/queue-5.15/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch +++ b/queue-5.15/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch @@ -24,16 +24,14 @@ Link: https://lore.kernel.org/r/20231024001636.890236-1-jmattson@google.com Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- - arch/x86/kvm/cpuid.c | 21 ++++++++++++++++++--- - arch/x86/kvm/reverse_cpuid.h | 12 ++++++++++++ + arch/x86/kvm/cpuid.c | 21 ++++++++++++++++++--- + arch/x86/kvm/reverse_cpuid.h | 12 ++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) -diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c -index dda6fc4cfae8..1811a9ddfe1d 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c -@@ -679,6 +679,11 @@ void kvm_set_cpu_caps(void) - F(AMX_COMPLEX) +@@ -469,6 +469,11 @@ void kvm_set_cpu_caps(void) + F(AVX_VNNI) | F(AVX512_BF16) ); + kvm_cpu_cap_init_kvm_defined(CPUID_7_2_EDX, @@ -42,9 +40,9 @@ index dda6fc4cfae8..1811a9ddfe1d 100644 + ); + kvm_cpu_cap_mask(CPUID_D_1_EAX, - F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd + F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) ); -@@ -960,13 +965,13 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) +@@ -710,13 +715,13 @@ static inline int __do_cpuid_func(struct break; /* function 7 has additional index. */ case 7: @@ -61,9 +59,9 @@ index dda6fc4cfae8..1811a9ddfe1d 100644 entry = do_host_cpuid(array, function, 1); if (!entry) goto out; -@@ -976,6 +981,16 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) - entry->ebx = 0; +@@ -726,6 +731,16 @@ static inline int __do_cpuid_func(struct entry->ecx = 0; + entry->edx = 0; } + if (max_idx >= 2) { + entry = do_host_cpuid(array, function, 2); @@ -77,22 +75,20 @@ index dda6fc4cfae8..1811a9ddfe1d 100644 + } break; case 0xa: { /* Architectural Performance Monitoring */ - union cpuid10_eax eax; -diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h -index b81650678375..17007016d8b5 100644 + struct x86_pmu_capability cap; --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h -@@ -16,6 +16,7 @@ enum kvm_only_cpuid_leafs { - CPUID_7_1_EDX, - CPUID_8000_0007_EDX, - CPUID_8000_0022_EAX, +@@ -13,6 +13,7 @@ + */ + enum kvm_only_cpuid_leafs { + CPUID_12_EAX = NCAPINTS, + CPUID_7_2_EDX, NR_KVM_CPU_CAPS, NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS, -@@ -46,6 +47,14 @@ enum kvm_only_cpuid_leafs { - #define X86_FEATURE_AMX_COMPLEX KVM_X86_FEATURE(CPUID_7_1_EDX, 8) - #define X86_FEATURE_PREFETCHITI KVM_X86_FEATURE(CPUID_7_1_EDX, 14) +@@ -36,6 +37,14 @@ enum kvm_only_cpuid_leafs { + #define KVM_X86_FEATURE_SGX1 KVM_X86_FEATURE(CPUID_12_EAX, 0) + #define KVM_X86_FEATURE_SGX2 KVM_X86_FEATURE(CPUID_12_EAX, 1) +/* Intel-defined sub-features, CPUID level 0x00000007:2 (EDX) */ +#define X86_FEATURE_INTEL_PSFD KVM_X86_FEATURE(CPUID_7_2_EDX, 0) @@ -102,26 +98,23 @@ index b81650678375..17007016d8b5 100644 +#define X86_FEATURE_BHI_CTRL KVM_X86_FEATURE(CPUID_7_2_EDX, 4) +#define X86_FEATURE_MCDT_NO KVM_X86_FEATURE(CPUID_7_2_EDX, 5) + - /* CPUID level 0x80000007 (EDX). */ - #define KVM_X86_FEATURE_CONSTANT_TSC KVM_X86_FEATURE(CPUID_8000_0007_EDX, 8) - -@@ -80,6 +89,7 @@ static const struct cpuid_reg reverse_cpuid[] = { - [CPUID_8000_0007_EDX] = {0x80000007, 0, CPUID_EDX}, + struct cpuid_reg { + u32 function; + u32 index; +@@ -61,6 +70,7 @@ static const struct cpuid_reg reverse_cp + [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, + [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, [CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX}, - [CPUID_8000_0022_EAX] = {0x80000022, 0, CPUID_EAX}, + [CPUID_7_2_EDX] = { 7, 2, CPUID_EDX}, }; /* -@@ -116,6 +126,8 @@ static __always_inline u32 __feature_translate(int x86_feature) - return KVM_X86_FEATURE_CONSTANT_TSC; - else if (x86_feature == X86_FEATURE_PERFMON_V2) - return KVM_X86_FEATURE_PERFMON_V2; +@@ -91,6 +101,8 @@ static __always_inline u32 __feature_tra + return KVM_X86_FEATURE_SGX1; + else if (x86_feature == X86_FEATURE_SGX2) + return KVM_X86_FEATURE_SGX2; + else if (x86_feature == X86_FEATURE_RRSBA_CTRL) + return KVM_X86_FEATURE_RRSBA_CTRL; return x86_feature; } --- -2.44.0 - diff --git a/queue-6.1/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch b/queue-6.1/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch index d09ea19494f..1d069378d95 100644 --- a/queue-6.1/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch +++ b/queue-6.1/kvm-x86-advertise-cpuid.-eax-7-ecx-2-edx-to-userspace.patch @@ -24,16 +24,14 @@ Link: https://lore.kernel.org/r/20231024001636.890236-1-jmattson@google.com Signed-off-by: Sean Christopherson Signed-off-by: Greg Kroah-Hartman --- - arch/x86/kvm/cpuid.c | 21 ++++++++++++++++++--- - arch/x86/kvm/reverse_cpuid.h | 12 ++++++++++++ + arch/x86/kvm/cpuid.c | 21 ++++++++++++++++++--- + arch/x86/kvm/reverse_cpuid.h | 12 ++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) -diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c -index dda6fc4cfae8..1811a9ddfe1d 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c -@@ -679,6 +679,11 @@ void kvm_set_cpu_caps(void) - F(AMX_COMPLEX) +@@ -652,6 +652,11 @@ void kvm_set_cpu_caps(void) + F(AVX_VNNI) | F(AVX512_BF16) ); + kvm_cpu_cap_init_kvm_defined(CPUID_7_2_EDX, @@ -44,7 +42,7 @@ index dda6fc4cfae8..1811a9ddfe1d 100644 kvm_cpu_cap_mask(CPUID_D_1_EAX, F(XSAVEOPT) | F(XSAVEC) | F(XGETBV1) | F(XSAVES) | f_xfd ); -@@ -960,13 +965,13 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) +@@ -902,13 +907,13 @@ static inline int __do_cpuid_func(struct break; /* function 7 has additional index. */ case 7: @@ -61,9 +59,9 @@ index dda6fc4cfae8..1811a9ddfe1d 100644 entry = do_host_cpuid(array, function, 1); if (!entry) goto out; -@@ -976,6 +981,16 @@ static inline int __do_cpuid_func(struct kvm_cpuid_array *array, u32 function) - entry->ebx = 0; +@@ -918,6 +923,16 @@ static inline int __do_cpuid_func(struct entry->ecx = 0; + entry->edx = 0; } + if (max_idx >= 2) { + entry = do_host_cpuid(array, function, 2); @@ -78,21 +76,19 @@ index dda6fc4cfae8..1811a9ddfe1d 100644 break; case 0xa: { /* Architectural Performance Monitoring */ union cpuid10_eax eax; -diff --git a/arch/x86/kvm/reverse_cpuid.h b/arch/x86/kvm/reverse_cpuid.h -index b81650678375..17007016d8b5 100644 --- a/arch/x86/kvm/reverse_cpuid.h +++ b/arch/x86/kvm/reverse_cpuid.h -@@ -16,6 +16,7 @@ enum kvm_only_cpuid_leafs { - CPUID_7_1_EDX, - CPUID_8000_0007_EDX, - CPUID_8000_0022_EAX, +@@ -13,6 +13,7 @@ + */ + enum kvm_only_cpuid_leafs { + CPUID_12_EAX = NCAPINTS, + CPUID_7_2_EDX, NR_KVM_CPU_CAPS, NKVMCAPINTS = NR_KVM_CPU_CAPS - NCAPINTS, -@@ -46,6 +47,14 @@ enum kvm_only_cpuid_leafs { - #define X86_FEATURE_AMX_COMPLEX KVM_X86_FEATURE(CPUID_7_1_EDX, 8) - #define X86_FEATURE_PREFETCHITI KVM_X86_FEATURE(CPUID_7_1_EDX, 14) +@@ -36,6 +37,14 @@ enum kvm_only_cpuid_leafs { + #define KVM_X86_FEATURE_SGX1 KVM_X86_FEATURE(CPUID_12_EAX, 0) + #define KVM_X86_FEATURE_SGX2 KVM_X86_FEATURE(CPUID_12_EAX, 1) +/* Intel-defined sub-features, CPUID level 0x00000007:2 (EDX) */ +#define X86_FEATURE_INTEL_PSFD KVM_X86_FEATURE(CPUID_7_2_EDX, 0) @@ -102,26 +98,23 @@ index b81650678375..17007016d8b5 100644 +#define X86_FEATURE_BHI_CTRL KVM_X86_FEATURE(CPUID_7_2_EDX, 4) +#define X86_FEATURE_MCDT_NO KVM_X86_FEATURE(CPUID_7_2_EDX, 5) + - /* CPUID level 0x80000007 (EDX). */ - #define KVM_X86_FEATURE_CONSTANT_TSC KVM_X86_FEATURE(CPUID_8000_0007_EDX, 8) - -@@ -80,6 +89,7 @@ static const struct cpuid_reg reverse_cpuid[] = { - [CPUID_8000_0007_EDX] = {0x80000007, 0, CPUID_EDX}, + struct cpuid_reg { + u32 function; + u32 index; +@@ -61,6 +70,7 @@ static const struct cpuid_reg reverse_cp + [CPUID_12_EAX] = {0x00000012, 0, CPUID_EAX}, + [CPUID_8000_001F_EAX] = {0x8000001f, 0, CPUID_EAX}, [CPUID_8000_0021_EAX] = {0x80000021, 0, CPUID_EAX}, - [CPUID_8000_0022_EAX] = {0x80000022, 0, CPUID_EAX}, + [CPUID_7_2_EDX] = { 7, 2, CPUID_EDX}, }; /* -@@ -116,6 +126,8 @@ static __always_inline u32 __feature_translate(int x86_feature) - return KVM_X86_FEATURE_CONSTANT_TSC; - else if (x86_feature == X86_FEATURE_PERFMON_V2) - return KVM_X86_FEATURE_PERFMON_V2; +@@ -91,6 +101,8 @@ static __always_inline u32 __feature_tra + return KVM_X86_FEATURE_SGX1; + else if (x86_feature == X86_FEATURE_SGX2) + return KVM_X86_FEATURE_SGX2; + else if (x86_feature == X86_FEATURE_RRSBA_CTRL) + return KVM_X86_FEATURE_RRSBA_CTRL; return x86_feature; } --- -2.44.0 -