Skip to contentSkip to conversation

x86: Correctly report max number of hypervisor leaves

PATCH In review Boris Ostrovsky 3 participants 3 messages May 30, 2014 – Jun 2, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: Correctly report max number of hypervisor leaves

Commit def0bbd31 provided support for changing max number of hypervisor cpuid leaves (in leaf 0x4000xx00). It also made the hypervisor incorrectly report this number for guests that use default value (i.e. don't specify leaf 0x4000xx00 in config file)

---
 xen/arch/x86/traps.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
xen/arch/x86/traps.c +11 -5
index 1722912..b82b1b3 100644
@@ -692,13 +692,19 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
     if ( idx > XEN_CPUID_MAX_NUM_LEAVES )
         return 0; /* Avoid unnecessary pass through domain_cpuid() */
 
-    /* Number of leaves may be user-specified */
     domain_cpuid(d, base, 0, &limit, &dummy, &dummy, &dummy);
-    limit &= 0xff;
-    if ( limit < 2 )
-        limit = 2;
-    else if ( limit > XEN_CPUID_MAX_NUM_LEAVES )
+    if ( limit == 0 )
+        /* Default number of leaves */
         limit = XEN_CPUID_MAX_NUM_LEAVES;
+    else
+    {
+        /* User-specified number of leaves */
+        limit &= 0xff;
+        if ( limit < 2 )
+            limit = 2;
+        else if ( limit > XEN_CPUID_MAX_NUM_LEAVES )
+            limit = XEN_CPUID_MAX_NUM_LEAVES;
+    }
 
     if ( idx > limit ) 
         return 0;
Signature · 1 line
1.7.1
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Boris Ostrovsky

Commit def0bbd31 provided support for changing max number of hypervisor cpuid leaves (in leaf 0x4000xx00). It also made the hypervisor incorrectly report this number for guests that use default value (i.e. don't specify leaf 0x4000xx00 in config file)

However I think we should prevent PVH guests from seeing the newly introduced XEN_HVM_CPUID_APIC_ACCESS_VIRT and XEN_HVM_CPUID_X2APIC_VIRT flags. I have the following patch, but it still adds one more is_pvh_vcpu into VMX code. I've tried checking for vlapic_enabled, but it also returns true for PVH guests.

xen/arch/x86/hvm/vmx/vmx.c +1 -1
index d45fb7f..ecc010e 100644
@@ -1660,7 +1660,7 @@ void vmx_hypervisor_cpuid_leaf(uint32_t sub_idx,
                                uint32_t *eax, uint32_t *ebx,
                                uint32_t *ecx, uint32_t *edx)
 {
-    if ( sub_idx != 0 )
+    if ( sub_idx != 0 || is_pvh_vcpu(current) )
         return;
     if ( cpu_has_vmx_apic_reg_virt )
         *eax |= XEN_HVM_CPUID_APIC_ACCESS_VIRT;
#2 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 02.06.14 at 11:29, <[email protected]> wrote:
Quoted 8 lines · Boris Ostrovsky

Commit def0bbd31 provided support for changing max number of hypervisor cpuid leaves (in leaf 0x4000xx00). It also made the hypervisor incorrectly report this number for guests that use default value (i.e. don't specify leaf 0x4000xx00 in config file)

Quoted 7 lines

However I think we should prevent PVH guests from seeing the newly introduced XEN_HVM_CPUID_APIC_ACCESS_VIRT and XEN_HVM_CPUID_X2APIC_VIRT flags. I have the following patch, but it still adds one more is_pvh_vcpu into VMX code. I've tried checking for vlapic_enabled, but it also returns true for PVH guests.

And vlapic_enabled() wouldn't be the right qualifier anyway, as feature availability doesn't depend on what other features are enabled. I think is_pvh is fine for now here, until the folding of PVH and HVM got far enough.

Jan

xen/arch/x86/hvm/vmx/vmx.c void vmx_hypervisor_cpuid_leaf(uint32_t sub_idx, · line 1666

Quoted 11 lines
xen/arch/x86/hvm/vmx/vmx.c +1 -1
@@ -1660,7 +1660,7 @@ void vmx_hypervisor_cpuid_leaf(uint32_t sub_idx,
                                uint32_t *eax, uint32_t *ebx,
                                uint32_t *ecx, uint32_t *edx)
 {
-    if ( sub_idx != 0 )
+    if ( sub_idx != 0 || is_pvh_vcpu(current) )
         return;
     if ( cpu_has_vmx_apic_reg_virt )
         *eax |= XEN_HVM_CPUID_APIC_ACCESS_VIRT;

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel