Re: [PATCH v2 15/15] KVM: x86/cpuid: Advertise Arch LBR feature in CPUID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 12/22/2022 7:03 PM, Like Xu wrote:
On 25/11/2022 12:06 pm, Yang Weijiang wrote:
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index 85e3df6217af..60b3c591d462 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -134,6 +134,19 @@ static int kvm_check_cpuid(struct kvm_vcpu *vcpu,
          if (vaddr_bits != 48 && vaddr_bits != 57 && vaddr_bits != 0)
              return -EINVAL;
      }
+    if (kvm_cpu_cap_has(X86_FEATURE_ARCH_LBR)) {
+        best = cpuid_entry2_find(entries, nent, 0x1c, 0);
+        if (best) {
+            unsigned int eax, ebx, ecx, edx;
+
+            /* Reject user-space CPUID if depth is different from host's.*/

Try to verify this in the KVM selftest, as this behavior is different from the host.


Will do it.




+            cpuid_count(0x1c, 0, &eax, &ebx, &ecx, &edx); > +
+            if ((eax & 0xff) &&
+                (best->eax & 0xff) != BIT(fls(eax & 0xff) - 1))
+                return -EINVAL;
+        }
+    }



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux