public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: LKML <linux-kernel@vger.kernel.org>,
	xen-devel <xen-devel@lists.xensource.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: [PATCH 05 of 12] xen: add p2m mfn_list_list
Date: Fri, 23 May 2008 14:41:12 +0100	[thread overview]
Message-ID: <a405e5f9ddf6f5f142ea.1211550072@localhost> (raw)
In-Reply-To: <patchbomb.1211550067@localhost>

When saving a domain, the Xen tools need to remap all our mfns to
portable pfns.  In order to remap our p2m table, it needs to know
where all its pages are, so maintain the references to the p2m table
for it to use.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/xen/enlighten.c |    2 ++
 arch/x86/xen/mmu.c       |   39 ++++++++++++++++++++++++++++++++++++---
 arch/x86/xen/xen-ops.h   |    2 ++
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -880,6 +880,8 @@
 	/* In UP this is as good a place as any to set up shared info */
 	xen_setup_vcpu_info_placement();
 #endif
+
+	xen_setup_mfn_list_list();
 }
 
 static __init void xen_pagetable_setup_done(pgd_t *base)
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -69,6 +69,13 @@
 	__attribute__((section(".data.page_aligned"))) =
 		{ [ 0 ... TOP_ENTRIES - 1] = &p2m_missing[0] };
 
+/* Arrays of p2m arrays expressed in mfns used for save/restore */
+static unsigned long p2m_top_mfn[TOP_ENTRIES]
+	__attribute__((section(".bss.page_aligned")));
+
+static unsigned long p2m_top_mfn_list[TOP_ENTRIES / P2M_ENTRIES_PER_PAGE]
+	__attribute__((section(".bss.page_aligned")));
+
 static inline unsigned p2m_top_index(unsigned long pfn)
 {
 	BUG_ON(pfn >= MAX_DOMAIN_PAGES);
@@ -80,11 +87,35 @@
 	return pfn % P2M_ENTRIES_PER_PAGE;
 }
 
+/* Build the parallel p2m_top_mfn structures */
+void xen_setup_mfn_list_list(void)
+{
+	unsigned pfn, idx;
+
+	for(pfn = 0; pfn < MAX_DOMAIN_PAGES; pfn += P2M_ENTRIES_PER_PAGE) {
+		unsigned topidx = p2m_top_index(pfn);
+
+		p2m_top_mfn[topidx] = virt_to_mfn(p2m_top[topidx]);
+	}
+
+	for(idx = 0; idx < ARRAY_SIZE(p2m_top_mfn_list); idx++) {
+		unsigned topidx = idx * P2M_ENTRIES_PER_PAGE;
+		p2m_top_mfn_list[idx] = virt_to_mfn(&p2m_top_mfn[topidx]);
+	}
+
+	BUG_ON(HYPERVISOR_shared_info == &xen_dummy_shared_info);
+
+	HYPERVISOR_shared_info->arch.pfn_to_mfn_frame_list_list =
+		virt_to_mfn(p2m_top_mfn_list);
+	HYPERVISOR_shared_info->arch.max_pfn = xen_start_info->nr_pages;
+}
+
+/* Set up p2m_top to point to the domain-builder provided p2m pages */
 void __init xen_build_dynamic_phys_to_machine(void)
 {
-	unsigned pfn;
 	unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list;
 	unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages);
+	unsigned pfn;
 
 	for(pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) {
 		unsigned topidx = p2m_top_index(pfn);
@@ -105,7 +136,7 @@
 	return p2m_top[topidx][idx];
 }
 
-static void alloc_p2m(unsigned long **pp)
+static void alloc_p2m(unsigned long **pp, unsigned long *mfnp)
 {
 	unsigned long *p;
 	unsigned i;
@@ -118,6 +149,8 @@
 
 	if (cmpxchg(pp, p2m_missing, p) != p2m_missing)
 		free_page((unsigned long)p);
+	else
+		*mfnp = virt_to_mfn(p);
 }
 
 void set_phys_to_machine(unsigned long pfn, unsigned long mfn)
@@ -139,7 +172,7 @@
 		/* no need to allocate a page to store an invalid entry */
 		if (mfn == INVALID_P2M_ENTRY)
 			return;
-		alloc_p2m(&p2m_top[topidx]);
+		alloc_p2m(&p2m_top[topidx], &p2m_top_mfn[topidx]);
 	}
 
 	idx = p2m_index(pfn);
diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
--- a/arch/x86/xen/xen-ops.h
+++ b/arch/x86/xen/xen-ops.h
@@ -17,6 +17,8 @@
 extern struct start_info *xen_start_info;
 extern struct shared_info xen_dummy_shared_info;
 extern struct shared_info *HYPERVISOR_shared_info;
+
+void xen_setup_mfn_list_list(void);
 
 char * __init xen_memory_setup(void);
 void __init xen_arch_setup(void);



  parent reply	other threads:[~2008-05-23 13:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-23 13:41 [PATCH 00 of 12] xen: add save/restore/migrate for Xen domains Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 01 of 12] xen: make phys_to_machine structure dynamic Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 02 of 12] xen: add configurable max domain size Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 03 of 12] xen: efficiently support a holey p2m table Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 04 of 12] xen: make dummy_shared_info non-static Jeremy Fitzhardinge
2008-05-23 13:41 ` Jeremy Fitzhardinge [this message]
2008-05-28 12:28   ` [bisected] Re: [PATCH 05 of 12] xen: add p2m mfn_list_list Ingo Molnar
2008-05-28 14:02     ` Jeremy Fitzhardinge
2008-05-28 14:10       ` Sam Ravnborg
2008-06-02 10:10       ` Ingo Molnar
2008-06-02 13:12         ` Jeremy Fitzhardinge
2008-05-30  7:40     ` Gerd Hoffmann
2008-05-30  8:04       ` Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 06 of 12] xen: add rebind_evtchn_irq Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 07 of 12] xen: fix unbind_from_irq() Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 08 of 12] xen-console: add save/restore Jeremy Fitzhardinge
2008-06-02 11:17   ` Ingo Molnar
2008-06-02 11:18     ` Ingo Molnar
2008-06-02 11:50     ` Jeremy Fitzhardinge
2008-06-02 12:13     ` [Xen-devel] " Markus Armbruster
2008-05-23 13:41 ` [PATCH 09 of 12] xenbus: rebind irq on restore Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 10 of 12] xen: implement save/restore Jeremy Fitzhardinge
2008-05-29  7:31   ` Ingo Molnar
2008-05-29  8:00     ` Jeremy Fitzhardinge
2008-05-29  8:02     ` [PATCH] xen: fix compilation when CONFIG_PM_SLEEP is disabled Jeremy Fitzhardinge
2008-05-30  0:24       ` Randy Dunlap
2008-06-02 10:13         ` Ingo Molnar
2008-06-02  9:21   ` [Xen-devel] [PATCH 10 of 12] xen: implement save/restore Isaku Yamahata
2008-06-02 10:03     ` Jeremy Fitzhardinge
2008-06-02 10:47       ` Isaku Yamahata
2008-06-02 10:52         ` Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 11 of 12] xen: maintain clock offset over save/restore Jeremy Fitzhardinge
2008-05-23 13:41 ` [PATCH 12 of 12] hrtimer: remove warning in hres_timers_resume Jeremy Fitzhardinge

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=a405e5f9ddf6f5f142ea.1211550072@localhost \
    --to=jeremy@goop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rjw@sisk.pl \
    --cc=tglx@linutronix.de \
    --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