From patchwork Thu Feb 2 19:25:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 93122 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp258034qgi; Thu, 2 Feb 2017 11:28:09 -0800 (PST) X-Received: by 10.107.133.223 with SMTP id p92mr9084484ioi.175.1486063689596; Thu, 02 Feb 2017 11:28:09 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s78si1839359ios.47.2017.02.02.11.28.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Feb 2017 11:28:09 -0800 (PST) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZN0q-0008VO-3g; Thu, 02 Feb 2017 19:25:44 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cZN0p-0008VI-0i for xen-devel@lists.xen.org; Thu, 02 Feb 2017 19:25:43 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 31/7F-27678-6B783985; Thu, 02 Feb 2017 19:25:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrHLMWRWlGSWpSXmKPExsVysyfVTXdr++Q Ig/VrFCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1owdN64xFbyXq/jWeo+tgfGaWBcjJ4eQwCZG icmHzLsYuYDs04wS7/a/ZgZJsAloStz5/IkJxBYRkJa49vkyI0gRs8B2Ronpf64xgiSEBRwlj q5tB2tgEVCVuDzjAVgDr4CLxMQ1h8DiEgJyEiePTWadwMi5gJFhFaN6cWpRWWqRrpleUlFmek ZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkagvxiAYAfjvBP+hxglOZiURHmnaE2OEOJLyk+ pzEgszogvKs1JLT7EKMPBoSTBy9sGlBMsSk1PrUjLzAEGDkxagoNHSYQ3HSTNW1yQmFucmQ6R OsWoKCXOaw2SEABJZJTmwbXBgvUSo6yUMC8j0CFCPAWpRbmZJajyrxjFORiVhHnbQabwZOaVw E1/BbSYCWjxz8eTQBaXJCKkpBoYIwuSln58dWHD84WMRTNDd9o0in+RK9LnWXex7+nciNclnB E8LExusz5+mv/6w5SSxzwNUi/vMZS8tk96qK531Hvvea7FPgVbFxjKC7PnP7hwWFn6hNpT7XU vzaPjK+/l/r3O5eBedKmJxWzyy/XGW2JVtQWCuP6wqymsbJse/dOTV49Frc5YiaU4I9FQi7mo OBEAYjyRcFECAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-27.messagelabs.com!1486063540!54635647!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58689 invoked from network); 2 Feb 2017 19:25:41 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-27.messagelabs.com with SMTP; 2 Feb 2017 19:25:41 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D2742AD7; Thu, 2 Feb 2017 11:25:39 -0800 (PST) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF4DD3F220; Thu, 2 Feb 2017 11:25:38 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 2 Feb 2017 19:25:32 +0000 Message-Id: <1486063532-12288-1-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 Cc: Andrew Cooper , Julien Grall , sstabellini@kernel.org, Daniel Kiper , Jan Beulich Subject: [Xen-devel] [PATCH] xen/arm64: Don't zero BSS when booting using EFI 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" Commit 146786b "efi: create efi_enabled()" introduced a variable efi_flags stored in BSS and used to pass information between the stub and Xen. However on ARM, BSS is zeroed after the stub has finished to run and before Xen is started. This means that the bits set in efi_flags will be lost. We were not affected before because all the variables used to pass information between Xen and the stub are living in initdata or data. Looking at the description of the field SizeOfRawData in the PE/COFF header (see [1]): "If this is less than VirtualSize, the remainder of the section is zero-filled. Because the SizeOfRawData field is rounded but the VirtualSize field is not, it is possible for SizeOfRawData to be greater than VirtualSize as well. When a section contains only uninitialized data, this field should be zero." Both VirtualSize and SizeOfRawData are correctly set in the header (see arch/arm/arm64/head.S) so the EFI firmware will zero BSS for us. Therefore we don't need to zero BSS before running the EFI stub and can skip the one between the EFI stub and Xen. To avoid another branch instruction, slightly refactor the code. The register x26 is allocated to hold whether BSS is skipped. The value will be: - 0 when the code is running on CPU0 and EFI is not used - 1 when EFI is used or running on other processor than the boot one. [1] https://msdn.microsoft.com/en-us/library/windows/desktop/ms680547(v=vs.85).aspx Signed-off-by: Julien Grall Reviewed-by: Daniel Kiper Reviewed-by: Stefano Stabellini --- CC: Jan Beulich CC: Daniel Kiper CC: Andrew Cooper This patch fix ACPI boot on Xen ARM. Without it Xen thinks it is not running on EFI and will not try to find the RDSP. --- xen/arch/arm/arm64/head.S | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 3f63d2a..8cb4602 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -65,7 +65,7 @@ * x23 - UART address * x24 - cpuid * x25 - identity map in place - * x26 - + * x26 - skip_zero_bss * x27 - * x28 - * x29 - @@ -232,6 +232,10 @@ section_table: .long 0xe0500020 /* Characteristics (section flags) */ .align 5 real_start: + /* BSS should be zeroed when booting with efi */ + mov x26, #0 /* x26 := skip_zero_bss */ + +real_start_efi: msr DAIFSet, 0xf /* Disable all interrupts */ /* Save the bootloader arguments in less-clobberable registers */ @@ -261,6 +265,8 @@ GLOBAL(init_secondary) sub x20, x19, x0 /* x20 := phys-offset */ mov x22, #1 /* x22 := is_secondary_cpu */ + /* Skip zero BSS on secondary CPUs to avoid nasty surprises. */ + mov x26, #1 /* X26 := skip_zero_bss */ common_start: mov x24, #0 /* x24 := CPU ID. Initialy zero until we @@ -314,8 +320,8 @@ common_start: el2: PRINT("- Xen starting at EL2 -\r\n") - /* Zero BSS On the boot CPU to avoid nasty surprises */ - cbnz x22, skip_bss + /* Zero BSS only when requested to avoid nasty surprises. */ + cbnz x26, skip_bss PRINT("- Zero BSS -\r\n") ldr x0, =__bss_start /* Load start & end of bss */ @@ -787,7 +793,16 @@ ENTRY(efi_xen_start) mov x1, xzr mov x2, xzr mov x3, xzr - b real_start + /* + * The EFI stub and Xen may share some information living in + * BSS. Don't zero BSS to avoid loosing them. + * + * Note that the EFI firmware has already zeroed BSS for us + * before jump into the stub. + */ + mov x26, #1 /* x26 := skip_zero_bss */ + + b real_start_efi ENDPROC(efi_xen_start) /*