From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: [PATCH] KVM: VMX: Fix repeatly allocate of apic access page
Date: Tue, 6 Nov 2007 11:00:35 +0800 [thread overview]
Message-ID: <200711061100.35700.sheng.yang@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1526 bytes --]
From 05164d73994a88ae130a086b592cd127c15a617f Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Tue, 6 Nov 2007 11:37:44 +0800
Subject: [PATCH] KVM: VMX: Fix repeatly allocate of apic access page
For 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 FlexPriority.
This patch fixed this issue.
Signed-off-by: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
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
--- 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;
- int r;
+ int r = 0;
- r = -EFAULT;
+ mutex_lock(&kvm->lock);
+ if (kvm->apic_access_page)
+ goto out;
+ mutex_unlock(&kvm->lock);
kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT;
kvm_userspace_mem.flags = 0;
kvm_userspace_mem.guest_phys_addr = 0xfee00000ULL;
kvm_userspace_mem.memory_size = PAGE_SIZE;
r = kvm_set_memory_region(kvm, &kvm_userspace_mem, 0);
if (r)
- return r;
+ goto out;
+ mutex_lock(&kvm->lock);
kvm->apic_access_page = gfn_to_page(kvm, 0xfee00);
- return 0;
+out:
+ mutex_unlock(&kvm->lock);
+ return r;
}
/*
--
1.5.2
[-- Attachment #2: 0001-KVM-VMX-Fix-repeatly-allocate-of-apic-access-page.patch --]
[-- Type: text/x-diff, Size: 1526 bytes --]
From 05164d73994a88ae130a086b592cd127c15a617f Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Date: Tue, 6 Nov 2007 11:37:44 +0800
Subject: [PATCH] KVM: VMX: Fix repeatly allocate of apic access page
For 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 FlexPriority.
This patch fixed this issue.
Signed-off-by: Sheng Yang <sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
---
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
--- 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;
- int r;
+ int r = 0;
- r = -EFAULT;
+ mutex_lock(&kvm->lock);
+ if (kvm->apic_access_page)
+ goto out;
+ mutex_unlock(&kvm->lock);
kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT;
kvm_userspace_mem.flags = 0;
kvm_userspace_mem.guest_phys_addr = 0xfee00000ULL;
kvm_userspace_mem.memory_size = PAGE_SIZE;
r = kvm_set_memory_region(kvm, &kvm_userspace_mem, 0);
if (r)
- return r;
+ goto out;
+ mutex_lock(&kvm->lock);
kvm->apic_access_page = gfn_to_page(kvm, 0xfee00);
- return 0;
+out:
+ mutex_unlock(&kvm->lock);
+ return r;
}
/*
--
1.5.2
[-- Attachment #3: Type: text/plain, Size: 314 bytes --]
-------------------------------------------------------------------------
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/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
next reply other threads:[~2007-11-06 3:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-06 3:00 Sheng Yang [this message]
[not found] ` <200711061100.35700.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2007-11-06 9:23 ` [PATCH] KVM: VMX: Fix repeatly allocate of apic access page Avi Kivity
-- strict thread matches above, loose matches on Subject: below --
2007-11-06 9:55 Sheng Yang
[not found] ` <200711061755.14444.sheng.yang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2007-11-06 10:04 ` Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711061100.35700.sheng.yang@intel.com \
--to=sheng.yang-ral2jqcrhueavxtiumwx3w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox