From patchwork Fri Jan 17 20:42:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11339727 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3124692A for ; Fri, 17 Jan 2020 20:43:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D8172072E for ; Fri, 17 Jan 2020 20:43:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="V1/Ez/Kw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D8172072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYS1-0004zk-JI; Fri, 17 Jan 2020 20:42:41 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYS0-0004yu-RD for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 20:42:40 +0000 X-Inumbo-ID: df856c36-3969-11ea-9fd7-bc764e2007e4 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id df856c36-3969-11ea-9fd7-bc764e2007e4; Fri, 17 Jan 2020 20:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579293747; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oGgEPL6H4T/atSijyUJAoByln4PcK5zMY4BCVapfIJs=; b=V1/Ez/KwOuMQjfqHKITGxeZOSyqeV2jocqzb7DLZoey6pteimqs4GH1j o+vSB49fOWvIH54eYZda4nyCCOnKM/51d76q2qb/vbTWelqphj3jkMgRj RX0AGs1847mVAJum+zs9kI/BrNDdmaT4eqkrXD21YElsT8xXWuaNFPtr7 I=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: o4pF3YPvmxnMRGEVT7JubDEU6+MLx62FBx6XZuynb8yV12ZxZv1knYkJzpeSBDCwWA53WTguli EoQ3f8KvRY0fNhkhAejYujQcny8tnvFq//tzbLjOYdU9hiGrQAEw8+pdVxVDBAhdwgnsfT5TQW VfDolS1El2ymKZONKBOUcAaVj4vtAwRjmn5mepqEc1rqJ5iJyOmcNNWkjVgjTIgupGzDDUN3s/ iu9oKnFCoFyr5xqs5CDGky/1b6kg9b0aWuf2LpIGSWZGAi3hWZcWSWBLMQn0rQP+JVv9AzQKLK Eig= X-SBRS: 2.7 X-MesageID: 11526071 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,331,1574139600"; d="scan'208";a="11526071" From: Andrew Cooper To: Xen-devel Date: Fri, 17 Jan 2020 20:42:19 +0000 Message-ID: <20200117204223.30076-2-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200117204223.30076-1-andrew.cooper3@citrix.com> References: <20200117204223.30076-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 1/5] x86/boot: Create the l2_xenmap[] mappings dynamically X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The build-time construction of l2_xenmap[] imposes an arbitrary limit of 16M total, which is a limit looking to be lifted. Move l2_xenmap[] into the BSS, and adjust both the BIOS and EFI paths to fill it in dynamically, based on the final linked size of Xen. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné v2: * Rewrite several comments --- xen/arch/x86/boot/head.S | 14 ++++++++++++++ xen/arch/x86/boot/x86_64.S | 23 ++++++++--------------- xen/arch/x86/efi/efi-boot.h | 14 ++++++++++++++ xen/arch/x86/xen.lds.S | 3 +++ 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index c5acbf56ae..ef9f562505 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -668,6 +668,20 @@ trampoline_setup: add %esi,sym_fs(__page_tables_start)-8(,%ecx,8) 2: loop 1b + /* Map Xen into the higher mappings using 2M superpages. */ + lea _PAGE_PSE + PAGE_HYPERVISOR_RWX + sym_esi(_start), %eax + mov $sym_offs(_start), %ecx /* %eax = PTE to write ^ */ + mov $sym_offs(_end - 1), %edx + shr $L2_PAGETABLE_SHIFT, %ecx /* %ecx = First slot to write */ + shr $L2_PAGETABLE_SHIFT, %edx /* %edx = Final slot to write */ + +1: mov %eax, sym_offs(l2_xenmap)(%esi, %ecx, 8) + add $1, %ecx + add $1 << L2_PAGETABLE_SHIFT, %eax + + cmp %edx, %ecx + jbe 1b + /* * Map Xen into the directmap (needed for early-boot pagetable * handling/walking), and identity map Xen into bootmap (needed for diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index aabf561b23..e63bece460 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -43,6 +43,14 @@ multiboot_ptr: GLOBAL(stack_start) .quad cpu0_stack + STACK_SIZE - CPUINFO_sizeof + .section .bss.page_aligned, "aw", @nobits + .align PAGE_SIZE, 0 + +/* L2 mapping the Xen text/data/bss region. Uses 1x 4k page. */ +GLOBAL(l2_xenmap) + .fill L2_PAGETABLE_ENTRIES, 8, 0 + .size l2_xenmap, . - l2_xenmap + .section .data.page_aligned, "aw", @progbits .align PAGE_SIZE, 0 /* @@ -80,21 +88,6 @@ GLOBAL(l2_directmap) .fill 4 * L2_PAGETABLE_ENTRIES - 1, 8, 0 .size l2_directmap, . - l2_directmap -/* - * 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) - .quad 0 - idx = 1 - .rept 7 - .quad sym_offs(__image_base__) + (idx << L2_PAGETABLE_SHIFT) + (PAGE_HYPERVISOR_RWX | _PAGE_PSE) - idx = idx + 1 - .endr - .fill L2_PAGETABLE_ENTRIES - 8, 8, 0 - .size l2_xenmap, . - l2_xenmap - /* L2 mapping the fixmap. Uses 1x 4k page. */ l2_fixmap: idx = 0 diff --git a/xen/arch/x86/efi/efi-boot.h b/xen/arch/x86/efi/efi-boot.h index 50d1499867..ce07aedf45 100644 --- a/xen/arch/x86/efi/efi-boot.h +++ b/xen/arch/x86/efi/efi-boot.h @@ -585,6 +585,20 @@ static void __init efi_arch_memory_setup(void) if ( !efi_enabled(EFI_LOADER) ) return; + /* + * Map Xen into the higher mappings, using 2M superpages. + * + * NB: We are currently in physical mode, so a RIP-relative relocation + * against _start/_end result in our arbitrary placement by the bootloader + * in memory, rather than the intended high mappings position. Subtract + * xen_phys_start to get the appropriate slots in l2_xenmap[]. + */ + for ( i = l2_table_offset((UINTN)_start - xen_phys_start); + i <= l2_table_offset((UINTN)_end - 1 - xen_phys_start); ++i ) + l2_xenmap[i] = + l2e_from_paddr(xen_phys_start + (i << L2_PAGETABLE_SHIFT), + PAGE_HYPERVISOR_RWX | _PAGE_PSE); + /* Check that there is at least 4G of mapping space in l2_*map[] */ BUILD_BUG_ON((sizeof(l2_bootmap) / L2_PAGETABLE_ENTRIES) < 4); BUILD_BUG_ON((sizeof(l2_directmap) / L2_PAGETABLE_ENTRIES) < 4); diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 29ef507432..07c6448dbb 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -360,6 +360,9 @@ ASSERT(__2M_rwdata_end <= XEN_VIRT_END - XEN_VIRT_START + __XEN_VIRT_START - ASSERT(kexec_reloc_size - kexec_reloc <= PAGE_SIZE, "kexec_reloc is too large") #endif +/* The Multiboot setup paths relies on this to simplify superpage PTE creation. */ +ASSERT(IS_ALIGNED(_start, MB(2)), "_start misaligned") + ASSERT(IS_ALIGNED(__2M_text_end, SECTION_ALIGN), "__2M_text_end misaligned") ASSERT(IS_ALIGNED(__2M_rodata_start, SECTION_ALIGN), "__2M_rodata_start misaligned") ASSERT(IS_ALIGNED(__2M_rodata_end, SECTION_ALIGN), "__2M_rodata_end misaligned") From patchwork Fri Jan 17 20:42:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11339723 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 092E9138D for ; Fri, 17 Jan 2020 20:43:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D96CC2082F for ; Fri, 17 Jan 2020 20:43:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="bUjK78HD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D96CC2082F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYRs-0004vO-0Z; Fri, 17 Jan 2020 20:42:32 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYRq-0004uz-0X for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 20:42:30 +0000 X-Inumbo-ID: dfbc0c14-3969-11ea-b618-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id dfbc0c14-3969-11ea-b618-12813bfff9fa; Fri, 17 Jan 2020 20:42:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579293748; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fpCO0ehVSAQgDjvhHyCszFmIE7gcwm29q8mHr7AMMDk=; b=bUjK78HD2UHlkh0o5dNI4+bJKXHoi+ugJVAFTiEBZxXXH3qgV/fgB0Yr D+DwbkXd+7yy9Aba2V24QD8lr2VSlFOiagJp+DDhfYeZcUWzxU65SDq0w RO99qqGf2cYaS3x6EHGj4n39DbgWXqbkleapOwHVAnlAj1Lv6tpKT7PuR Q=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 7gCKtV2y8COdvzMRWJ2BKsyxla/KMiosFxoQp+NXQw1ri7I3yKjYD4fWqjRmgCDcHFMxbNn9G2 Dh2npbjnT7ybROGhee6TXXs3CBju0VGzDFCXxnyw9SXROZqMBBTvfF7fcxt6EMc6PB33blHy5I xwolFk8pUByaXTrheWiE/dZoDDfidMLiLmmjjnXbI7gN1y5pnu/rzkhBGIUFk90Wxe9Hfihn5+ vyIZAmRq/DZPlEgDBPbmS18AC3H8C/3oYRPdSJtyT60ffWFmn8re+W8mxif8tg0wAs3d721vTm 1I0= X-SBRS: 2.7 X-MesageID: 11688713 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,331,1574139600"; d="scan'208";a="11688713" From: Andrew Cooper To: Xen-devel Date: Fri, 17 Jan 2020 20:42:20 +0000 Message-ID: <20200117204223.30076-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200117204223.30076-1-andrew.cooper3@citrix.com> References: <20200117204223.30076-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 2/5] x86/boot: Size the boot/directmap mappings dynamically X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" ... rather than presuming that 16M will do. On the EFI side, use l2e_add_flags() to reduce the code-generation overhead of using l2e_from_paddr() twice. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné v2: * Drop adjustment to the linker script. There are more 16M issues to find. --- xen/arch/x86/boot/head.S | 21 +++++++++++++-------- xen/arch/x86/efi/efi-boot.h | 23 ++++++++++++++++++----- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index ef9f562505..0137ee99a4 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -687,14 +687,19 @@ trampoline_setup: * handling/walking), and identity map Xen into bootmap (needed for * the transition into long mode), using 2M superpages. */ - lea sym_esi(start),%ebx - lea (1<> L2_PAGETABLE_SHIFT) & (4 * L2_PAGETABLE_ENTRIES - 1)) + + for ( i = l2_4G_offset(_start); + i <= l2_4G_offset(_end - 1); ++i ) { - unsigned int slot = (xen_phys_start >> L2_PAGETABLE_SHIFT) + i; - paddr_t addr = slot << L2_PAGETABLE_SHIFT; + l2_pgentry_t pte = l2e_from_paddr(i << L2_PAGETABLE_SHIFT, + __PAGE_HYPERVISOR | _PAGE_PSE); + + l2_bootmap[i] = pte; + + /* Bootmap RWX/Non-global. Directmap RW/Global. */ + l2e_add_flags(pte, PAGE_HYPERVISOR); - l2_directmap[slot] = l2e_from_paddr(addr, PAGE_HYPERVISOR|_PAGE_PSE); - l2_bootmap[slot] = l2e_from_paddr(addr, __PAGE_HYPERVISOR|_PAGE_PSE); + l2_directmap[i] = pte; } +#undef l2_4G_offset } static void __init efi_arch_handle_module(struct file *file, const CHAR16 *name, From patchwork Fri Jan 17 20:42:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11339721 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2472292A for ; Fri, 17 Jan 2020 20:43:31 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0008C2072E for ; Fri, 17 Jan 2020 20:43:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="TS8NI0+I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0008C2072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYRw-0004wZ-B6; Fri, 17 Jan 2020 20:42:36 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYRu-0004wB-TG for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 20:42:34 +0000 X-Inumbo-ID: e0585092-3969-11ea-b618-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e0585092-3969-11ea-b618-12813bfff9fa; Fri, 17 Jan 2020 20:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579293749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=peR5YpwnLucy99fGI8zjvLj+hucdOn9FmBcbB0UM/5w=; b=TS8NI0+IDbsG3dV87RKuHm2tz87BMjXqviN7HeuWBtsCoeWrSFqlPtcN aKIJOw2/R2fVkan3mB7JNPJNW6Svn35YjNVkRKC/qzrULw/53Zisg733G KLJLNIaGzPDixIqSDX8/RfcYVVSqhToAMk0b8sMDj+Pn8Xbh7cfrUMVfZ Y=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: DiPOMOLQgxIPkEuFWfcnQtAySzjfWX3Owbyr1cp01uAk8LGsUqgCOz+Q5g7LqtXH/c1zfpLL+x rfYPytEllzzmlu/SJaXN1ihjLbBrlqMusHgKmfw2iJ3J2j89gq1Zst0OObXOcF/tksw8VwrxOB orc/HMDGP8mJCRdcfa3kG+qdUTL7njZjy5LOHhc9V0y3W+fTfnNX40RNIKSLBvlEtkHRUD9v3r Y1qmMVAfnf1ENgmy6LresszYDWurTmQfacCDs0gGprsvi1qUya7Rl8d/6aSD7CwORAievfrwLb rM4= X-SBRS: 2.7 X-MesageID: 11688714 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,331,1574139600"; d="scan'208";a="11688714" From: Andrew Cooper To: Xen-devel Date: Fri, 17 Jan 2020 20:42:21 +0000 Message-ID: <20200117204223.30076-4-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200117204223.30076-1-andrew.cooper3@citrix.com> References: <20200117204223.30076-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 3/5] x86/boot: Drop explicit %fs uses X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The trampoline relocation code uses %fs for accessing Xen, and this comes with an arbitrary 16M limitation. We could adjust the limit, but the boot code is a confusing mix of %ds/%esi-based and %fs-based accesses, and the use of %fs is longer to encode, and incurs an address generation overhead. Rewrite the logic to use %ds, for better consistency with the surrounding code, and a marginal performance improvement. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/boot/head.S | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 0137ee99a4..1deeae2f2a 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -718,23 +718,27 @@ trampoline_setup: mov %edx, sym_esi(l2_bootmap) /* Apply relocations to bootstrap trampoline. */ - mov sym_fs(trampoline_phys),%edx - mov $sym_offs(__trampoline_rel_start),%edi + mov sym_esi(trampoline_phys), %edx + lea sym_esi(__trampoline_rel_start), %edi + lea sym_esi(__trampoline_rel_stop), %ecx 1: - mov %fs:(%edi),%eax - add %edx,%fs:(%edi,%eax) + mov (%edi), %eax + add %edx, (%edi, %eax) add $4,%edi - cmp $sym_offs(__trampoline_rel_stop),%edi + + cmp %ecx, %edi jb 1b /* Patch in the trampoline segment. */ shr $4,%edx - mov $sym_offs(__trampoline_seg_start),%edi + lea sym_esi(__trampoline_seg_start), %edi + lea sym_esi(__trampoline_seg_stop), %ecx 1: - mov %fs:(%edi),%eax - mov %dx,%fs:(%edi,%eax) + mov (%edi), %eax + mov %dx, (%edi, %eax) add $4,%edi - cmp $sym_offs(__trampoline_seg_stop),%edi + + cmp %ecx, %edi jb 1b /* Do not parse command line on EFI platform here. */ @@ -760,9 +764,9 @@ trampoline_setup: push %eax /* Copy bootstrap trampoline to low memory, below 1MB. */ - mov $sym_offs(trampoline_start),%esi + lea sym_esi(trampoline_start), %esi mov $((trampoline_end - trampoline_start) / 4),%ecx - rep movsl %fs:(%esi),%es:(%edi) + rep movsl /* Jump into the relocated trampoline. */ lret From patchwork Fri Jan 17 20:42:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11339731 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 84C2F92A for ; Fri, 17 Jan 2020 20:43:39 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 60C382072E for ; Fri, 17 Jan 2020 20:43:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="NzTNjWKy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 60C382072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYS5-00052g-Uv; Fri, 17 Jan 2020 20:42:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYS4-00052A-TQ for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 20:42:44 +0000 X-Inumbo-ID: e0585094-3969-11ea-b618-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e0585094-3969-11ea-b618-12813bfff9fa; Fri, 17 Jan 2020 20:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579293749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lwxbiIIphKzv7M1wucFaTA2yiLn6ylvMeg5ek0OqqtM=; b=NzTNjWKymJ77mAeZl/ylvSetxtWr/LYQM5x6LUXZ3uioOhEzCKqkTbkH 1KB33wZQ1hze/vzfom2yiLMYKTpPBn8iXE7phdbI2fs9J4yllWG4ViQRR Nxe/qdHtY3gHLtO+U7X0RYnwFXSJXEfA4jDFKPQyFYZFu63RovAtys9fN k=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: NLwMu/lyppxgkdJGGTHgvjEoNtuwpwzJF3kL6hqvEbMtp2L0BT4q3QBv4yHjnAm7JBtTyh2SMl QmYkEMEkM4oVPN/rhsGTmaFvF2xF8tQn1Ett7VclcRlQE49SJ6BlwWhf14H1TEn/v/2Dkko9DE Bt0HKkzoBcGuCvwyVAAzRpxFx+zX0CWmctP6kMysHbkEkZ+0/yxM5lxLWHv2nxTfiJm5MUS8WE zUMgdJkl9CDLLwOpiMmg3ztxm58xnOTVeB9OwA4lE0rHDhU5LdbyzzZbK7hSnohzoyX18KX28Q PlA= X-SBRS: 2.7 X-MesageID: 11688716 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,331,1574139600"; d="scan'208";a="11688716" From: Andrew Cooper To: Xen-devel Date: Fri, 17 Jan 2020 20:42:22 +0000 Message-ID: <20200117204223.30076-5-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200117204223.30076-1-andrew.cooper3@citrix.com> References: <20200117204223.30076-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 4/5] x86/boot: Simplify pagetable manipulation loops X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For __page_tables_{start,end} and L3 bootmap initialisation, the logic is unnecesserily complicated owing to its attempt to use the LOOP instruction, which results in an off-by-8 memory address owing to LOOP's termination condition. Rewrite both loops for improved clarity and speed. Misc notes: * TEST $IMM, MEM can't macrofuse. The loop has 0x1200 iterations, so pull the $_PAGE_PRESENT constant out into a spare register to turn the TEST into its %REG, MEM form, which can macrofuse. * Avoid the use of %fs-relative references. %esi-relative is the more common form in the code, and doesn't suffer an address generation overhead. * Avoid LOOP. CMP/JB isn't microcoded and faster to execute in all cases. * For a 4 interation trivial loop, even compilers unroll these. The generated code size is a fraction larger, but this is init and the asm is far easier to follow. * Reposition the l2=>l1 bootmap construction so the asm reads in pagetable level order. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/boot/head.S | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 1deeae2f2a..1acaf817ba 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -662,11 +662,17 @@ trampoline_setup: mov %edx,sym_fs(boot_tsc_stamp)+4 /* Relocate pagetables to point at Xen's current location in memory. */ - mov $((__page_tables_end-__page_tables_start)/8),%ecx -1: testl $_PAGE_PRESENT,sym_fs(__page_tables_start)-8(,%ecx,8) + mov $_PAGE_PRESENT, %edx + lea sym_esi(__page_tables_start), %eax + lea sym_esi(__page_tables_end), %edi + +1: testb %dl, (%eax) /* if page present */ jz 2f - add %esi,sym_fs(__page_tables_start)-8(,%ecx,8) -2: loop 1b + add %esi, (%eax) /* pte += base */ +2: add $8, %eax + + cmp %edi, %eax + jb 1b /* Map Xen into the higher mappings using 2M superpages. */ lea _PAGE_PSE + PAGE_HYPERVISOR_RWX + sym_esi(_start), %eax @@ -701,22 +707,27 @@ trampoline_setup: cmp %edx, %ecx jbe 1b - /* Initialize L3 boot-map page directory entries. */ - lea __PAGE_HYPERVISOR+(L2_PAGETABLE_ENTRIES*8)*3+sym_esi(l2_bootmap),%eax - mov $4,%ecx -1: mov %eax,sym_fs(l3_bootmap)-8(,%ecx,8) - sub $(L2_PAGETABLE_ENTRIES*8),%eax - loop 1b - - /* Map the permanent trampoline page into l{1,2}_bootmap[]. */ + /* Map 4x l2_bootmap[] into l3_bootmap[0...3] */ + lea __PAGE_HYPERVISOR + sym_esi(l2_bootmap), %eax + mov $PAGE_SIZE, %edx + mov %eax, 0 + sym_esi(l3_bootmap) + add %edx, %eax + mov %eax, 8 + sym_esi(l3_bootmap) + add %edx, %eax + mov %eax, 16 + sym_esi(l3_bootmap) + add %edx, %eax + mov %eax, 24 + sym_esi(l3_bootmap) + + /* Map l1_bootmap[] into l2_bootmap[0]. */ + lea __PAGE_HYPERVISOR + sym_esi(l1_bootmap), %eax + mov %eax, sym_esi(l2_bootmap) + + /* Map the permanent trampoline page into l1_bootmap[]. */ mov sym_esi(trampoline_phys), %ecx lea __PAGE_HYPERVISOR_RX(%ecx), %edx /* %edx = PTE to write */ shr $PAGE_SHIFT, %ecx /* %ecx = Slot to write */ mov %edx, sym_offs(l1_bootmap)(%esi, %ecx, 8) - lea __PAGE_HYPERVISOR + sym_esi(l1_bootmap), %edx - mov %edx, sym_esi(l2_bootmap) - /* Apply relocations to bootstrap trampoline. */ mov sym_esi(trampoline_phys), %edx lea sym_esi(__trampoline_rel_start), %edi From patchwork Fri Jan 17 20:42:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11339729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76661138D for ; Fri, 17 Jan 2020 20:43:36 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52FE52072E for ; Fri, 17 Jan 2020 20:43:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="VrhjcAgy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52FE52072E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYS1-0004z2-0c; Fri, 17 Jan 2020 20:42:41 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1isYRz-0004yb-TZ for xen-devel@lists.xenproject.org; Fri, 17 Jan 2020 20:42:39 +0000 X-Inumbo-ID: e10e6f1c-3969-11ea-b618-12813bfff9fa Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id e10e6f1c-3969-11ea-b618-12813bfff9fa; Fri, 17 Jan 2020 20:42:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1579293749; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YBmap6C478XSgQIRF3uqTTI46EHEB9iCWn6tw5D2SFw=; b=VrhjcAgyId/UWgUlhiWWeVpcplCMMZRjDtrxCe7nW0ytRpniOhtaMRBx NkQz9c50ZqfUX0Pcn59bG/DHsCO0jtRlyys9Ltoqs2h5yi7LnMO/0MZKU +y1JhTu5hu5IdXZB6JocnVWdhWSk1/AIB/qb+kaAT4uDZNYaLEPDbh4S5 4=; Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: qlVCX4zCbpejCiZ7uewKx0osAQ0PwlNq9AU5tCfa9Eq2RXjiiKMnejJiJYWgYsD2Ozld69yaBU 0CygI8jR8Wnx6tNyNrC3ayHcMGuZ6snPf1ElogvUqtfOJ16/Q+PCH9v3TCX3dBORQnpQtBYxyO BOGKBDXx0vmv2Uu2rNxjIc3Lqam9wfbVR+hRBPPMhquFLyYeyOMaCLx6112TcV7LAqiUiXgZ4X oc/lZPQTNALRtV+R3JL7pQBTXxWuc3JosiVYy6QWJ2nT1yylecJwrn884lBFLllRt5Be3HIaT2 ew0= X-SBRS: 2.7 X-MesageID: 11688715 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,331,1574139600"; d="scan'208";a="11688715" From: Andrew Cooper To: Xen-devel Date: Fri, 17 Jan 2020 20:42:23 +0000 Message-ID: <20200117204223.30076-6-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200117204223.30076-1-andrew.cooper3@citrix.com> References: <20200117204223.30076-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v2 5/5] x86/boot: Drop sym_fs() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" All remaining users of sym_fs() can trivially be switched to using sym_esi() instead. This is shorter to encode and faster to execute. This removes the final uses of %fs during boot, which allows us to drop BOOT_FS from the trampoline GDT, which drops an 16M arbitrary limit on Xen's compiled size. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/boot/head.S | 41 ++++++++++++++--------------------------- xen/arch/x86/boot/trampoline.S | 1 - 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index 1acaf817ba..aea6744c80 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -14,14 +14,12 @@ #define sym_offs(sym) ((sym) - __XEN_VIRT_START) #define sym_esi(sym) sym_offs(sym)(%esi) -#define sym_fs(sym) %fs:sym_offs(sym) #define BOOT_CS32 0x0008 #define BOOT_CS64 0x0010 #define BOOT_DS 0x0018 #define BOOT_PSEUDORM_CS 0x0020 #define BOOT_PSEUDORM_DS 0x0028 -#define BOOT_FS 0x0030 #define MB2_HT(name) (MULTIBOOT2_HEADER_TAG_##name) #define MB2_TT(name) (MULTIBOOT2_TAG_TYPE_##name) @@ -555,24 +553,13 @@ trampoline_bios_setup: trampoline_setup: /* * Called on legacy BIOS and EFI platforms. - * - * Set the BOOT_FS descriptor base address to %esi. */ - mov %esi, %edx - shr $16, %edx - mov %si, BOOT_FS + 2 + sym_esi(trampoline_gdt) /* Bits 0-15 */ - mov %dl, BOOT_FS + 4 + sym_esi(trampoline_gdt) /* Bits 16-23 */ - mov %dh, BOOT_FS + 7 + sym_esi(trampoline_gdt) /* Bits 24-31 */ - - /* Load %fs to allow for access to Xen data. */ - mov $BOOT_FS, %edx - mov %edx, %fs /* Save Xen image load base address for later use. */ - mov %esi,sym_fs(xen_phys_start) - mov %esi,sym_fs(trampoline_xen_phys_start) + mov %esi, sym_esi(xen_phys_start) + mov %esi, sym_esi(trampoline_xen_phys_start) - mov sym_fs(trampoline_phys),%ecx + mov sym_esi(trampoline_phys), %ecx /* Get bottom-most low-memory stack address. */ add $TRAMPOLINE_SPACE,%ecx @@ -583,13 +570,13 @@ trampoline_setup: push %eax /* Magic number. */ call reloc #ifdef CONFIG_PVH_GUEST - cmpb $0, sym_fs(pvh_boot) + cmpb $0, sym_esi(pvh_boot) je 1f - mov %eax, sym_fs(pvh_start_info_pa) + mov %eax, sym_esi(pvh_start_info_pa) jmp 2f #endif 1: - mov %eax, sym_fs(multiboot_ptr) + mov %eax, sym_esi(multiboot_ptr) 2: /* @@ -613,7 +600,7 @@ trampoline_setup: * Do not zero BSS on EFI platform here. * It was initialized earlier. */ - cmpb $0,sym_fs(efi_platform) + cmpb $0, sym_esi(efi_platform) jnz 1f /* @@ -632,7 +619,7 @@ trampoline_setup: /* Interrogate CPU extended features via CPUID. */ mov $1, %eax cpuid - mov %ecx, sym_fs(boot_cpu_data) + CPUINFO_FEATURE_OFFSET(X86_FEATURE_HYPERVISOR) + mov %ecx, CPUINFO_FEATURE_OFFSET(X86_FEATURE_HYPERVISOR) + sym_esi(boot_cpu_data) mov $0x80000000,%eax cpuid @@ -644,7 +631,7 @@ trampoline_setup: jbe 1f mov $0x80000001,%eax cpuid -1: mov %edx, sym_fs(boot_cpu_data) + CPUINFO_FEATURE_OFFSET(X86_FEATURE_LM) +1: mov %edx, CPUINFO_FEATURE_OFFSET(X86_FEATURE_LM) + sym_esi(boot_cpu_data) /* Check for NX. Adjust EFER setting if available. */ bt $cpufeat_bit(X86_FEATURE_NX), %edx @@ -658,8 +645,8 @@ trampoline_setup: /* Stash TSC to calculate a good approximation of time-since-boot */ rdtsc - mov %eax,sym_fs(boot_tsc_stamp) - mov %edx,sym_fs(boot_tsc_stamp)+4 + mov %eax, sym_esi(boot_tsc_stamp) + mov %edx, 4 + sym_esi(boot_tsc_stamp) /* Relocate pagetables to point at Xen's current location in memory. */ mov $_PAGE_PRESENT, %edx @@ -753,11 +740,11 @@ trampoline_setup: jb 1b /* Do not parse command line on EFI platform here. */ - cmpb $0,sym_fs(efi_platform) + cmpb $0, sym_esi(efi_platform) jnz 1f /* Bail if there is no command line to parse. */ - mov sym_fs(multiboot_ptr),%ebx + mov sym_esi(multiboot_ptr), %ebx testl $MBI_CMDLINE,MB_flags(%ebx) jz 1f @@ -768,7 +755,7 @@ trampoline_setup: 1: /* Switch to low-memory stack which lives at the end of trampoline region. */ - mov sym_fs(trampoline_phys),%edi + mov sym_esi(trampoline_phys), %edi lea TRAMPOLINE_SPACE+TRAMPOLINE_STACK_SPACE(%edi),%esp lea trampoline_boot_cpu_entry-trampoline_start(%edi),%eax pushl $BOOT_CS32 diff --git a/xen/arch/x86/boot/trampoline.S b/xen/arch/x86/boot/trampoline.S index 6b403a6d1a..18c6638924 100644 --- a/xen/arch/x86/boot/trampoline.S +++ b/xen/arch/x86/boot/trampoline.S @@ -129,7 +129,6 @@ gdt_48: .quad 0x00cf93000000ffff /* 0x0018: ring 0 data */ .quad 0x00009b000000ffff /* 0x0020: real-mode code @ BOOT_TRAMPOLINE */ .quad 0x000093000000ffff /* 0x0028: real-mode data @ BOOT_TRAMPOLINE */ - .quad 0x00c0930000000fff /* 0x0030: ring 0 Xen data, 16M @ XEN */ .Ltrampoline_gdt_end: /* Relocations for trampoline Real Mode segments. */