hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/arch/x86/kvm/cpuid.c
....@@ -491,6 +491,9 @@
491491 !boot_cpu_has(X86_FEATURE_AMD_SSBD))
492492 kvm_cpu_cap_set(X86_FEATURE_VIRT_SSBD);
493493
494
+ if (cpu_feature_enabled(X86_FEATURE_SRSO_NO))
495
+ kvm_cpu_cap_set(X86_FEATURE_SRSO_NO);
496
+
494497 /*
495498 * Hide all SVM features by default, SVM will set the cap bits for
496499 * features it emulates and/or exposes for L1.
....@@ -511,15 +514,21 @@
511514 int nent;
512515 };
513516
514
-static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
515
- u32 function, u32 index)
517
+static struct kvm_cpuid_entry2 *get_next_cpuid(struct kvm_cpuid_array *array)
516518 {
517
- struct kvm_cpuid_entry2 *entry;
518
-
519519 if (array->nent >= array->maxnent)
520520 return NULL;
521521
522
- entry = &array->entries[array->nent++];
522
+ return &array->entries[array->nent++];
523
+}
524
+
525
+static struct kvm_cpuid_entry2 *do_host_cpuid(struct kvm_cpuid_array *array,
526
+ u32 function, u32 index)
527
+{
528
+ struct kvm_cpuid_entry2 *entry = get_next_cpuid(array);
529
+
530
+ if (!entry)
531
+ return NULL;
523532
524533 entry->function = function;
525534 entry->index = index;
....@@ -698,22 +707,13 @@
698707 entry->edx = edx.full;
699708 break;
700709 }
701
- /*
702
- * Per Intel's SDM, the 0x1f is a superset of 0xb,
703
- * thus they can be handled by common code.
704
- */
705710 case 0x1f:
706711 case 0xb:
707712 /*
708
- * Populate entries until the level type (ECX[15:8]) of the
709
- * previous entry is zero. Note, CPUID EAX.{0x1f,0xb}.0 is
710
- * the starting entry, filled by the primary do_host_cpuid().
713
+ * No topology; a valid topology is indicated by the presence
714
+ * of subleaf 1.
711715 */
712
- for (i = 1; entry->ecx & 0xff00; ++i) {
713
- entry = do_host_cpuid(array, function, i);
714
- if (!entry)
715
- goto out;
716
- }
716
+ entry->eax = entry->ebx = entry->ecx = 0;
717717 break;
718718 case 0xd:
719719 entry->eax &= supported_xcr0;
....@@ -866,6 +866,9 @@
866866 entry->ebx = entry->ecx = entry->edx = 0;
867867 break;
868868 case 0x8000001e:
869
+ /* Do not return host topology information. */
870
+ entry->eax = entry->ebx = entry->ecx = 0;
871
+ entry->edx = 0; /* reserved */
869872 break;
870873 /* Support memory encryption cpuid if host supports it */
871874 case 0x8000001F: