From patchwork Tue Sep 27 15:56:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 9352177 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D864060757 for ; Tue, 27 Sep 2016 16:00:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA0A52925C for ; Tue, 27 Sep 2016 16:00:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEAFA29286; Tue, 27 Sep 2016 16:00:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 00F122927A for ; Tue, 27 Sep 2016 16:00:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boulq-0007Tg-46; Tue, 27 Sep 2016 15:58:14 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1boulo-0007SH-Ll for xen-devel@lists.xenproject.org; Tue, 27 Sep 2016 15:58:12 +0000 Received: from [85.158.139.211] by server-2.bemta-5.messagelabs.com id 5F/25-15996-3179AE75; Tue, 27 Sep 2016 15:58:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsXitHSDva7g9Ff hBpMvGll83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnnlxxgL7gmU7Hwx3P2Bsbd4l2MnBwSAv4S sx5vYgGx2QR0JC7O3cnWxcjBISKgInF7r0EXIxcHs8BPRonls++C1QgLBEv8vv2GFcRmEVCVu Lb9KxNIPa+Ai8T3jR4QI3UlHp77DVbCKeAq0du2gAnEFgIquTvzI1icV0BQ4uTMJ2AjmQU0JV q3/2aHsOUlmrfOZoaoV5Ton/cA7BwJAW6Jv932Exj5ZyHpnoWkexaS7gWMzKsYNYpTi8pSi3Q NDfWSijLTM0pyEzNzdA0NTPVyU4uLE9NTcxKTivWS83M3MQIDkAEIdjCubHc+xCjJwaQkyqvR /ipciC8pP6UyI7E4I76oNCe1+BCjDAeHkgSvx1SgnGBRanpqRVpmDjAWYNISHDxKIrw804DSv MUFibnFmekQqVOMilLivA0gfQIgiYzSPLg2WPxdYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkj CvAsh4nsy8Erjpr4AWMwEtXnriBcjikkSElFQDoyvf69YLWTOf8Zw5eGj2ulbuFYs2eM6qnH3 75Pebu2LiNRy9xX5/SGpZ+3mu+jo5rnOfS8O+Xw1I6NzjfUE+yVt4hQzb2sbWaJ2UAzOXTupW v3D3+NINYs7PSyp8s48r+b25sNhFchJXYc0NnYA2kXnT5kotTHp16tnPr/ZzFtsozWhdK7xuv p4SS3FGoqEWc1FxIgCmNr9EugIAAA== X-Env-Sender: prvs=071b8e69e=roger.pau@citrix.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1474991886!60100383!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16537 invoked from network); 27 Sep 2016 15:58:09 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 27 Sep 2016 15:58:09 -0000 X-IronPort-AV: E=Sophos;i="5.30,405,1470700800"; d="scan'208";a="389169417" From: Roger Pau Monne To: Date: Tue, 27 Sep 2016 17:56:56 +0200 Message-ID: <1474991845-27962-2-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.7.4 (Apple Git-66) In-Reply-To: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> References: <1474991845-27962-1-git-send-email-roger.pau@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Andrew Cooper , Ian Jackson , Jan Beulich , boris.ostrovsky@oracle.com, Roger Pau Monne Subject: [Xen-devel] [PATCH v2 01/30] xen/x86: move setup of the VM86 TSS to the domain builder X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This is also required for PVHv2 guests if they want to use real-mode, and hvmloader is not executed for those kind of guests. Signed-off-by: Roger Pau Monné --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Ian Jackson Cc: Wei Liu --- tools/firmware/hvmloader/hvmloader.c | 17 ----------------- tools/libxc/include/xc_dom.h | 2 +- tools/libxc/xc_dom_x86.c | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index bbd4e34..9eabbd8 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -176,21 +176,6 @@ static void cmos_write_memory_size(void) cmos_outb(0x35, (uint8_t)( alt_mem >> 8)); } -/* - * Set up an empty TSS area for virtual 8086 mode to use. - * The only important thing is that it musn't have any bits set - * in the interrupt redirection bitmap, so all zeros will do. - */ -static void init_vm86_tss(void) -{ - void *tss; - - tss = mem_alloc(128, 128); - memset(tss, 0, 128); - hvm_param_set(HVM_PARAM_VM86_TSS, virt_to_phys(tss)); - printf("vm86 TSS at %08lx\n", virt_to_phys(tss)); -} - static void apic_setup(void) { /* @@ -398,8 +383,6 @@ int main(void) hvm_param_set(HVM_PARAM_ACPI_IOPORTS_LOCATION, 1); } - init_vm86_tss(); - cmos_write_memory_size(); printf("BIOS map:\n"); diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index de7dca9..e1cfaad 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -20,7 +20,7 @@ #include #define INVALID_PFN ((xen_pfn_t)-1) -#define X86_HVM_NR_SPECIAL_PAGES 8 +#define X86_HVM_NR_SPECIAL_PAGES 9 #define X86_HVM_END_SPECIAL_REGION 0xff000u /* --- typedefs and structs ---------------------------------------- */ diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index 0eab8a7..1676a3c 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -59,6 +59,7 @@ #define SPECIALPAGE_IOREQ 5 #define SPECIALPAGE_IDENT_PT 6 #define SPECIALPAGE_CONSOLE 7 +#define SPECIALPAGE_VM86TSS 8 #define special_pfn(x) \ (X86_HVM_END_SPECIAL_REGION - X86_HVM_NR_SPECIAL_PAGES + (x)) @@ -590,6 +591,7 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom) { unsigned long i; uint32_t *ident_pt, domid = dom->guest_domid; + void *tss; int rc; xen_pfn_t special_array[X86_HVM_NR_SPECIAL_PAGES]; xen_pfn_t ioreq_server_array[NR_IOREQ_SERVER_PAGES]; @@ -699,6 +701,20 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom) xc_hvm_param_set(xch, domid, HVM_PARAM_IDENT_PT, special_pfn(SPECIALPAGE_IDENT_PT) << PAGE_SHIFT); + /* + * Set up an empty TSS area for virtual 8086 mode to use. + * The only important thing is that it musn't have any bits set + * in the interrupt redirection bitmap, so all zeros will do. + */ + if ( (tss = xc_map_foreign_range( + xch, domid, PAGE_SIZE, PROT_READ | PROT_WRITE, + special_pfn(SPECIALPAGE_VM86TSS))) == NULL ) + goto error_out; + memset(tss, 0, 128); + munmap(tss, PAGE_SIZE); + xc_hvm_param_set(xch, domid, HVM_PARAM_VM86_TSS, + special_pfn(SPECIALPAGE_VM86TSS) << PAGE_SHIFT); + dom->console_pfn = special_pfn(SPECIALPAGE_CONSOLE); dom->xenstore_pfn = special_pfn(SPECIALPAGE_XENSTORE); dom->parms.virt_hypercall = -1;