Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1224987 > unrolled thread
| Started by | Wanpeng Li <wanpeng.li@hotmail.com> |
|---|---|
| First post | 2015-09-15 12:40 +0200 |
| Last post | 2015-09-16 06:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid Wanpeng Li <wanpeng.li@hotmail.com> - 2015-09-15 12:40 +0200
Re: [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid Paolo Bonzini <pbonzini@redhat.com> - 2015-09-15 15:00 +0200
Re: [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid Wanpeng Li <wanpeng.li@hotmail.com> - 2015-09-16 06:00 +0200
| From | Wanpeng Li <wanpeng.li@hotmail.com> |
|---|---|
| Date | 2015-09-15 12:40 +0200 |
| Subject | [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid |
| Message-ID | <q8VOy-2cy-15@gated-at.bofh.it> |
Enhance allocate/free_vid to handle shadow vpid.
Suggested-by: Wincy Van <fanwenyi0529@gmail.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
arch/x86/kvm/vmx.c | 33 +++++++++++++++++++++++++++------
1 file changed, 27 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index da1590e..bd07d88 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -424,6 +424,8 @@ struct nested_vmx {
/* to migrate it to L2 if VM_ENTRY_LOAD_DEBUG_CONTROLS is off */
u64 vmcs01_debugctl;
+ u16 vpid02;
+
u32 nested_vmx_procbased_ctls_low;
u32 nested_vmx_procbased_ctls_high;
u32 nested_vmx_true_procbased_ctls_low;
@@ -4155,18 +4157,29 @@ static int alloc_identity_pagetable(struct kvm *kvm)
return r;
}
-static void allocate_vpid(struct vcpu_vmx *vmx)
+static void allocate_vpid(struct vcpu_vmx *vmx, bool nested)
{
int vpid;
- vmx->vpid = 0;
if (!enable_vpid)
return;
+ if (!nested)
+ vmx->vpid = 0;
+ else
+ vmx->nested.vpid02 = 0;
spin_lock(&vmx_vpid_lock);
- vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
- if (vpid < VMX_NR_VPIDS) {
+ if (!nested) {
+ vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
+ if (vpid < VMX_NR_VPIDS) {
vmx->vpid = vpid;
__set_bit(vpid, vmx_vpid_bitmap);
+ }
+ } else {
+ vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
+ if (vpid < VMX_NR_VPIDS) {
+ vmx->nested.vpid02 = vpid;
+ __set_bit(vpid, vmx_vpid_bitmap);
+ }
}
spin_unlock(&vmx_vpid_lock);
}
@@ -4178,6 +4191,12 @@ static void free_vpid(struct vcpu_vmx *vmx)
spin_lock(&vmx_vpid_lock);
if (vmx->vpid != 0)
__clear_bit(vmx->vpid, vmx_vpid_bitmap);
+ if (!nested) {
+ spin_unlock(&vmx_vpid_lock);
+ return;
+ }
+ if (vmx->nested.vpid02)
+ __clear_bit(vmx->nested.vpid02, vmx_vpid_bitmap);
spin_unlock(&vmx_vpid_lock);
}
@@ -8509,7 +8528,7 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
if (!vmx)
return ERR_PTR(-ENOMEM);
- allocate_vpid(vmx);
+ allocate_vpid(vmx, false);
err = kvm_vcpu_init(&vmx->vcpu, kvm, id);
if (err)
@@ -8557,8 +8576,10 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
goto free_vmcs;
}
- if (nested)
+ if (nested) {
nested_vmx_setup_ctls_msrs(vmx);
+ allocate_vpid(vmx, true);
+ }
vmx->nested.posted_intr_nv = -1;
vmx->nested.current_vmptr = -1ull;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-09-15 15:00 +0200 |
| Subject | Re: [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid |
| Message-ID | <q8Y02-5gY-13@gated-at.bofh.it> |
| In reply to | #1224987 |
On 15/09/2015 12:30, Wanpeng Li wrote:
> + if (!nested) {
> + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
> + if (vpid < VMX_NR_VPIDS) {
> vmx->vpid = vpid;
> __set_bit(vpid, vmx_vpid_bitmap);
> + }
> + } else {
> + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
> + if (vpid < VMX_NR_VPIDS) {
> + vmx->nested.vpid02 = vpid;
> + __set_bit(vpid, vmx_vpid_bitmap);
> + }
Messy indentation, and a lot of duplicate code. Can you instead have
(which I think was Jan's suggestion too):
static int allocate_vpid(void);
static void free_vpid(int vpid);
That said, I like the simple solution to the "too many VPIDs for each L1
VCPU" processor.
Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Wanpeng Li <wanpeng.li@hotmail.com> |
|---|---|
| Date | 2015-09-16 06:00 +0200 |
| Subject | Re: [PATCH v2 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid |
| Message-ID | <q9c2Z-1aO-1@gated-at.bofh.it> |
| In reply to | #1225068 |
On 9/15/15 8:54 PM, Paolo Bonzini wrote:
>
> On 15/09/2015 12:30, Wanpeng Li wrote:
>> + if (!nested) {
>> + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
>> + if (vpid < VMX_NR_VPIDS) {
>> vmx->vpid = vpid;
>> __set_bit(vpid, vmx_vpid_bitmap);
>> + }
>> + } else {
>> + vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS);
>> + if (vpid < VMX_NR_VPIDS) {
>> + vmx->nested.vpid02 = vpid;
>> + __set_bit(vpid, vmx_vpid_bitmap);
>> + }
> Messy indentation, and a lot of duplicate code. Can you instead have
> (which I think was Jan's suggestion too):
>
> static int allocate_vpid(void);
> static void free_vpid(int vpid);
I see, done in v3.
>
> That said, I like the simple solution to the "too many VPIDs for each L1
> VCPU" processor.
Thanks. :-)
Regards,
Wanpeng Li
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web