From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sheng Yang Subject: [PATCH] KVM: VMX: Fix repeatly allocate of apic access page Date: Tue, 6 Nov 2007 11:00:35 +0800 Message-ID: <200711061100.35700.sheng.yang@intel.com> Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_Tj9LH9hAKEyOtKD" To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Errors-To: kvm-devel-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: kvm.vger.kernel.org --Boundary-00=_Tj9LH9hAKEyOtKD Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline =46rom 05164d73994a88ae130a086b592cd127c15a617f Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Tue, 6 Nov 2007 11:37:44 +0800 Subject: [PATCH] KVM: VMX: Fix repeatly allocate of apic access page =46or SMP guest, alloc_apic_access_page() would be called more than once. So only the last one works, causing SMP guest can't benifit from FlexPriori= ty. This patch fixed this issue. Signed-off-by: Sheng Yang =2D-- drivers/kvm/vmx.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index 42e7fad..6670e2b 100644 =2D-- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -1463,18 +1463,24 @@ static void seg_setup(int seg) static int alloc_apic_access_page(struct kvm *kvm) { struct kvm_userspace_memory_region kvm_userspace_mem; =2D int r; + int r =3D 0; =20 =2D r =3D -EFAULT; + mutex_lock(&kvm->lock); + if (kvm->apic_access_page) + goto out; + mutex_unlock(&kvm->lock); kvm_userspace_mem.slot =3D APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; kvm_userspace_mem.flags =3D 0; kvm_userspace_mem.guest_phys_addr =3D 0xfee00000ULL; kvm_userspace_mem.memory_size =3D PAGE_SIZE; r =3D kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); if (r) =2D return r; + goto out; + mutex_lock(&kvm->lock); kvm->apic_access_page =3D gfn_to_page(kvm, 0xfee00); =2D return 0; +out: + mutex_unlock(&kvm->lock); + return r; } =20 /* =2D-=20 1.5.2 --Boundary-00=_Tj9LH9hAKEyOtKD Content-Type: text/x-diff; charset="utf-8"; name="0001-KVM-VMX-Fix-repeatly-allocate-of-apic-access-page.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-KVM-VMX-Fix-repeatly-allocate-of-apic-access-page.patch" =46rom 05164d73994a88ae130a086b592cd127c15a617f Mon Sep 17 00:00:00 2001 =46rom: Sheng Yang Date: Tue, 6 Nov 2007 11:37:44 +0800 Subject: [PATCH] KVM: VMX: Fix repeatly allocate of apic access page =46or SMP guest, alloc_apic_access_page() would be called more than once. So only the last one works, causing SMP guest can't benifit from FlexPriori= ty. This patch fixed this issue. Signed-off-by: Sheng Yang =2D-- drivers/kvm/vmx.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index 42e7fad..6670e2b 100644 =2D-- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -1463,18 +1463,24 @@ static void seg_setup(int seg) static int alloc_apic_access_page(struct kvm *kvm) { struct kvm_userspace_memory_region kvm_userspace_mem; =2D int r; + int r =3D 0; =20 =2D r =3D -EFAULT; + mutex_lock(&kvm->lock); + if (kvm->apic_access_page) + goto out; + mutex_unlock(&kvm->lock); kvm_userspace_mem.slot =3D APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; kvm_userspace_mem.flags =3D 0; kvm_userspace_mem.guest_phys_addr =3D 0xfee00000ULL; kvm_userspace_mem.memory_size =3D PAGE_SIZE; r =3D kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); if (r) =2D return r; + goto out; + mutex_lock(&kvm->lock); kvm->apic_access_page =3D gfn_to_page(kvm, 0xfee00); =2D return 0; +out: + mutex_unlock(&kvm->lock); + return r; } =20 /* =2D-=20 1.5.2 --Boundary-00=_Tj9LH9hAKEyOtKD Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ --Boundary-00=_Tj9LH9hAKEyOtKD Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kvm-devel mailing list kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/kvm-devel --Boundary-00=_Tj9LH9hAKEyOtKD--