OSDN Git Service

KVM: selftests: Add X86_FEATURE_PAE and use it calc "fallback" MAXPHYADDR
authorSean Christopherson <seanjc@google.com>
Thu, 6 Oct 2022 00:51:14 +0000 (00:51 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 17 Nov 2022 00:59:02 +0000 (16:59 -0800)
Add X86_FEATURE_PAE and use it to guesstimate the MAXPHYADDR when the
MAXPHYADDR CPUID entry isn't supported.

No functional change intended.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Link: https://lore.kernel.org/r/20221006005125.680782-2-seanjc@google.com
tools/testing/selftests/kvm/include/x86_64/processor.h
tools/testing/selftests/kvm/lib/x86_64/processor.c

index 6093d0d..4f928fe 100644 (file)
@@ -89,6 +89,7 @@ struct kvm_x86_cpu_feature {
 #define        X86_FEATURE_XSAVE               KVM_X86_CPU_FEATURE(0x1, 0, ECX, 26)
 #define        X86_FEATURE_OSXSAVE             KVM_X86_CPU_FEATURE(0x1, 0, ECX, 27)
 #define        X86_FEATURE_RDRAND              KVM_X86_CPU_FEATURE(0x1, 0, ECX, 30)
+#define X86_FEATURE_PAE                        KVM_X86_CPU_FEATURE(0x1, 0, EDX, 6)
 #define        X86_FEATURE_MCE                 KVM_X86_CPU_FEATURE(0x1, 0, EDX, 7)
 #define        X86_FEATURE_APIC                KVM_X86_CPU_FEATURE(0x1, 0, EDX, 9)
 #define        X86_FEATURE_CLFLUSH             KVM_X86_CPU_FEATURE(0x1, 0, EDX, 19)
index 4623874..061e001 100644 (file)
@@ -1012,12 +1012,10 @@ bool is_amd_cpu(void)
 void kvm_get_cpu_address_width(unsigned int *pa_bits, unsigned int *va_bits)
 {
        const struct kvm_cpuid_entry2 *entry;
-       bool pae;
 
        /* SDM 4.1.4 */
        if (kvm_get_cpuid_max_extended() < 0x80000008) {
-               pae = kvm_get_supported_cpuid_entry(1)->edx & (1 << 6);
-               *pa_bits = pae ? 36 : 32;
+               *pa_bits == kvm_cpu_has(X86_FEATURE_PAE) ? 36 : 32;
                *va_bits = 32;
        } else {
                entry = kvm_get_supported_cpuid_entry(0x80000008);