WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 05/16] xenpaging: update machine_to_phys_mapping

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-devel] [PATCH 05/16] xenpaging: update machine_to_phys_mapping during page-in and page-out
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Wed, 3 Nov 2010 19:32:19 +0100
Delivery-date: Wed, 03 Nov 2010 11:33:08 -0700
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1288809141; l=2046; s=domk; d=aepfle.de; h=In-Reply-To:Content-Type:MIME-Version:References:Subject:To:From: Date:X-RZG-CLASS-ID:X-RZG-AUTH; bh=AbztK6NE3qowOhzBv9RxJTHe3aA=; b=sVRwxg7MmEctP2aVYBqDwUeeIV2ZjL5xW0SuPJpVzfs25/aU4xJLskSnz0F6fZdWY+7 XT81JGaM1+j8A+wYIsYy2AagSvhYOq8g54HLPgsvizk86E+dokTOVQ3o+acp/P0nHK/1E IgT9Ig1V6IkB7v/QyqDm9QwIkI/SWiCtg24=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20101102223012.460890479@xxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20101102223010.603002116@xxxxxxxxx> <20101102223012.460890479@xxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
The machine_to_phys_mapping array needs updating during page-out.
If a page is gone, a call to get_gpfn_from_mfn will still return the old
gfn for an already paged-out page.  This happens when the entire guest
ram is paged-out before xen_vga_populate_vram() runs.  Then
XENMEM_populate_physmap is called with gfn 0xff000.  A new page is
allocated with alloc_domheap_pages.  This new page does not have a gfn
yet.  However, in guest_physmap_add_entry() the passed mfn maps still to
an old gfn.  This old gfn is paged-out and has no mfn anymore.  As a
result, the ASSERT() triggers because p2m_is_ram() is true for
p2m_ram_paging* types.

If the machine_to_phys_mapping array is updated properly, both loops in
guest_physmap_add_entry() turn into no-ops for the new page and the
mfn/gfn mapping will be done at the end of the function.


The same thing needs to happen dring a page-in.
If XENMEM_add_to_physmap is used with XENMAPSPACE_gmfn,
get_gpfn_from_mfn() will return an appearently valid gfn.  As a result,
guest_physmap_remove_page() is called.  The ASSERT in p2m_remove_page
triggers because the passed mfn does not match the old mfn for the
passed gfn.

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

---
v2:
  call set_gpfn_from_mfn only if mfn is valid

 xen/arch/x86/mm/p2m.c |    3 +++
 1 file changed, 3 insertions(+)

--- xen-unstable.hg-4.1.22353.orig/xen/arch/x86/mm/p2m.c
+++ xen-unstable.hg-4.1.22353/xen/arch/x86/mm/p2m.c
@@ -2742,6 +2742,7 @@ int p2m_mem_paging_evict(struct p2m_doma
     /* Remove mapping from p2m table */
     p2m_lock(p2m);
     set_p2m_entry(p2m, gfn, _mfn(PAGING_MFN), 0, p2m_ram_paged);
+    set_gpfn_from_mfn(mfn_x(mfn), INVALID_M2P_ENTRY);
     p2m_unlock(p2m);
 
     /* Put the page back so it gets freed */
@@ -2820,6 +2821,8 @@ void p2m_mem_paging_resume(struct p2m_do
     mfn = gfn_to_mfn(p2m, rsp.gfn, &p2mt);
     p2m_lock(p2m);
     set_p2m_entry(p2m, rsp.gfn, mfn, 0, p2m_ram_rw);
+    if ( mfn_valid(mfn) )
+        set_gpfn_from_mfn(mfn_x(mfn), rsp.gfn);
     p2m_unlock(p2m);
 
     /* Unpause domain */

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>