Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-15 Thread Yu Zhang
On 8/15/2017 12:40 AM, Paolo Bonzini wrote: On 14/08/2017 18:13, Jim Mattson wrote: ctxt->ops->get_msr(ctxt, MSR_EFER, ); - if (efer & EFER_LMA) - rsvd = CR3_L_MODE_RESERVED_BITS & ~CR3_PCID_INVD; + if (efer & EFER_LMA) { +

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-15 Thread Yu Zhang
On 8/15/2017 12:40 AM, Paolo Bonzini wrote: On 14/08/2017 18:13, Jim Mattson wrote: ctxt->ops->get_msr(ctxt, MSR_EFER, ); - if (efer & EFER_LMA) - rsvd = CR3_L_MODE_RESERVED_BITS & ~CR3_PCID_INVD; + if (efer & EFER_LMA) { +

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Paolo Bonzini
On 14/08/2017 18:13, Jim Mattson wrote: >> ctxt->ops->get_msr(ctxt, MSR_EFER, ); >> - if (efer & EFER_LMA) >> - rsvd = CR3_L_MODE_RESERVED_BITS & ~CR3_PCID_INVD; >> + if (efer & EFER_LMA) { >> + u64 maxphyaddr;

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Paolo Bonzini
On 14/08/2017 18:13, Jim Mattson wrote: >> ctxt->ops->get_msr(ctxt, MSR_EFER, ); >> - if (efer & EFER_LMA) >> - rsvd = CR3_L_MODE_RESERVED_BITS & ~CR3_PCID_INVD; >> + if (efer & EFER_LMA) { >> + u64 maxphyaddr;

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Jim Mattson
On Sat, Aug 12, 2017 at 6:35 AM, Yu Zhang wrote: > Currently, KVM uses CR3_L_MODE_RESERVED_BITS to check the > reserved bits in CR3. Yet the length of reserved bits in > guest CR3 should be based on the physical address width > exposed to the VM. This patch changes CR3

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Jim Mattson
On Sat, Aug 12, 2017 at 6:35 AM, Yu Zhang wrote: > Currently, KVM uses CR3_L_MODE_RESERVED_BITS to check the > reserved bits in CR3. Yet the length of reserved bits in > guest CR3 should be based on the physical address width > exposed to the VM. This patch changes CR3 check logic to > calculate

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Yu Zhang
On 8/14/2017 3:36 PM, Paolo Bonzini wrote: On 12/08/2017 15:35, Yu Zhang wrote: + ctxt->ops->get_cpuid(ctxt, , NULL, NULL, NULL); + maxphyaddr = eax * 0xff; This is "&", not "*". You can also use rsvd_bits here. Oops. Sorry for the typo. :-) +

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Yu Zhang
On 8/14/2017 3:36 PM, Paolo Bonzini wrote: On 12/08/2017 15:35, Yu Zhang wrote: + ctxt->ops->get_cpuid(ctxt, , NULL, NULL, NULL); + maxphyaddr = eax * 0xff; This is "&", not "*". You can also use rsvd_bits here. Oops. Sorry for the typo. :-) +

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Paolo Bonzini
On 12/08/2017 15:35, Yu Zhang wrote: > + ctxt->ops->get_cpuid(ctxt, , NULL, NULL, NULL); > + maxphyaddr = eax * 0xff; This is "&", not "*". You can also use rsvd_bits here. > + rsvd = (~((1UL << maxphyaddr) - 1)) & > +

Re: [PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-14 Thread Paolo Bonzini
On 12/08/2017 15:35, Yu Zhang wrote: > + ctxt->ops->get_cpuid(ctxt, , NULL, NULL, NULL); > + maxphyaddr = eax * 0xff; This is "&", not "*". You can also use rsvd_bits here. > + rsvd = (~((1UL << maxphyaddr) - 1)) & > +

[PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-12 Thread Yu Zhang
Currently, KVM uses CR3_L_MODE_RESERVED_BITS to check the reserved bits in CR3. Yet the length of reserved bits in guest CR3 should be based on the physical address width exposed to the VM. This patch changes CR3 check logic to calculate the reserved bits at runtime. Signed-off-by: Yu Zhang

[PATCH v1 1/4] KVM: MMU: check guest CR3 reserved bits based on its physical address width.

2017-08-12 Thread Yu Zhang
Currently, KVM uses CR3_L_MODE_RESERVED_BITS to check the reserved bits in CR3. Yet the length of reserved bits in guest CR3 should be based on the physical address width exposed to the VM. This patch changes CR3 check logic to calculate the reserved bits at runtime. Signed-off-by: Yu Zhang ---