From: Avi Kivity <avi@qumranet.com>
To: kvm-devel@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 31/35] KVM: MMU: Introduce and use spte_to_page()
Date: Thu, 3 Apr 2008 22:32:46 +0300 [thread overview]
Message-ID: <1207251170-5013-32-git-send-email-avi@qumranet.com> (raw)
In-Reply-To: <1207251170-5013-1-git-send-email-avi@qumranet.com>
Encapsulate the pte mask'n'shift in a function.
Signed-off-by: Avi Kivity <avi@qumranet.com>
---
arch/x86/kvm/mmu.c | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index dd4b95b..6fc3421 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -240,6 +240,13 @@ static int is_rmap_pte(u64 pte)
return is_shadow_present_pte(pte);
}
+static struct page *spte_to_page(u64 pte)
+{
+ hfn_t hfn = (pte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
+
+ return pfn_to_page(hfn);
+}
+
static gfn_t pse36_gfn_delta(u32 gpte)
{
int shift = 32 - PT32_DIR_PSE36_SHIFT - PAGE_SHIFT;
@@ -541,7 +548,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
if (!is_rmap_pte(*spte))
return;
sp = page_header(__pa(spte));
- page = pfn_to_page((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT);
+ page = spte_to_page(*spte);
mark_page_accessed(page);
if (is_writeble_pte(*spte))
kvm_release_page_dirty(page);
@@ -630,7 +637,7 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
struct page *page;
spte = rmap_next(kvm, rmapp, NULL);
- page = pfn_to_page((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT);
+ page = spte_to_page(*spte);
SetPageDirty(page);
}
@@ -1033,7 +1040,6 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
u64 spte;
int was_rmapped = 0;
int was_writeble = is_writeble_pte(*shadow_pte);
- hfn_t host_pfn = (*shadow_pte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;
pgprintk("%s: spte %llx access %x write_fault %d"
" user_fault %d gfn %lx\n",
@@ -1051,9 +1057,10 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
child = page_header(pte & PT64_BASE_ADDR_MASK);
mmu_page_remove_parent_pte(child, shadow_pte);
- } else if (host_pfn != page_to_pfn(page)) {
+ } else if (page != spte_to_page(*shadow_pte)) {
pgprintk("hfn old %lx new %lx\n",
- host_pfn, page_to_pfn(page));
+ page_to_pfn(spte_to_page(*shadow_pte)),
+ page_to_pfn(page));
rmap_remove(vcpu->kvm, shadow_pte);
} else {
if (largepage)
--
1.5.4.5
next prev parent reply other threads:[~2008-04-03 19:41 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-03 19:32 [PATCH 00/35] KVM updates for the 2.6.26 merge window (part II) Avi Kivity
2008-04-03 19:32 ` [PATCH 01/35] KVM: Use x86's segment descriptor struct instead of private definition Avi Kivity
2008-04-03 19:32 ` [PATCH 02/35] KVM: Add stat counter for hypercalls Avi Kivity
2008-04-03 19:32 ` [PATCH 03/35] KVM: x86 emulator: fix sparse warnings in x86_emulate.c Avi Kivity
2008-04-03 19:32 ` [PATCH 04/35] KVM: SVM: make iopm_base static Avi Kivity
2008-04-03 19:32 ` [PATCH 05/35] KVM: sparse fixes for kvm/x86.c Avi Kivity
2008-04-03 19:32 ` [PATCH 06/35] KVM: Implement dummy values for MSR_PERF_STATUS Avi Kivity
2008-04-03 19:32 ` [PATCH 07/35] KVM: MMU: ignore zapped root pagetables Avi Kivity
2008-04-03 19:32 ` [PATCH 08/35] KVM: MMU: large page support Avi Kivity
2008-04-03 19:32 ` [PATCH 09/35] KVM: Prefix control register accessors with kvm_ to avoid namespace pollution Avi Kivity
2008-04-03 19:32 ` [PATCH 10/35] KVM: Use kzalloc to avoid allocating kvm_regs from kernel stack Avi Kivity
2008-04-03 19:32 ` [PATCH 11/35] KVM: detect if VCPU triple faults Avi Kivity
2008-04-03 19:32 ` [PATCH 12/35] KVM: replace remaining __FUNCTION__ occurances Avi Kivity
2008-04-03 19:32 ` [PATCH 13/35] KVM: VMX: Don't adjust tsc offset forward Avi Kivity
2008-04-03 19:32 ` [PATCH 14/35] KVM: Remove pointless desc_ptr #ifdef Avi Kivity
2008-04-03 19:32 ` [PATCH 15/35] KVM: In kernel PIT model Avi Kivity
2008-04-03 19:32 ` [PATCH 16/35] KVM: Add save/restore supporting of in kernel PIT Avi Kivity
2008-04-03 19:32 ` [PATCH 17/35] KVM: Add reset support for " Avi Kivity
2008-04-03 19:32 ` [PATCH 18/35] KVM: add basic paravirt support Avi Kivity
2008-04-03 19:32 ` [PATCH 19/35] x86: KVM guest: " Avi Kivity
2008-04-03 19:32 ` [PATCH 20/35] KVM: Provide unlocked version of emulator_write_phys() Avi Kivity
2008-04-03 19:32 ` [PATCH 21/35] KVM: MMU: hypercall based pte updates and TLB flushes Avi Kivity
2008-04-03 19:32 ` [PATCH 22/35] x86: KVM guest: " Avi Kivity
2008-04-03 19:32 ` [PATCH 23/35] x86: KVM guest: hypercall batching Avi Kivity
2008-04-03 19:32 ` [PATCH 24/35] x86: allow machine_crash_shutdown to be replaced Avi Kivity
2008-04-03 19:32 ` [PATCH 25/35] x86: make native_machine_shutdown non-static Avi Kivity
2008-04-03 19:32 ` [PATCH 26/35] x86: KVM guest: disable clock before rebooting Avi Kivity
2008-04-03 19:32 ` [PATCH 27/35] KVM: kvm.h: __user requires compiler.h Avi Kivity
2008-04-03 19:32 ` [PATCH 28/35] KVM: MMU: Set the accessed bit on non-speculative shadow ptes Avi Kivity
2008-04-03 19:32 ` [PATCH 29/35] KVM: Move some x86 specific constants and structures to include/asm-x86 Avi Kivity
2008-04-03 19:32 ` [PATCH 30/35] KVM: MMU: fix dirty bit setting when removing write permissions Avi Kivity
2008-04-03 19:32 ` Avi Kivity [this message]
2008-04-03 19:32 ` [PATCH 32/35] KVM: no longer EXPERIMENTAL Avi Kivity
2008-04-03 19:32 ` [PATCH 33/35] KVM: VMX: Add module option to disable flexpriority Avi Kivity
2008-04-03 19:32 ` [PATCH 34/35] KVM: x86: add functions to get the cpl of vcpu Avi Kivity
2008-04-03 19:32 ` [PATCH 35/35] KVM: x86: hardware task switching support 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=1207251170-5013-32-git-send-email-avi@qumranet.com \
--to=avi@qumranet.com \
--cc=kvm-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®