From: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: Zhang-Rn83F4s8Lwc+UXBhvPuGgqsjOiXwFzmk@public.gmane.org,
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
Xiantao <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org
Subject: [PATCH 2 of 3] Move vm_stat and apic_access_page to kvm_x86
Date: Tue, 20 Nov 2007 10:57:14 -0600 [thread overview]
Message-ID: <7ec2ba0e8a361336d006.1195577834@basalt> (raw)
In-Reply-To: <patchbomb.1195577832@basalt>
Signed-off-by: Hollis Blanchard <hollisb-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
---
5 files changed, 18 insertions(+), 13 deletions(-)
drivers/kvm/kvm.h | 2 --
drivers/kvm/mmu.c | 14 ++++++++------
drivers/kvm/vmx.c | 11 +++++++----
drivers/kvm/x86.c | 2 +-
drivers/kvm/x86.h | 2 ++
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -315,8 +315,6 @@ struct kvm {
struct kvm_io_bus mmio_bus;
struct kvm_io_bus pio_bus;
int round_robin_prev_vcpu;
- struct page *apic_access_page;
- struct kvm_vm_stat stat;
};
struct descriptor_table {
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -761,7 +761,7 @@ static void kvm_mmu_zap_page(struct kvm
u64 *parent_pte;
struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
- ++kvm->stat.mmu_shadow_zapped;
+ ++kvm_x86->stat.mmu_shadow_zapped;
while (page->multimapped || page->parent_pte) {
if (!page->multimapped)
parent_pte = page->parent_pte;
@@ -1236,12 +1236,14 @@ static void mmu_pte_write_new_pte(struct
const void *new, int bytes,
int offset_in_pte)
{
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(vcpu->kvm);
+
if (page->role.level != PT_PAGE_TABLE_LEVEL) {
- ++vcpu->kvm->stat.mmu_pde_zapped;
+ ++kvm_x86->stat.mmu_pde_zapped;
return;
}
- ++vcpu->kvm->stat.mmu_pte_updated;
+ ++kvm_x86->stat.mmu_pte_updated;
if (page->role.glevels == PT32_ROOT_LEVEL)
paging32_update_pte(vcpu, page, spte, new, bytes,
offset_in_pte);
@@ -1277,7 +1279,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *
int npte;
pgprintk("%s: gpa %llx bytes %d\n", __FUNCTION__, gpa, bytes);
- ++vcpu->kvm->stat.mmu_pte_write;
+ ++kvm_x86->stat.mmu_pte_write;
kvm_mmu_audit(vcpu, "pre pte write");
if (gfn == vcpu->last_pt_write_gfn
&& !last_updated_pte_accessed(vcpu)) {
@@ -1311,7 +1313,7 @@ void kvm_mmu_pte_write(struct kvm_vcpu *
pgprintk("misaligned: gpa %llx bytes %d role %x\n",
gpa, bytes, page->role.word);
kvm_mmu_zap_page(vcpu->kvm, page);
- ++vcpu->kvm->stat.mmu_flooded;
+ ++kvm_x86->stat.mmu_flooded;
continue;
}
page_offset = offset;
@@ -1362,7 +1364,7 @@ void __kvm_mmu_free_some_pages(struct kv
page = container_of(kvm_x86->active_mmu_pages.prev,
struct kvm_mmu_page, link);
kvm_mmu_zap_page(vcpu->kvm, page);
- ++vcpu->kvm->stat.mmu_recycled;
+ ++kvm_x86->stat.mmu_recycled;
}
}
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -1468,11 +1468,12 @@ static void seg_setup(int seg)
static int alloc_apic_access_page(struct kvm *kvm)
{
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(kvm);
struct kvm_userspace_memory_region kvm_userspace_mem;
int r = 0;
mutex_lock(&kvm->lock);
- if (kvm->apic_access_page)
+ if (kvm_x86->apic_access_page)
goto out;
kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT;
kvm_userspace_mem.flags = 0;
@@ -1481,7 +1482,7 @@ static int alloc_apic_access_page(struct
r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0);
if (r)
goto out;
- kvm->apic_access_page = gfn_to_page(kvm, 0xfee00);
+ kvm_x86->apic_access_page = gfn_to_page(kvm, 0xfee00);
out:
mutex_unlock(&kvm->lock);
return r;
@@ -1694,9 +1695,11 @@ static int vmx_vcpu_reset(struct kvm_vcp
vmcs_write32(TPR_THRESHOLD, 0);
}
- if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm))
+ if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm)) {
+ struct kvm_x86 *kvm_x86 = to_kvm_x86(vmx->vcpu.kvm);
vmcs_write64(APIC_ACCESS_ADDR,
- page_to_phys(vmx->vcpu.kvm->apic_access_page));
+ page_to_phys(kvm_x86->apic_access_page));
+ }
vmx->vcpu.cr0 = 0x60000010;
vmx_set_cr0(&vmx->vcpu, vmx->vcpu.cr0); /* enter rmode */
diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -42,7 +42,7 @@
#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
#define EFER_RESERVED_BITS 0xfffffffffffff2fe
-#define VM_STAT(x) offsetof(struct kvm, stat.x), KVM_STAT_VM
+#define VM_STAT(x) offsetof(struct kvm_x86, stat.x), KVM_STAT_VM
#define VCPU_STAT(x) offsetof(struct kvm_vcpu, stat.x), KVM_STAT_VCPU
struct kvm_x86_ops *kvm_x86_ops;
diff --git a/drivers/kvm/x86.h b/drivers/kvm/x86.h
--- a/drivers/kvm/x86.h
+++ b/drivers/kvm/x86.h
@@ -169,6 +169,8 @@ struct kvm_x86 {
struct kvm_pic *vpic;
struct kvm_ioapic *vioapic;
unsigned int tss_addr;
+ struct page *apic_access_page;
+ struct kvm_vm_stat stat;
};
static struct kvm_x86 *to_kvm_x86(struct kvm *kvm)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
next prev parent reply other threads:[~2007-11-20 16:57 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-20 16:57 [PATCH 0 of 3] create kvm_x86 Hollis Blanchard
2007-11-20 16:57 ` [PATCH 1 of 3] Use kvm_x86 to hold x86 specific kvm fields Hollis Blanchard
2007-11-28 21:20 ` Anthony Liguori
[not found] ` <474DDB97.6090400-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-11-28 21:43 ` Hollis Blanchard
2007-11-20 16:57 ` Hollis Blanchard [this message]
2007-11-21 9:09 ` [PATCH 0 of 3] create kvm_x86 Carsten Otte
[not found] ` <4743F5AE.8090707-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
2007-11-21 9:18 ` Avi Kivity
[not found] ` <4743F7DF.4000107-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-21 9:32 ` Amit Shah
2007-11-21 9:39 ` Carsten Otte
2007-11-21 9:42 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDC9E7193-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-21 9:55 ` Avi Kivity
2007-11-28 21:15 ` Hollis Blanchard
2007-11-30 7:26 ` Avi Kivity
[not found] ` <474FBB17.6080800-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 8:36 ` Zhang, Xiantao
[not found] ` <42DFA526FC41B1429CE7279EF83C6BDCA397C1-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-30 9:04 ` Avi Kivity
[not found] ` <474FD234.5060203-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 11:42 ` Zhang, Xiantao
2007-11-30 18:43 ` Hollis Blanchard
2007-11-30 20:31 ` Avi Kivity
[not found] ` <4750732B.7070502-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-30 21:09 ` Hollis Blanchard
2007-11-30 21:43 ` Anthony Liguori
[not found] ` <47508408.8050202-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-11-30 22:08 ` Hollis Blanchard
2007-12-01 10:04 ` Avi Kivity
2007-12-01 10:02 ` 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=7ec2ba0e8a361336d006.1195577834@basalt \
--to=hollisb-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=Zhang-Rn83F4s8Lwc+UXBhvPuGgqsjOiXwFzmk@public.gmane.org \
--cc=avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org \
--cc=carsteno-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@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