Skip to contentSkip to conversation

libxc: Expose the 1GB pages cpuid flag to guest

PATCH In review Liang Li 6 participants 10 messages Nov 28, 2014 – Jan 8, 2015

lore
Share & tools
lore

Liang Li

author
#0 lore raw

PATCH v4 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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 1 file changed, 3 insertions(+)
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;
 
Signature · 1 line
1.9.1
Reviewed-by on v4 1/1
#1 lore raw
Quoted 11 lines
Quoted 1 line
Quoted 1 line · On 28.11.14 at 11:52, <[email protected]> wrote:

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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

#2 lore raw
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 28.11.14 at 11:52, <[email protected]> wrote:

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.

Quoted 8 lines
Quoted 6 lines

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

Acked + applied (to 4.6), thanks.

#3 lore raw
In reply to Liang Li
Quoted 10 lines · Liang Li

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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Quoted 32 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 1 file changed, 3 insertions(+)
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;
 
#4 lore raw
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Liang Li

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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

Quoted 5 lines
Quoted 2 lines

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Jan acked it.

Quoted 40 lines
Quoted 26 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 1 file changed, 3 insertions(+)
tools/libxc/xc_cpuid_x86.c +2 -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;

tools/libxc/xc_cpuid_x86.c static void xc_cpuid_hvm_policy( · line 394

Quoted 7 lines
tools/libxc/xc_cpuid_x86.c +1 -0
@@ -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-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#5 lore raw
Quoted 10 lines · Konrad Rzeszutek Wilk
Quoted 9 lines · Ian Campbell
Quoted 8 lines · Liang Li

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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Jan acked it.

For 4.5?

Have you release acked it?

This seemed like 4.6 material to me, or at least I've not seen any mention/argument to the contrary.

Ian.

Quoted 40 lines
Quoted 40 lines
Quoted 26 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 1 file changed, 3 insertions(+)
tools/libxc/xc_cpuid_x86.c +2 -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;

tools/libxc/xc_cpuid_x86.c static void xc_cpuid_hvm_policy( · line 394

Quoted 7 lines
tools/libxc/xc_cpuid_x86.c +1 -0
@@ -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-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#6 lore raw
Quoted 14 lines · Ian Campbell
Quoted 13 lines · Konrad Rzeszutek Wilk
Quoted 12 lines · Ian Campbell
Quoted 10 lines · Liang Li

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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Jan acked it.

For 4.5?

Probably not.

Quoted 2 lines

Have you release acked it?

No.

Quoted 3 lines

This seemed like 4.6 material to me, or at least I've not seen any mention/argument to the contrary.

Correct. 4.6 please.

Quoted 45 lines

Ian.

Quoted 40 lines
Quoted 40 lines
Quoted 26 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 1 file changed, 3 insertions(+)
tools/libxc/xc_cpuid_x86.c +2 -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;

tools/libxc/xc_cpuid_x86.c static void xc_cpuid_hvm_policy( · line 394

Quoted 7 lines
tools/libxc/xc_cpuid_x86.c +1 -0
@@ -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-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#7 lore raw

Konrad Rzeszutek Wilk wrote on 2014-12-03:

Quoted 24 lines · Ian Campbell
Quoted 14 lines · Konrad Rzeszutek Wilk
Quoted 13 lines · Ian Campbell
Quoted 12 lines · Liang Li
Quoted 10 lines

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.

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Jan acked it.

For 4.5?

Probably not.

Quoted 1 line
Quoted 8 lines
Quoted 1 line

Have you release acked it?

No.

Quoted 3 lines

This seemed like 4.6 material to me, or at least I've not seen any mention/argument to the contrary.

Correct. 4.6 please.

I think this more like a bug fixing than a feature. See our previous discussion.

Quoted 45 lines
Quoted 4 lines

Ian.

Quoted 1 line
Quoted 1 line
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

tools/libxc/xc_cpuid_x86.c static void amd_xc_cpuid_policy( · line 109

Quoted 9 lines
---
 tools/libxc/xc_cpuid_x86.c | 3 +++
 1 file changed, 3 insertions(+)
tools/libxc/xc_cpuid_x86.c +0 -0
index a18b1ff..c97f91a 100644
@@ -109,6 +109,7 @@ static void amd_xc_cpuid_policy(
         regs[3] &= (0x0183f3ff | /* features shared with

0x00000001:EDX */

Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
Quoted 20 lines
tools/libxc/xc_cpuid_x86.c +1 -0
                     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]);
         }
Quoted 10 lines
Quoted 8 lines
Quoted 8 lines

tools/libxc/xc_cpuid_x86.c static void xc_cpuid_hvm_policy( · line 393

Quoted 1 line
tools/libxc/xc_cpuid_x86.c +0 -0
         break;

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

Quoted 4 lines

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

Best regards,
Yang

Quoted 41 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · Ian Campbell
Quoted 3 lines · Jan Beulich

In fact I can't see where this would be forced off: xc_cpuid_x86.c only does so in the PV case, and all hvm_pse1gb_supported() is that the CPU supports it and the domain uses HAP.

Took me a while to spot it too:
static void intel_xc_cpuid_policy(
[...]

            case 0x80000001: {
                int is_64bit = hypervisor_is_64bit(xch) && is_pae;

                /* Only a few features are advertised in Intel's 0x80000001. */
                regs[2] &= (is_64bit ? bitmaskof(X86_FEATURE_LAHF_LM) : 0) |
                                       bitmaskof(X86_FEATURE_ABM);
                regs[3] &= ((is_pae ? bitmaskof(X86_FEATURE_NX) : 0) |
                            (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
                            (is_64bit ? bitmaskof(X86_FEATURE_SYSCALL) : 0) |
                            (is_64bit ? bitmaskof(X86_FEATURE_RDTSCP) : 0));
                break;
            }
Quoted 2 lines

Which masks anything which is not explicitly mentioned. (PAGE1GB is in regs[3], I think).

Ah, okay. The funs of white listing on HVM vs black listing on PV again.

Quoted 12 lines

The AMD version is more permissive:

        regs[3] &= (0x0183f3ff | /* features shared with 0x00000001:EDX */
                    (is_pae ? bitmaskof(X86_FEATURE_NX) : 0) |
                    (is_64bit ? bitmaskof(X86_FEATURE_LM) : 0) |
                    bitmaskof(X86_FEATURE_SYSCALL) |
                    bitmaskof(X86_FEATURE_MP) |
                    bitmaskof(X86_FEATURE_MMXEXT) |
                    bitmaskof(X86_FEATURE_FFXSR) |
                    bitmaskof(X86_FEATURE_3DNOW) |
                    bitmaskof(X86_FEATURE_3DNOWEXT));
Quoted 3 lines
Quoted 1 line

(but I didn't check if PAGE1GB is in that magic number...)

It's not - it's bit 26.

So.. it sounds to me like everybody is in the agreement that this is the right thing to do (enable it if the hypervisor has it enabled)?

And the next thing is actually come up with a patch to do some of this plumbing - naturally for Xen 4.5?

Quoted 3 lines

Jan

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

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

#8 lore raw
Quoted 18 lines · Yang Z

Konrad Rzeszutek Wilk wrote on 2014-12-03:

Quoted 17 lines · Ian Campbell
Quoted 16 lines · Konrad Rzeszutek Wilk
Quoted 15 lines · Ian Campbell
Quoted 5 lines · Liang Li
Quoted 4 lines

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.

Quoted 8 lines
Quoted 6 lines

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Jan acked it.

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

For 4.5?

Probably not.

Quoted 1 line

Have you release acked it?

No.

Quoted 2 lines

This seemed like 4.6 material to me, or at least I've not seen any mention/argument to the contrary.

Correct. 4.6 please.

I think this more like a bug fixing than a feature. See our previous discussion.

It is allowing HVM guests to use a brand new hardware feature which was previously unavailable to them.

It is absolutely not a bugfix, and not appropriate for 4.5 at this point, but a good candidate for acceptance as soon as the 4.6 dev window opens.

~Andrew

#9 lore raw

Andrew Cooper wrote on 2014-12-04:

Quoted 19 lines · Yang Z
Quoted 18 lines

Konrad Rzeszutek Wilk wrote on 2014-12-03:

Quoted 17 lines · Ian Campbell
Quoted 16 lines · Konrad Rzeszutek Wilk
Quoted 15 lines · Ian Campbell
Quoted 5 lines · Liang Li
Quoted 4 lines

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.

Quoted 8 lines
Quoted 6 lines

If guest use shadow mode, the 1GB pages feature will be hidden from guest, this is done in the function hvm_cpuid(). So the change is okay for shadow mode case.

FTR although this is strictly speaking a toolstack patch I think the main ack required should be from the x86 hypervisor guys...

Jan acked it.

Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines

For 4.5? Probably not. Have you release acked it? No. This seemed like 4.6 material to me, or at least I've not seen any mention/argument to the contrary.

Correct. 4.6 please.

I think this more like a bug fixing than a feature. See our previous discussion.

It is allowing HVM guests to use a brand new hardware feature which was previously unavailable to them.

Actually, we have regular test case to cover 1G page size which exposing the 1G feature manually through config file. And we also have a bug to track this issue. So it more likes a bugfix to me. But you are right. It is a new feature from guest's point.

Quoted 3 lines

It is absolutely not a bugfix, and not appropriate for 4.5 at this point, but a good candidate for acceptance as soon as the 4.6 dev window opens.

Agree.

Quoted 2 lines

~Andrew

Best regards,
Yang