From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: [PATCH 34/58] KVM: MMU: Move set_pte_common() to pte width dependent code
Date: Sun, 17 Jun 2007 12:44:15 +0300 [thread overview]
Message-ID: <1182073480677-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <1182073479890-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
In preparation of some modifications.
Signed-off-by: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
---
drivers/kvm/mmu.c | 48 --------------------------------------
drivers/kvm/paging_tmpl.h | 56 +++++++++++++++++++++++++++++++++++++++++---
2 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index 46491b4..a763150 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -965,54 +965,6 @@ static void paging_new_cr3(struct kvm_vcpu *vcpu)
kvm_arch_ops->set_cr3(vcpu, vcpu->mmu.root_hpa);
}
-static inline void set_pte_common(struct kvm_vcpu *vcpu,
- u64 *shadow_pte,
- gpa_t gaddr,
- int dirty,
- u64 access_bits,
- gfn_t gfn)
-{
- hpa_t paddr;
-
- *shadow_pte |= access_bits << PT_SHADOW_BITS_OFFSET;
- if (!dirty)
- access_bits &= ~PT_WRITABLE_MASK;
-
- paddr = gpa_to_hpa(vcpu, gaddr & PT64_BASE_ADDR_MASK);
-
- *shadow_pte |= access_bits;
-
- if (is_error_hpa(paddr)) {
- *shadow_pte |= gaddr;
- *shadow_pte |= PT_SHADOW_IO_MARK;
- *shadow_pte &= ~PT_PRESENT_MASK;
- return;
- }
-
- *shadow_pte |= paddr;
-
- if (access_bits & PT_WRITABLE_MASK) {
- struct kvm_mmu_page *shadow;
-
- shadow = kvm_mmu_lookup_page(vcpu, gfn);
- if (shadow) {
- pgprintk("%s: found shadow page for %lx, marking ro\n",
- __FUNCTION__, gfn);
- access_bits &= ~PT_WRITABLE_MASK;
- if (is_writeble_pte(*shadow_pte)) {
- *shadow_pte &= ~PT_WRITABLE_MASK;
- kvm_arch_ops->tlb_flush(vcpu);
- }
- }
- }
-
- if (access_bits & PT_WRITABLE_MASK)
- mark_page_dirty(vcpu->kvm, gaddr >> PAGE_SHIFT);
-
- page_header_update_slot(vcpu->kvm, shadow_pte, gaddr);
- rmap_add(vcpu, shadow_pte);
-}
-
static void inject_page_fault(struct kvm_vcpu *vcpu,
u64 addr,
u32 err_code)
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h
index e094a8b..6576300 100644
--- a/drivers/kvm/paging_tmpl.h
+++ b/drivers/kvm/paging_tmpl.h
@@ -192,14 +192,62 @@ static void FNAME(mark_pagetable_dirty)(struct kvm *kvm,
mark_page_dirty(kvm, walker->table_gfn[walker->level - 1]);
}
+static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu,
+ u64 *shadow_pte,
+ gpa_t gaddr,
+ int dirty,
+ u64 access_bits,
+ gfn_t gfn)
+{
+ hpa_t paddr;
+
+ *shadow_pte |= access_bits << PT_SHADOW_BITS_OFFSET;
+ if (!dirty)
+ access_bits &= ~PT_WRITABLE_MASK;
+
+ paddr = gpa_to_hpa(vcpu, gaddr & PT64_BASE_ADDR_MASK);
+
+ *shadow_pte |= access_bits;
+
+ if (is_error_hpa(paddr)) {
+ *shadow_pte |= gaddr;
+ *shadow_pte |= PT_SHADOW_IO_MARK;
+ *shadow_pte &= ~PT_PRESENT_MASK;
+ return;
+ }
+
+ *shadow_pte |= paddr;
+
+ if (access_bits & PT_WRITABLE_MASK) {
+ struct kvm_mmu_page *shadow;
+
+ shadow = kvm_mmu_lookup_page(vcpu, gfn);
+ if (shadow) {
+ pgprintk("%s: found shadow page for %lx, marking ro\n",
+ __FUNCTION__, gfn);
+ access_bits &= ~PT_WRITABLE_MASK;
+ if (is_writeble_pte(*shadow_pte)) {
+ *shadow_pte &= ~PT_WRITABLE_MASK;
+ kvm_arch_ops->tlb_flush(vcpu);
+ }
+ }
+ }
+
+ if (access_bits & PT_WRITABLE_MASK)
+ mark_page_dirty(vcpu->kvm, gaddr >> PAGE_SHIFT);
+
+ page_header_update_slot(vcpu->kvm, shadow_pte, gaddr);
+ rmap_add(vcpu, shadow_pte);
+}
+
static void FNAME(set_pte)(struct kvm_vcpu *vcpu, u64 guest_pte,
u64 *shadow_pte, u64 access_bits, gfn_t gfn)
{
ASSERT(*shadow_pte == 0);
access_bits &= guest_pte;
*shadow_pte = (guest_pte & PT_PTE_COPY_MASK);
- set_pte_common(vcpu, shadow_pte, guest_pte & PT_BASE_ADDR_MASK,
- guest_pte & PT_DIRTY_MASK, access_bits, gfn);
+ FNAME(set_pte_common)(vcpu, shadow_pte, guest_pte & PT_BASE_ADDR_MASK,
+ guest_pte & PT_DIRTY_MASK, access_bits, gfn);
}
static void FNAME(update_pte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *page,
@@ -229,8 +277,8 @@ static void FNAME(set_pde)(struct kvm_vcpu *vcpu, u64 guest_pde,
gaddr |= (guest_pde & PT32_DIR_PSE36_MASK) <<
(32 - PT32_DIR_PSE36_SHIFT);
*shadow_pte = guest_pde & PT_PTE_COPY_MASK;
- set_pte_common(vcpu, shadow_pte, gaddr,
- guest_pde & PT_DIRTY_MASK, access_bits, gfn);
+ FNAME(set_pte_common)(vcpu, shadow_pte, gaddr,
+ guest_pde & PT_DIRTY_MASK, access_bits, gfn);
}
/*
--
1.5.0.6
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
next prev parent reply other threads:[~2007-06-17 9:44 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-17 9:43 [PATCH 00/58] KVM updates for 2.6.23 Avi Kivity
[not found] ` <1182073479890-git-send-email-avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-06-17 9:43 ` [PATCH 01/58] KVM: VMX: Enable io bitmaps to avoid IO port 0x80 VMEXITs Avi Kivity
2007-06-17 9:43 ` [PATCH 02/58] KVM: SVM: Allow direct guest access to PC debug port Avi Kivity
2007-06-17 9:43 ` [PATCH 03/58] KVM: Assume that writes smaller than 4 bytes are to non-pagetable pages Avi Kivity
2007-06-17 9:43 ` [PATCH 04/58] KVM: Avoid saving and restoring some host CPU state on lightweight vmexit Avi Kivity
2007-06-17 9:43 ` [PATCH 05/58] KVM: Unindent some code Avi Kivity
2007-06-17 9:43 ` [PATCH 06/58] KVM: Reduce misfirings of the fork detector Avi Kivity
2007-06-17 9:43 ` [PATCH 07/58] KVM: Be more careful restoring fs on lightweight vmexit Avi Kivity
2007-06-17 9:43 ` [PATCH 08/58] KVM: Unify kvm_mmu_pre_write() and kvm_mmu_post_write() Avi Kivity
2007-06-17 9:43 ` [PATCH 09/58] KVM: MMU: Respect nonpae pagetable quadrant when zapping ptes Avi Kivity
2007-06-17 9:43 ` [PATCH 10/58] KVM: Update shadow pte on write to guest pte Avi Kivity
2007-06-17 9:43 ` [PATCH 11/58] KVM: Increase mmu shadow cache to 1024 pages Avi Kivity
2007-06-17 9:43 ` [PATCH 12/58] KVM: Fix potential guest state leak into host Avi Kivity
2007-06-17 9:43 ` [PATCH 13/58] KVM: Move some more msr mangling into vmx_save_host_state() Avi Kivity
2007-06-17 9:43 ` [PATCH 14/58] KVM: Rationalize exception bitmap usage Avi Kivity
2007-06-17 9:43 ` [PATCH 15/58] KVM: Consolidate guest fpu activation and deactivation Avi Kivity
2007-06-17 9:43 ` [PATCH 16/58] KVM: Set cr0.mp for guests Avi Kivity
2007-06-17 9:43 ` [PATCH 17/58] KVM: Implement IA32_EBL_CR_POWERON msr Avi Kivity
2007-06-17 9:43 ` [PATCH 18/58] KVM: MMU: Simplify kvm_mmu_free_page() a tiny bit Avi Kivity
2007-06-17 9:44 ` [PATCH 19/58] KVM: MMU: Store shadow page tables as kernel virtual addresses, not physical Avi Kivity
2007-06-17 9:44 ` [PATCH 20/58] KVM: VMX: Only reload guest msrs if they are already loaded Avi Kivity
2007-06-17 9:44 ` [PATCH 21/58] KVM: Avoid corrupting tr in real mode Avi Kivity
2007-06-17 9:44 ` [PATCH 22/58] KVM: Fix vmx I/O bitmap initialization on highmem systems Avi Kivity
2007-06-17 9:44 ` [PATCH 23/58] KVM: VMX: Use local labels in inline assembly Avi Kivity
2007-06-17 9:44 ` [PATCH 24/58] KVM: VMX: Handle #SS faults from real mode Avi Kivity
2007-06-17 9:44 ` [PATCH 25/58] KVM: VMX: Avoid saving and restoring msrs on lightweight vmexit Avi Kivity
2007-06-17 9:44 ` [PATCH 26/58] KVM: VMX: Cleanup redundant code in MSR set Avi Kivity
2007-06-17 9:44 ` [PATCH 27/58] KVM: VMX: Avoid saving and restoring msr_efer on lightweight vmexit Avi Kivity
2007-06-17 9:44 ` [PATCH 28/58] Use menuconfig objects II - KVM/Virt Avi Kivity
2007-06-17 9:44 ` [PATCH 29/58] KVM: x86 emulator: implement wbinvd Avi Kivity
2007-06-17 9:44 ` [PATCH 30/58] KVM: Fix includes Avi Kivity
2007-06-17 9:44 ` [PATCH 31/58] KVM: Use symbolic constants instead of magic numbers Avi Kivity
2007-06-17 9:44 ` [PATCH 32/58] KVM: MMU: Use slab caches for shadow pages and their headers Avi Kivity
2007-06-17 9:44 ` [PATCH 33/58] KVM: MMU: Simplify fetch() a little bit Avi Kivity
2007-06-17 9:44 ` Avi Kivity [this message]
2007-06-17 9:44 ` [PATCH 35/58] KVM: MMU: Pass the guest pde to set_pte_common Avi Kivity
2007-06-17 9:44 ` [PATCH 36/58] KVM: MMU: Fold fix_read_pf() into set_pte_common() Avi Kivity
2007-06-17 9:44 ` [PATCH 37/58] KVM: MMU: Fold fix_write_pf() " Avi Kivity
2007-06-17 9:44 ` [PATCH 38/58] KVM: Move shadow pte modifications from set_pte/set_pde to set_pde_common() Avi Kivity
2007-06-17 9:44 ` [PATCH 39/58] KVM: Make shadow pte updates atomic Avi Kivity
2007-06-17 9:44 ` [PATCH 40/58] KVM: MMU: Make setting shadow ptes atomic on i386 Avi Kivity
2007-06-17 9:44 ` [PATCH 41/58] KVM: MMU: Remove cr0.wp tricks Avi Kivity
2007-06-17 9:44 ` [PATCH 42/58] KVM: MMU: Simpify accessed/dirty/present/nx bit handling Avi Kivity
2007-06-17 9:44 ` [PATCH 43/58] KVM: MMU: Don't cache guest access bits in the shadow page table Avi Kivity
2007-06-17 9:44 ` [PATCH 44/58] KVM: MMU: Remove unused large page marker Avi Kivity
2007-06-17 9:44 ` [PATCH 45/58] KVM: Lazy guest cr3 switching Avi Kivity
2007-06-17 9:44 ` [PATCH 46/58] KVM: Replace C code with call to ARRAY_SIZE() macro Avi Kivity
2007-06-17 9:44 ` [PATCH 47/58] KVM: Remove unnecessary initialization and checks in mark_page_dirty() Avi Kivity
2007-06-17 9:44 ` [PATCH 48/58] KVM: Fix vcpu freeing for guest smp Avi Kivity
2007-06-17 9:44 ` [PATCH 49/58] KVM: Fix adding an smp virtual machine to the vm list Avi Kivity
2007-06-17 9:44 ` [PATCH 50/58] KVM: Enable guest smp Avi Kivity
2007-06-17 9:44 ` [PATCH 51/58] KVM: Move duplicate halt handling code into kvm_main.c Avi Kivity
2007-06-17 9:44 ` [PATCH 52/58] KVM: Emulate hlt on real mode for Intel Avi Kivity
2007-06-17 9:44 ` [PATCH 53/58] KVM: Keep an upper bound of initialized vcpus Avi Kivity
2007-06-17 9:44 ` [PATCH 54/58] KVM: Flush remote tlbs when reducing shadow pte permissions Avi Kivity
2007-06-17 9:44 ` [PATCH 55/58] KVM: SVM: Replace memset(<addr>, 0, PAGESIZE) with clear_page(<addr>) Avi Kivity
2007-06-17 9:44 ` [PATCH 56/58] KVM: VMX: " Avi Kivity
2007-06-17 9:44 ` [PATCH 57/58] KVM: Initialize the BSP bit in the APIC_BASE msr correctly Avi Kivity
2007-06-17 9:44 ` [PATCH 58/58] KVM: VMX: Ensure vcpu time stamp counter is monotonous 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=1182073480677-git-send-email-avi@qumranet.com \
--to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@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