From: Stefano Stabellini Subject: [PATCH v2 4/4] libxc/arm: allocate xenstore and console pages Date: Wed, 4 Jul 2012 11:55:49 +0100 Message-ID: <1341399349-31247-4-git-send-email-stefano.stabellini@eu.citrix.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xensource.com Cc: tim@xen.org, Ian.Campbell@citrix.com, Stefano Stabellini List-Id: xen-devel@lists.xenproject.org Allocate two additional pages at the end of the guest physical memory for xenstore and console. Set HVM_PARAM_STORE_PFN and HVM_PARAM_CONSOLE_PFN to the corresponding values. Signed-off-by: Stefano Stabellini --- tools/libxc/xc_dom_arm.c | 36 ++++++++++++++++++++++++++++++------ 1 files changed, 30 insertions(+), 6 deletions(-) diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index bb86139..724e7ad 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -25,6 +25,10 @@ #include "xg_private.h" #include "xc_dom.h" +#define NR_MAGIC_PAGES 2 +#define CONSOLE_PFN_OFFSET 0 +#define XENSTORE_PFN_OFFSET 1 + /* ------------------------------------------------------------------------ */ /* * arm guests are hybrid and start off with paging disabled, therefore no @@ -46,13 +50,33 @@ static int setup_pgtables_arm(struct xc_dom_image *dom) static int alloc_magic_pages(struct xc_dom_image *dom) { + int rc, i, allocsz; + xen_pfn_t store_pfn, console_pfn, p2m[NR_MAGIC_PAGES]; + DOMPRINTF_CALLED(dom->xch); - /* XXX - * dom->p2m_guest - * dom->start_info_pfn - * dom->xenstore_pfn - * dom->console_pfn - */ + + for (i = 0; i < NR_MAGIC_PAGES; i++) + p2m[i] = dom->rambase_pfn + dom->total_pages + i; + + for ( i = rc = allocsz = 0; + (i < NR_MAGIC_PAGES) && !rc; + i += allocsz) { + allocsz = NR_MAGIC_PAGES - i; + rc = xc_domain_populate_physmap_exact( + dom->xch, dom->guest_domid, allocsz, + 0, 0, &p2m[i]); + } + + console_pfn = dom->rambase_pfn + dom->total_pages + CONSOLE_PFN_OFFSET; + store_pfn = dom->rambase_pfn + dom->total_pages + XENSTORE_PFN_OFFSET; + + xc_clear_domain_page(dom->xch, dom->guest_domid, console_pfn); + xc_clear_domain_page(dom->xch, dom->guest_domid, store_pfn); + xc_set_hvm_param(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN, + console_pfn); + xc_set_hvm_param(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN, + store_pfn); + return 0; } -- 1.7.2.5