From patchwork Tue Feb 23 16:31:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8394301 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06D17C0553 for ; Tue, 23 Feb 2016 16:34:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CAB4202F8 for ; Tue, 23 Feb 2016 16:34:13 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CA30F202EC for ; Tue, 23 Feb 2016 16:34:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYFsH-0002Hh-I5; Tue, 23 Feb 2016 16:31:45 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aYFsG-0002HH-4d for xen-devel@lists.xen.org; Tue, 23 Feb 2016 16:31:44 +0000 Received: from [85.158.139.211] by server-14.bemta-5.messagelabs.com id 17/FC-02992-F698CC65; Tue, 23 Feb 2016 16:31:43 +0000 X-Env-Sender: prvs=8544ffb4f=Andrew.Cooper3@citrix.com X-Msg-Ref: server-15.tower-206.messagelabs.com!1456245100!16039014!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 65109 invoked from network); 23 Feb 2016 16:31:42 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 23 Feb 2016 16:31:42 -0000 X-IronPort-AV: E=Sophos;i="5.22,490,1449532800"; d="scan'208";a="333705409" From: Andrew Cooper To: Xen-devel Date: Tue, 23 Feb 2016 16:31:19 +0000 Message-ID: <1456245085-2302-3-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1456245085-2302-1-git-send-email-andrew.cooper3@citrix.com> References: <1456245085-2302-1-git-send-email-andrew.cooper3@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH v2 2/8] xen/x86: Improvements to build-time pagetable generation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * Additional comments, including size and runtime use. * Consistent use of idx, rather than a mix including pfn. * Consistent use of .quad, rather than a mix including .long. * Consistent use of PAGE_HYPERVISOR for addresses in the Xen global range, which include _PAGE_GLOBAL. No change in runtime behaviour. Signed-off-by: Andrew Cooper --- CC: Jan Beulich New in v2 --- xen/arch/x86/boot/x86_64.S | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 94cf089..cc10932 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -86,32 +86,40 @@ GLOBAL(__page_tables_start) * Mapping of first 2 megabytes of memory. This is mapped with 4kB mappings * to avoid type conflicts with fixed-range MTRRs covering the lowest megabyte * of physical memory. In any case the VGA hole should be mapped with type UC. + * Uses 1x 4k page. */ GLOBAL(l1_identmap) - pfn = 0 + idx = 0 .rept L1_PAGETABLE_ENTRIES /* VGA hole (0xa0000-0xc0000) should be mapped UC. */ - .if pfn >= 0xa0 && pfn < 0xc0 - .long (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR_NOCACHE | MAP_SMALL_PAGES + .if idx >= 0xa0 && idx < 0xc0 + .quad (idx << PAGE_SHIFT) | PAGE_HYPERVISOR_NOCACHE .else - .long (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR | MAP_SMALL_PAGES + .quad (idx << PAGE_SHIFT) | PAGE_HYPERVISOR .endif - .long 0 - pfn = pfn + 1 + idx = idx + 1 .endr .size l1_identmap, . - l1_identmap -/* Mapping of first 16 megabytes of memory. */ +/* + * Space for mapping the first 4GB of memory, with the first 16 megabytes + * actualy mapped (mostly using superpages). Uses 4x 4k pages. + */ GLOBAL(l2_identmap) - .quad sym_phys(l1_identmap) + __PAGE_HYPERVISOR - pfn = 0 + .quad sym_phys(l1_identmap) + PAGE_HYPERVISOR + idx = 1 .rept 7 - pfn = pfn + (1 << PAGETABLE_ORDER) - .quad (pfn << PAGE_SHIFT) | PAGE_HYPERVISOR | _PAGE_PSE + .quad (idx << L2_PAGETABLE_SHIFT) | PAGE_HYPERVISOR | _PAGE_PSE + idx = idx + 1 .endr .fill 4 * L2_PAGETABLE_ENTRIES - 8, 8, 0 .size l2_identmap, . - l2_identmap +/* + * L2 mapping the 1GB Xen text/data/bss region. At boot it maps 16MB from + * __image_base__, and is modified when Xen relocates itself. Uses 1x 4k + * page. + */ GLOBAL(l2_xenmap) idx = 0 .rept 8 @@ -121,11 +129,12 @@ GLOBAL(l2_xenmap) .fill L2_PAGETABLE_ENTRIES - 8, 8, 0 .size l2_xenmap, . - l2_xenmap +/* L2 mapping the fixmap. Uses 1x 4k page. */ l2_fixmap: idx = 0 .rept L2_PAGETABLE_ENTRIES .if idx == l2_table_offset(FIXADDR_TOP - 1) - .quad sym_phys(l1_fixmap) + __PAGE_HYPERVISOR + .quad sym_phys(l1_fixmap) + PAGE_HYPERVISOR .else .quad 0 .endif @@ -133,22 +142,24 @@ l2_fixmap: .endr .size l2_fixmap, . - l2_fixmap +/* Identity map, covering the 4 l2_identmap tables. Uses 1x 4k page. */ GLOBAL(l3_identmap) idx = 0 .rept 4 - .quad sym_phys(l2_identmap) + (idx << PAGE_SHIFT) + __PAGE_HYPERVISOR + .quad sym_phys(l2_identmap) + (idx << PAGE_SHIFT) + PAGE_HYPERVISOR idx = idx + 1 .endr .fill L3_PAGETABLE_ENTRIES - 4, 8, 0 .size l3_identmap, . - l3_identmap +/* L3 mapping the fixmap. Uses 1x 4k page. */ l3_xenmap: idx = 0 .rept L3_PAGETABLE_ENTRIES .if idx == l3_table_offset(XEN_VIRT_START) - .quad sym_phys(l2_xenmap) + __PAGE_HYPERVISOR + .quad sym_phys(l2_xenmap) + PAGE_HYPERVISOR .elseif idx == l3_table_offset(FIXADDR_TOP - 1) - .quad sym_phys(l2_fixmap) + __PAGE_HYPERVISOR + .quad sym_phys(l2_fixmap) + PAGE_HYPERVISOR .else .quad 0 .endif @@ -162,9 +173,9 @@ GLOBAL(idle_pg_table) idx = 1 .rept L4_PAGETABLE_ENTRIES - 1 .if idx == l4_table_offset(DIRECTMAP_VIRT_START) - .quad sym_phys(l3_identmap) + __PAGE_HYPERVISOR + .quad sym_phys(l3_identmap) + PAGE_HYPERVISOR .elseif idx == l4_table_offset(XEN_VIRT_START) - .quad sym_phys(l3_xenmap) + __PAGE_HYPERVISOR + .quad sym_phys(l3_xenmap) + PAGE_HYPERVISOR .else .quad 0 .endif