From patchwork Thu Mar 22 15:59:31 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 148308 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9673DB6EE6 for ; Fri, 23 Mar 2012 06:09:35 +1100 (EST) Received: from localhost ([::1]:34652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAlrB-00072t-Bt for incoming@patchwork.ozlabs.org; Thu, 22 Mar 2012 13:31:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAkSx-0006qI-LD for qemu-devel@nongnu.org; Thu, 22 Mar 2012 12:02:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAkSq-0004n5-LS for qemu-devel@nongnu.org; Thu, 22 Mar 2012 12:02:19 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:32638) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAkSq-0004ld-CK for qemu-devel@nongnu.org; Thu, 22 Mar 2012 12:02:12 -0400 X-IronPort-AV: E=Sophos;i="4.73,630,1325480400"; d="scan'208";a="187142812" Received: from ftlpmailmx02.citrite.net ([10.13.107.66]) by FTLPIPO02.CITRIX.COM with ESMTP/TLS/RC4-MD5; 22 Mar 2012 12:01:52 -0400 Received: from meteora.cam.xci-test.com (10.80.248.241) by smtprelay.citrix.com (10.13.107.66) with Microsoft SMTP Server id 8.3.213.0; Thu, 22 Mar 2012 12:01:52 -0400 From: Julien Grall To: xen-devel@lists.xensource.com Date: Thu, 22 Mar 2012 15:59:31 +0000 Message-ID: <562f12e135c4876330b03c9d3759e61c62adf079.1332430811.git.julien.grall@citrix.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 X-Mailman-Approved-At: Thu, 22 Mar 2012 13:31:03 -0400 Cc: Stefano.Stabellini@eu.citrix.com, qemu-devel@nongnu.org, julian.pidancet@citrix.com Subject: [Qemu-devel] [XEN][RFC PATCH 10/15] xc: Add argument to allocate more special pages X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patchs permits to allocate more special pages. Indeed, for multiple ioreq server, we need to have 2 shared pages by server. xc_hvm_build will take an argument which will indicate the number of special pages we want to allocate. Signed-off-by: Julien Grall --- tools/libxc/xc_hvm_build.c | 57 +++++++++++++++++++++++++------------------ tools/libxc/xenguest.h | 6 +++- tools/libxc/xg_private.c | 3 +- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/tools/libxc/xc_hvm_build.c b/tools/libxc/xc_hvm_build.c index 696c012..62b4ff1 100644 --- a/tools/libxc/xc_hvm_build.c +++ b/tools/libxc/xc_hvm_build.c @@ -47,10 +47,11 @@ #define SPECIALPAGE_IDENT_PT 6 #define SPECIALPAGE_CONSOLE 7 #define NR_SPECIAL_PAGES 8 -#define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x)) +#define special_pfn(x, add) (0xff000u - (NR_SPECIAL_PAGES + (add)) + (x)) static void build_hvm_info(void *hvm_info_page, uint64_t mem_size, - uint64_t mmio_start, uint64_t mmio_size) + uint64_t mmio_start, uint64_t mmio_size, + uint32_t nr_special_pages) { struct hvm_info_table *hvm_info = (struct hvm_info_table *) (((unsigned char *)hvm_info_page) + HVM_INFO_OFFSET); @@ -78,7 +79,7 @@ static void build_hvm_info(void *hvm_info_page, uint64_t mem_size, /* Memory parameters. */ hvm_info->low_mem_pgend = lowmem_end >> PAGE_SHIFT; hvm_info->high_mem_pgend = highmem_end >> PAGE_SHIFT; - hvm_info->reserved_mem_pgstart = special_pfn(0); + hvm_info->reserved_mem_pgstart = special_pfn(0, nr_special_pages); /* Finish with the checksum. */ for ( i = 0, sum = 0; i < hvm_info->length; i++ ) @@ -141,7 +142,8 @@ static int check_mmio_hole(uint64_t start, uint64_t memsize, static int setup_guest(xc_interface *xch, uint32_t dom, const struct xc_hvm_build_args *args, - char *image, unsigned long image_size) + char *image, unsigned long image_size, + uint32_t nr_special_pages) { xen_pfn_t *page_array = NULL; unsigned long i, nr_pages = args->mem_size >> PAGE_SHIFT; @@ -334,37 +336,42 @@ static int setup_guest(xc_interface *xch, xch, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, HVM_INFO_PFN)) == NULL ) goto error_out; - build_hvm_info(hvm_info_page, v_end, mmio_start, mmio_size); + build_hvm_info(hvm_info_page, v_end, mmio_start, mmio_size, nr_special_pages); munmap(hvm_info_page, PAGE_SIZE); /* Allocate and clear special pages. */ - for ( i = 0; i < NR_SPECIAL_PAGES; i++ ) + for ( i = 0; i < (NR_SPECIAL_PAGES + nr_special_pages); i++ ) { - xen_pfn_t pfn = special_pfn(i); + xen_pfn_t pfn = special_pfn(i, nr_special_pages); rc = xc_domain_populate_physmap_exact(xch, dom, 1, 0, 0, &pfn); if ( rc != 0 ) { PERROR("Could not allocate %d'th special page.", i); goto error_out; } - if ( xc_clear_domain_page(xch, dom, special_pfn(i)) ) + if ( xc_clear_domain_page(xch, dom, special_pfn(i, nr_special_pages)) ) goto error_out; } xc_set_hvm_param(xch, dom, HVM_PARAM_STORE_PFN, - special_pfn(SPECIALPAGE_XENSTORE)); + special_pfn(SPECIALPAGE_XENSTORE, nr_special_pages)); xc_set_hvm_param(xch, dom, HVM_PARAM_BUFIOREQ_PFN, - special_pfn(SPECIALPAGE_BUFIOREQ)); + special_pfn(SPECIALPAGE_BUFIOREQ, nr_special_pages)); xc_set_hvm_param(xch, dom, HVM_PARAM_IOREQ_PFN, - special_pfn(SPECIALPAGE_IOREQ)); + special_pfn(SPECIALPAGE_IOREQ, nr_special_pages)); xc_set_hvm_param(xch, dom, HVM_PARAM_CONSOLE_PFN, - special_pfn(SPECIALPAGE_CONSOLE)); + special_pfn(SPECIALPAGE_CONSOLE, nr_special_pages)); xc_set_hvm_param(xch, dom, HVM_PARAM_PAGING_RING_PFN, - special_pfn(SPECIALPAGE_PAGING)); + special_pfn(SPECIALPAGE_PAGING, nr_special_pages)); xc_set_hvm_param(xch, dom, HVM_PARAM_ACCESS_RING_PFN, - special_pfn(SPECIALPAGE_ACCESS)); + special_pfn(SPECIALPAGE_ACCESS, nr_special_pages)); xc_set_hvm_param(xch, dom, HVM_PARAM_SHARING_RING_PFN, - special_pfn(SPECIALPAGE_SHARING)); + special_pfn(SPECIALPAGE_SHARING, nr_special_pages)); + xc_set_hvm_param(xch, dom, HVM_PARAM_IO_PFN_FIRST, + special_pfn(NR_SPECIAL_PAGES, nr_special_pages)); + xc_set_hvm_param(xch, dom, HVM_PARAM_IO_PFN_LAST, + special_pfn(NR_SPECIAL_PAGES + nr_special_pages - 1, + nr_special_pages)); /* * Identity-map page table is required for running with CR0.PG=0 when @@ -372,14 +379,14 @@ static int setup_guest(xc_interface *xch, */ if ( (ident_pt = xc_map_foreign_range( xch, dom, PAGE_SIZE, PROT_READ | PROT_WRITE, - special_pfn(SPECIALPAGE_IDENT_PT))) == NULL ) + special_pfn(SPECIALPAGE_IDENT_PT, nr_special_pages))) == NULL ) goto error_out; for ( i = 0; i < PAGE_SIZE / sizeof(*ident_pt); i++ ) ident_pt[i] = ((i << 22) | _PAGE_PRESENT | _PAGE_RW | _PAGE_USER | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_PSE); munmap(ident_pt, PAGE_SIZE); xc_set_hvm_param(xch, dom, HVM_PARAM_IDENT_PT, - special_pfn(SPECIALPAGE_IDENT_PT) << PAGE_SHIFT); + special_pfn(SPECIALPAGE_IDENT_PT, nr_special_pages) << PAGE_SHIFT); /* Insert JMP instruction at address 0x0 to reach entry point. */ entry_eip = elf_uval(&elf, elf.ehdr, e_entry); @@ -406,7 +413,8 @@ static int setup_guest(xc_interface *xch, * Create a domain for a virtualized Linux, using files/filenames. */ int xc_hvm_build(xc_interface *xch, uint32_t domid, - const struct xc_hvm_build_args *hvm_args) + const struct xc_hvm_build_args *hvm_args, + uint32_t nr_special_pages) { struct xc_hvm_build_args args = *hvm_args; void *image; @@ -432,7 +440,7 @@ int xc_hvm_build(xc_interface *xch, uint32_t domid, if ( image == NULL ) return -1; - sts = setup_guest(xch, domid, &args, image, image_size); + sts = setup_guest(xch, domid, &args, image, image_size, nr_special_pages); free(image); @@ -447,10 +455,11 @@ int xc_hvm_build(xc_interface *xch, uint32_t domid, * If target == memsize, pages are populated normally. */ int xc_hvm_build_target_mem(xc_interface *xch, - uint32_t domid, - int memsize, - int target, - const char *image_name) + uint32_t domid, + int memsize, + int target, + const char *image_name, + uint32_t nr_special_pages) { struct xc_hvm_build_args args = {}; @@ -458,7 +467,7 @@ int xc_hvm_build_target_mem(xc_interface *xch, args.mem_target = (uint64_t)target << 20; args.image_file_name = image_name; - return xc_hvm_build(xch, domid, &args); + return xc_hvm_build(xch, domid, &args, nr_special_pages); } /* diff --git a/tools/libxc/xenguest.h b/tools/libxc/xenguest.h index 8d885d3..092ee24 100644 --- a/tools/libxc/xenguest.h +++ b/tools/libxc/xenguest.h @@ -188,13 +188,15 @@ struct xc_hvm_build_args { * are optional. */ int xc_hvm_build(xc_interface *xch, uint32_t domid, - const struct xc_hvm_build_args *hvm_args); + const struct xc_hvm_build_args *hvm_args, + uint32_t nr_special_pages); int xc_hvm_build_target_mem(xc_interface *xch, uint32_t domid, int memsize, int target, - const char *image_name); + const char *image_name, + uint32_t nr_special_pages); int xc_suspend_evtchn_release(xc_interface *xch, xc_evtchn *xce, int domid, int suspend_evtchn); diff --git a/tools/libxc/xg_private.c b/tools/libxc/xg_private.c index 3864bc7..e74adce 100644 --- a/tools/libxc/xg_private.c +++ b/tools/libxc/xg_private.c @@ -192,7 +192,8 @@ unsigned long csum_page(void *page) __attribute__((weak)) int xc_hvm_build(xc_interface *xch, uint32_t domid, - const struct xc_hvm_build_args *hvm_args) + const struct xc_hvm_build_args *hvm_args, + uint32_t nr_servers) { errno = ENOSYS; return -1;