From patchwork Tue Feb 21 19:19:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kiper X-Patchwork-Id: 9585443 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 CB1E2602A7 for ; Tue, 21 Feb 2017 19:23:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDA81283F9 for ; Tue, 21 Feb 2017 19:23:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B25742860A; Tue, 21 Feb 2017 19:23:11 +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, UNPARSEABLE_RELAY 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 A5A40283F9 for ; Tue, 21 Feb 2017 19:23:09 +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 1cgFzQ-0001oq-LU; Tue, 21 Feb 2017 19:20:44 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cgFzP-0001oW-Pd for xen-devel@lists.xenproject.org; Tue, 21 Feb 2017 19:20:43 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 68/4E-12625-B039CA85; Tue, 21 Feb 2017 19:20:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLLMWRWlGSWpSXmKPExsXSO6nOVZdr8po Ig8a7Chbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8b3xbIFm1Qrpq6+xNjAeFC2i5GLQ0hgMpPE ztcNzBDOX0aJfQ++sEE4Gxklbs4/wQrhTGSU2Dj1O1AZJwebgI7ExS8P2UFsEQEliXurJjOBF DELzGSSOH3nJAtIQljAV+LioidgRSwCqhItt/sYQWxeAXeJg8dfs4HYEgKKEt3PJoDZnAIeEp v/nGACsYWAajZtPc4KUWMs0f72ItsERr4FjAyrGDWKU4vKUot0jUz0kooy0zNKchMzc3QNDYz 1clOLixPTU3MSk4r1kvNzNzECg6WegYFxB+Or436HGCU5mJREeXMy1kQI8SXlp1RmJBZnxBeV 5qQWH2KU4eBQkuB1qQXKCRalpqdWpGXmAMMWJi3BwaMkwnugBijNW1yQmFucmQ6ROsWoKCXOy w/SJwCSyCjNg2uDxcolRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8gSBTeDLzSuCmvwJazA S0+KbHSpDFJYkIKakGRrUrdoXXJdiMd7R+vsw8u3vTm5RD69/G76+QyXR+3Lo/1OphdKN9+8H yHa+Ug5h0vvSVrbyTsuz7WRsXl0OBrIlqHpue/zW5etOga07bz4t/LEv3uGzKZFQ8l5N44ZO+ peLrn4+dV1qet1lQ3Lb8wKUsJ69LRfuduIIOCAuej3SvFs88uSlUSYmlOCPRUIu5qDgRAGHuf E+QAgAA X-Env-Sender: daniel.kiper@oracle.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1487704840!28672590!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33358 invoked from network); 21 Feb 2017 19:20:42 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-4.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 21 Feb 2017 19:20:42 -0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v1LJKUqo020232 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2017 19:20:30 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v1LJKTft022670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 21 Feb 2017 19:20:30 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v1LJKTjf010021; Tue, 21 Feb 2017 19:20:29 GMT Received: from olila.local.net-space.pl (/10.175.217.207) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 21 Feb 2017 11:20:29 -0800 From: Daniel Kiper To: xen-devel@lists.xenproject.org Date: Tue, 21 Feb 2017 20:19:54 +0100 Message-Id: <1487704799-21162-6-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1487704799-21162-1-git-send-email-daniel.kiper@oracle.com> References: <1487704799-21162-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: aserv0022.oracle.com [141.146.126.234] Cc: jgross@suse.com, sstabellini@kernel.org, andrew.cooper3@citrix.com, cardoe@cardoe.com, pgnet.dev@gmail.com, ning.sun@intel.com, julien.grall@arm.com, jbeulich@suse.com, qiaowei.ren@intel.com, gang.wei@intel.com, fu.wei@linaro.org Subject: [Xen-devel] [PATCH v16 5/9] x86: change default load address from 1 MiB to 2 MiB 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Subsequent patches introducing relocatable early boot code play with page tables using 2 MiB huge pages. If load address is not aligned at 2 MiB then code touching such page tables must have special cases for start and end of Xen image memory region. So, let's make life easier and move default load address from 1 MiB to 2 MiB. This way page table code will be nice and easy. Hence, there is a chance that it will be less error prone too... :-))) Additionally, drop first 2 MiB mapping from Xen image mapping. It is no longer needed. Signed-off-by: Daniel Kiper Reviewed-by: Jan Beulich Reviewed-by: Doug Goldstein --- v8 - suggestions/fixes: - drop first 2 MiB mapping from Xen image mapping (suggested by Jan Beulich), - improve commit message. v7 - suggestions/fixes: - minor cleanups (suggested by Jan Beulich). --- xen/arch/x86/Makefile | 2 +- xen/arch/x86/Rules.mk | 3 +++ xen/arch/x86/boot/head.S | 8 -------- xen/arch/x86/boot/x86_64.S | 5 +++-- xen/arch/x86/setup.c | 3 ++- xen/arch/x86/xen.lds.S | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index d6980b5..fead99a 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -91,7 +91,7 @@ all_symbols = endif $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32 - ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) 0x100000 \ + ./boot/mkelf32 $(notes_phdrs) $(TARGET)-syms $(TARGET) $(XEN_IMG_OFFSET) \ `$(NM) $(TARGET)-syms | sed -ne 's/^\([^ ]*\) . __2M_rwdata_end$$/0x\1/p'` ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS) diff --git a/xen/arch/x86/Rules.mk b/xen/arch/x86/Rules.mk index 72be8b2..568657e 100644 --- a/xen/arch/x86/Rules.mk +++ b/xen/arch/x86/Rules.mk @@ -1,9 +1,12 @@ ######################################## # x86-specific definitions +XEN_IMG_OFFSET := 0x200000 + CFLAGS += -I$(BASEDIR)/include CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-generic CFLAGS += -I$(BASEDIR)/include/asm-x86/mach-default +CFLAGS += -DXEN_IMG_OFFSET=$(XEN_IMG_OFFSET) CFLAGS += '-D__OBJECT_LABEL__=$(subst /,$$,$(subst -,_,$(subst $(BASEDIR)/,,$(CURDIR))/$@))' # Prevent floating-point variables from creeping into Xen. diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index a2177c3..b5d9ec8 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -524,14 +524,6 @@ trampoline_setup: mov %eax,sym_phys(boot_tsc_stamp) mov %edx,sym_phys(boot_tsc_stamp+4) - /* - * During boot, hook 4kB mappings of first 2MB of memory into L2. - * This avoids mixing cachability for the legacy VGA region, and is - * corrected when Xen relocates itself. - */ - mov $sym_phys(l1_identmap)+__PAGE_HYPERVISOR,%edi - mov %edi,sym_phys(l2_xenmap) - /* Apply relocations to bootstrap trampoline. */ mov sym_phys(trampoline_phys),%edx mov $sym_phys(__trampoline_rel_start),%edi diff --git a/xen/arch/x86/boot/x86_64.S b/xen/arch/x86/boot/x86_64.S index 4d507fb..f9d1022 100644 --- a/xen/arch/x86/boot/x86_64.S +++ b/xen/arch/x86/boot/x86_64.S @@ -121,8 +121,9 @@ GLOBAL(l2_identmap) * page. */ GLOBAL(l2_xenmap) - idx = 0 - .rept 8 + .quad 0 + idx = 1 + .rept 7 .quad sym_phys(__image_base__) + (idx << L2_PAGETABLE_SHIFT) + (PAGE_HYPERVISOR | _PAGE_PSE) idx = idx + 1 .endr diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 66b7aba..e2a5f76 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -998,7 +998,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) * Undo the temporary-hooking of the l1_identmap. __2M_text_start * is contained in this PTE. */ - BUG_ON(l2_table_offset((unsigned long)_erodata) == + BUG_ON(using_2M_mapping() && + l2_table_offset((unsigned long)_erodata) == l2_table_offset((unsigned long)_stext)); *pl2e++ = l2e_from_pfn(xen_phys_start >> PAGE_SHIFT, PAGE_HYPERVISOR_RX | _PAGE_PSE); diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S index 066aca6..ff93a0b 100644 --- a/xen/arch/x86/xen.lds.S +++ b/xen/arch/x86/xen.lds.S @@ -54,7 +54,7 @@ SECTIONS __2M_text_start = .; /* Start of 2M superpages, mapped RX. */ #endif - . = __XEN_VIRT_START + MB(1); + . = __XEN_VIRT_START + XEN_IMG_OFFSET; _start = .; .text : { _stext = .; /* Text and read-only data */