Skip to contentSkip to conversation

libxc: Expose the 1GB pages cpuid flag to guest

PATCH Superseded Liang Li 3 participants 6 messages Nov 28, 2014

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Liang Li

author
#0 lore raw

PATCH v3 1/1 libxc: Expose the 1GB pages cpuid flag to guest

If hardware support the 1GB pages, expose the feature to guest by default. Users don't have to use a 'cpuid= ' option in config fil e to turn it on.

---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 xen/arch/x86/hvm/hvm.c     | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
tools/libxc/xc_cpuid_x86.c +3 -0
index a18b1ff..c97f91a 100644
@@ -109,6 +109,7 @@ static void amd_xc_cpuid_policy(
         regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */
                     bitmaskof(X86_FEATURE_NX) |
                     bitmaskof(X86_FEATURE_LM) |
+                    bitmaskof(X86_FEATURE_PAGE1GB) |
                     bitmaskof(X86_FEATURE_SYSCALL) |
                     bitmaskof(X86_FEATURE_MP) |
                     bitmaskof(X86_FEATURE_MMXEXT) |
@@ -192,6 +193,7 @@ static void intel_xc_cpuid_policy(
                     bitmaskof(X86_FEATURE_ABM));
         regs[3] &= (bitmaskof(X86_FEATURE_NX) |
                     bitmaskof(X86_FEATURE_LM) |
+                    bitmaskof(X86_FEATURE_PAGE1GB) |
                     bitmaskof(X86_FEATURE_SYSCALL) |
                     bitmaskof(X86_FEATURE_RDTSCP));
         break;
@@ -386,6 +388,7 @@ static void xc_cpuid_hvm_policy(
             clear_bit(X86_FEATURE_LM, regs[3]);
             clear_bit(X86_FEATURE_NX, regs[3]);
             clear_bit(X86_FEATURE_PSE36, regs[3]);
+            clear_bit(X86_FEATURE_PAGE1GB, regs[3]);
         }
         break;
 
xen/arch/x86/hvm/hvm.c +1 -1
index 8f49b44..c825618 100644
@@ -4287,7 +4287,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
              !host_tsc_is_safe() )
             *edx &= ~cpufeat_mask(X86_FEATURE_RDTSCP);
         /* Hide 1GB-superpage feature if we can't emulate it. */
-        if (!hvm_pse1gb_supported(d))
+        if (!hvm_pse1gb_supported(d) || paging_mode_shadow(d))
             *edx &= ~cpufeat_mask(X86_FEATURE_PAGE1GB);
         /* Only provide PSE36 when guest runs in 32bit PAE or in long mode */
         if ( !(hvm_pae_enabled(v) || hvm_long_mode_enabled(v)) )
Signature · 1 line
1.9.1
#1 lore raw

xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, · line 4291

Quoted 10 lines
Quoted 1 line
Quoted 1 line · On 28.11.14 at 04:28, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +1 -1
@@ -4287,7 +4287,7 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx,
              !host_tsc_is_safe() )
             *edx &= ~cpufeat_mask(X86_FEATURE_RDTSCP);
         /* Hide 1GB-superpage feature if we can't emulate it. */
-        if (!hvm_pse1gb_supported(d))
+        if (!hvm_pse1gb_supported(d) || paging_mode_shadow(d))
             *edx &= ~cpufeat_mask(X86_FEATURE_PAGE1GB);

With

#define hvm_pse1gb_supported(d) \
    (cpu_has_page1gb && paging_mode_hap(d))

the change above is pointless. While, considering this, comments on v2 may have been misleading, you should have simply updated the patch description instead to clarify why the v2 change was okay even for the shadow mode case.

Jan

#2 lore raw
Quoted 11 lines

xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, · line 4291

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1 -1
-        if (!hvm_pse1gb_supported(d))
+        if (!hvm_pse1gb_supported(d) || paging_mode_shadow(d))
             *edx &= ~cpufeat_mask(X86_FEATURE_PAGE1GB);

With

#define hvm_pse1gb_supported(d) \
   (cpu_has_page1gb && paging_mode_hap(d))

the change above is pointless. While, considering this, comments on
v2 may have been misleading, you should have simply updated the patch description instead to clarify why the v2 change was okay even for the shadow mode case.

I checked the code and found that for a normal guest can only be in hap mode or shadow mode before I sending the patch, but I am not share if it's true for dom0.

Liang

#3 lore raw
Quoted 5 lines · Liang Z
Quoted 5 lines

xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, · line 4291

Quoted 3 lines
xen/arch/x86/hvm/hvm.c +1 -1
-        if (!hvm_pse1gb_supported(d))
+        if (!hvm_pse1gb_supported(d) || paging_mode_shadow(d))
             *edx &= ~cpufeat_mask(X86_FEATURE_PAGE1GB);

With

Quoted 7 lines
Quoted 4 lines
#define hvm_pse1gb_supported(d) \
   (cpu_has_page1gb && paging_mode_hap(d))

the change above is pointless. While, considering this, comments on
v2 may have been misleading, you should have simply updated the patch description instead to clarify why the v2 change was okay even for the shadow mode case.

I checked the code and found that for a normal guest can only be in hap mode or shadow mode before I sending the patch, but I am not share if it's true for dom0.

Liang

Dom0 may either be PV (in which case neither hap nor shadow, and cant use 1GB pages anyway), or experimentally PVH which is currently restricted to hap.

~Andrew

#4 lore raw
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
   (cpu_has_page1gb && paging_mode_hap(d)) the change above is 

pointless. While, considering this, comments on
v2 may have been misleading, you should have simply updated the patch description instead to clarify why the v2 change was okay even for the shadow mode case.

I checked the code and found that for a normal guest can only be in hap mode or shadow mode before I sending the patch, but I am not share if it's true for dom0.

Liang

Dom0 may either be PV (in which case neither hap nor shadow, and cant use 1GB pages anyway), or experimentally PVH which is currently restricted to hap.

~Andrew

Thanks for clarification. I will resend the v2 patch.

Liang

#5 lore raw
In reply to Li, Liang Z
Quoted 10 lines
Quoted 9 lines

xen/arch/x86/hvm/hvm.c void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, · line 4291

Quoted 4 lines · On 28.11.14 at 11:29, <[email protected]> wrote:
xen/arch/x86/hvm/hvm.c +1 -1
-        if (!hvm_pse1gb_supported(d))
+        if (!hvm_pse1gb_supported(d) || paging_mode_shadow(d))
             *edx &= ~cpufeat_mask(X86_FEATURE_PAGE1GB);

With

#define hvm_pse1gb_supported(d) \
   (cpu_has_page1gb && paging_mode_hap(d))
Quoted 8 lines
Quoted 2 lines

the change above is pointless. While, considering this, comments on v2 may have been misleading, you should have simply updated the patch

description instead to clarify why the v2 change was okay even for the shadow mode case.

I checked the code and found that for a normal guest can only be in hap mode or shadow mode before I sending the patch, but I am not share if it's true for dom0.

The CPUID code in libxc doesn't apply to Dom0 at all, and CPUID handling is also special cased in the hypervisor for Dom0. Plus finally Dom0 only possibly being PV or PVH, PVH requiring HAP and PV generally not allowing large pages anyway, your concern is unnecessary.

Jan