mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: stefano.stabellini@eu.citrix.com
To: linux-kernel@vger.kernel.org
Cc: xen-devel@lists.xensource.com, Jeremy.Fitzhardinge@citrix.com,
	konrad.wilk@oracle.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH 09/12] xen p2m: transparently change the p2m mappings in the m2p override
Date: Mon, 10 Jan 2011 10:36:38 +0000	[thread overview]
Message-ID: <1294655801-16230-9-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.00.1101101012190.2390@kaball-desktop>

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

In m2p_add_override store the original mfn into page->index and then
change the p2m mapping, setting mfns as FOREIGN_FRAME.

In m2p_remove_override restore the original mapping.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/x86/xen/p2m.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c
index 8db19d5..b3b19d4 100644
--- a/arch/x86/xen/p2m.c
+++ b/arch/x86/xen/p2m.c
@@ -407,8 +407,11 @@ static unsigned long mfn_hash(unsigned long mfn)
 void m2p_add_override(unsigned long mfn, struct page *page)
 {
 	unsigned long flags;
+	unsigned long pfn = page_to_pfn(page);
 	page->private = mfn;
+	page->index = pfn_to_mfn(pfn);
 
+	__set_phys_to_machine(pfn, FOREIGN_FRAME(mfn));
 	spin_lock_irqsave(&m2p_override_lock, flags);
 	list_add(&page->lru,  &m2p_overrides[mfn_hash(mfn)]);
 	spin_unlock_irqrestore(&m2p_override_lock, flags);
@@ -417,9 +420,18 @@ void m2p_add_override(unsigned long mfn, struct page *page)
 void m2p_remove_override(struct page *page)
 {
 	unsigned long flags;
+	unsigned long mfn;
+	unsigned long pfn;
+
+	pfn = page_to_pfn(page);
+	mfn = get_phys_to_machine(pfn);
+	if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT))
+		return;
+
 	spin_lock_irqsave(&m2p_override_lock, flags);
 	list_del(&page->lru);
 	spin_unlock_irqrestore(&m2p_override_lock, flags);
+	__set_phys_to_machine(pfn, page->index);
 }
 
 struct page *m2p_find_override(unsigned long mfn)
-- 
1.5.6.5


  parent reply	other threads:[~2011-01-10 10:35 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 10:36 [PATCH v2 00/12] xen: allow usermode to map granted pages Stefano Stabellini
2011-01-10 10:36 ` [PATCH 01/12] xen: define gnttab_set_map_op/unmap_op stefano.stabellini
2011-01-10 10:36 ` [PATCH 02/12] xen/gntdev: allow usermode to map granted pages stefano.stabellini
2011-01-10 10:36 ` [PATCH 03/12] xen/gntdev: add VM_PFNMAP to vma stefano.stabellini
2011-01-10 10:36 ` [PATCH 04/12] xen: move p2m handling to separate file stefano.stabellini
2011-01-10 10:36 ` [PATCH 05/12] xen: add m2p override mechanism stefano.stabellini
2011-01-10 23:11   ` Konrad Rzeszutek Wilk
2011-01-11 12:44     ` Stefano Stabellini
2011-01-11 15:24       ` Konrad Rzeszutek Wilk
2011-01-10 10:36 ` [PATCH 06/12] xen: gntdev: move use of GNTMAP_contains_pte next to the map_op stefano.stabellini
2011-01-10 10:36 ` [PATCH 07/12] xen/gntdev: stop using "token" argument stefano.stabellini
2011-01-10 10:36 ` [PATCH 08/12] xen/gntdev: Fix circular locking dependency stefano.stabellini
2011-01-10 10:36 ` stefano.stabellini [this message]
2011-01-10 10:36 ` [PATCH 10/12] xen: introduce gnttab_map_refs and gnttab_unmap_refs stefano.stabellini
2011-01-10 10:36 ` [PATCH 11/12] xen gntdev: use " stefano.stabellini
2011-01-10 10:36 ` [PATCH 12/12] xen p2m: clear the old pte when adding a page to m2p_override stefano.stabellini

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=1294655801-16230-9-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Jeremy.Fitzhardinge@citrix.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xen-devel@lists.xensource.com \
    /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®