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-changelog

[Xen-changelog] [xen-3.4-testing] pv-grub: Fix for incorrect dom->p2m_ho

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-3.4-testing] pv-grub: Fix for incorrect dom->p2m_host[] list initialization
From: Xen patchbot-3.4-testing <patchbot@xxxxxxx>
Date: Tue, 30 Aug 2011 08:11:12 +0100
Delivery-date: Tue, 30 Aug 2011 00:12:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keith Coleman <keith.coleman@xxxxxxxxxxxxx>
# Date 1314687909 14400
# Node ID 90a184da7b92039b6ee4642351fa898c64e92aa4
# Parent  60b3ca4d973af88dbdb380c5d4b21a0a961459f5
pv-grub: Fix for incorrect dom->p2m_host[] list initialization

Introduction of Linux Kernel git commit
ceefccc93932b920a8ec6f35f596db05202a12fe (x86: default
CONFIG_PHYSICAL_START and CONFIG_PHYSICAL_ALIGN to 16 MB) revealed
deeply hidden bug in pv-grub. During kernel load stage dom->p2m_host[]
list has been incorrectly initialized.

At the beginning of kernel load stage dom->p2m_host[] list is
populated with current PFN->MFN layout. Later during memory allocation
(memory is allocated page by page in kexec_allocate()) page order is
changed to establish linear layout in new domain. It is done by
exchanging subsequent MFNs with newly allocated MFNs. dom->p2m_host[]
list is indexed by currently requested PFN (it is incremented from 0)
and PFN of newly allocated paged. If PFN of newly allocated page is
less than currently requested PFN then earlier allocated MFN is
overwritten which leads to domain crash later. This patch corrects
that issue. If PFN of newly allocated page is less then currently
requested PFN then relevant PFN/MFN pair is properly calculated and
usual exchange occurs later.

Signed-off-by: Daniel Kiper <dkiper@xxxxxxxxxxxx>
Reviewed-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
Committed-by: Keith Coleman <keith.coleman@xxxxxxxxxxxxx>
---


diff -r 60b3ca4d973a -r 90a184da7b92 stubdom/grub/kexec.c
--- a/stubdom/grub/kexec.c      Tue Aug 30 02:35:58 2011 -0400
+++ b/stubdom/grub/kexec.c      Tue Aug 30 03:05:09 2011 -0400
@@ -48,6 +48,7 @@
 
 static unsigned long *pages;
 static unsigned long *pages_mfns;
+static xen_pfn_t *pages_moved2pfns;
 static unsigned long allocated;
 
 int pin_table(int xc_handle, unsigned int type, unsigned long mfn,
@@ -80,6 +81,7 @@
 
     pages = realloc(pages, new_allocated * sizeof(*pages));
     pages_mfns = realloc(pages_mfns, new_allocated * sizeof(*pages_mfns));
+    pages_moved2pfns = realloc(pages_moved2pfns, new_allocated * 
sizeof(*pages_moved2pfns));
     for (i = allocated; i < new_allocated; i++) {
         /* Exchange old page of PFN i with a newly allocated page.  */
         xen_pfn_t old_mfn = dom->p2m_host[i];
@@ -91,6 +93,18 @@
         new_pfn = PHYS_PFN(to_phys(pages[i]));
         pages_mfns[i] = new_mfn = pfn_to_mfn(new_pfn);
 
+       /*
+        * If PFN of newly allocated page (new_pfn) is less then currently
+        * requested PFN (i) then look for relevant PFN/MFN pair. In this
+        * situation dom->p2m_host[new_pfn] no longer contains proper MFN
+        * because original page with new_pfn was moved earlier
+        * to different location.
+        */
+       for (; new_pfn < i; new_pfn = pages_moved2pfns[new_pfn]);
+
+       /* Store destination PFN of currently requested page. */
+       pages_moved2pfns[i] = new_pfn;
+
         /* Put old page at new PFN */
         dom->p2m_host[new_pfn] = old_mfn;
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-3.4-testing] pv-grub: Fix for incorrect dom->p2m_host[] list initialization, Xen patchbot-3 . 4-testing <=