From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753677AbbIPJOi (ORCPT ); Wed, 16 Sep 2015 05:14:38 -0400 Received: from blu004-omc1s33.hotmail.com ([65.55.116.44]:57885 "EHLO BLU004-OMC1S33.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752640AbbIPJOf (ORCPT ); Wed, 16 Sep 2015 05:14:35 -0400 X-TMN: [6zBG8FgTLqm1aVb4dj73zS1aAjNz5eWl] X-Originating-Email: [wanpeng.li@hotmail.com] Message-ID: Subject: Re: [PATCH v4 1/2] KVM: nVMX: enhance allocate/free_vpid to handle shadow vpid To: Jan Kiszka , Paolo Bonzini References: <1442387950-116085-1-git-send-email-wanpeng.li@hotmail.com> <55F9323A.3080900@siemens.com> CC: Bandan Das , Wincy Van , kvm@vger.kernel.org, linux-kernel@vger.kernel.org From: Wanpeng Li Date: Wed, 16 Sep 2015 17:14:27 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <55F9323A.3080900@siemens.com> Content-Type: text/plain; charset="iso-8859-15"; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 16 Sep 2015 09:14:32.0392 (UTC) FILETIME=[19311C80:01D0F060] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/16/15 5:11 PM, Jan Kiszka wrote: > On 2015-09-16 09:19, Wanpeng Li wrote: >> Enhance allocate/free_vid to handle shadow vpid. >> >> Signed-off-by: Wanpeng Li >> --- >> arch/x86/kvm/vmx.c | 23 +++++++++++------------ >> 1 file changed, 11 insertions(+), 12 deletions(-) >> >> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c >> index 9ff6a3f..c5222b8 100644 >> --- a/arch/x86/kvm/vmx.c >> +++ b/arch/x86/kvm/vmx.c >> @@ -4155,29 +4155,28 @@ static int alloc_identity_pagetable(struct kvm *kvm) >> return r; >> } >> >> -static void allocate_vpid(struct vcpu_vmx *vmx) >> +static int allocate_vpid(void) >> { >> int vpid; >> >> - vmx->vpid = 0; >> if (!enable_vpid) >> - return; >> + return 0; >> spin_lock(&vmx_vpid_lock); >> vpid = find_first_zero_bit(vmx_vpid_bitmap, VMX_NR_VPIDS); >> - if (vpid < VMX_NR_VPIDS) { >> - vmx->vpid = vpid; >> + if (vpid < VMX_NR_VPIDS) >> __set_bit(vpid, vmx_vpid_bitmap); >> - } >> + else >> + vpid = 0; >> spin_unlock(&vmx_vpid_lock); >> + return vpid; >> } >> >> -static void free_vpid(struct vcpu_vmx *vmx) >> +static void free_vpid(int vpid) >> { >> if (!enable_vpid) > || vpid == 0 > > Otherwise you clear bit zero and cause the next allocate_vpid return 0 - > from the bitmap. Will do, thanks. :-) Regards, Wanpeng Li