From patchwork Wed Feb 8 10:48:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 93609 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2666361obz; Wed, 8 Feb 2017 02:50:30 -0800 (PST) X-Received: by 10.36.19.201 with SMTP id 192mr15455328itz.30.1486551030026; Wed, 08 Feb 2017 02:50:30 -0800 (PST) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 28si14428768iod.106.2017.02.08.02.50.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Feb 2017 02:50:30 -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 1cbPnV-000548-K6; Wed, 08 Feb 2017 10:48:25 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cbPnU-00053z-1I for xen-devel@lists.xen.org; Wed, 08 Feb 2017 10:48:24 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 58/08-02804-777FA985; Wed, 08 Feb 2017 10:48:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrPLMWRWlGSWpSXmKPExsVysyfVTbfs+6w IgwuTtSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ozj+66zFHyTr9i3spu9gXGjeBcjF4eQwCZG iY3NO5ghnNOMEivXH2bvYuTkYBPQlLjz+RMTiC0iIC1x7fNlRpAiZoHtjBLT/1xjBEkICzhKH F3bzgxiswioSqybMgEozsHBK+Ai8ba5FCQsISAncfLYZNYJjJwLGBlWMWoUpxaVpRbpGhroJR VlpmeU5CZm5gB5xnq5qcXFiempOYlJxXrJ+bmbGIEeq2dgYNzBuK3L+RCjJAeTkiivz9NZEUJ 8SfkplRmJxRnxRaU5qcWHGGU4OJQkeEO+AeUEi1LTUyvSMnOAoQOTluDgURLhbQZJ8xYXJOYW Z6ZDpE4xKkqJ884GSQiAJDJK8+DaYOF6iVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw71WQK TyZeSVw018BLWYCWnz9NNjikkSElFQD4xr3p03qbMyiAUt2lFxoeyC9QaSodf3lG58OLegPNm n6In9xketepbi6B2d7sr59CuhSOey2e7pxu1CNSa+/8uRb+oe++fE3qalNv1+nYNW/Vmxln7r fT5UPl45sfBJi/+RIXu7fTcbi/69/ld+zacHXM5dPnLC9oZq5+vi3hced0k7/OrG+/J0SS3FG oqEWc1FxIgAzids3UgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1486550901!83883249!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 7869 invoked from network); 8 Feb 2017 10:48:22 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-31.messagelabs.com with SMTP; 8 Feb 2017 10:48:22 -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 E4191AD7; Wed, 8 Feb 2017 02:48:20 -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 E0E0D3F458; Wed, 8 Feb 2017 02:48:19 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 8 Feb 2017 10:48:14 +0000 Message-Id: <1486550894-10830-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. I did not put the reviewed-by/acked-by tag as there was some request to clarify the comments. Changes in v2: - Update comment in the code --- 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..3a54356 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 without 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 */ + /* Boot CPU already zero BSS so skip it on secondary CPUs. */ + 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 */ + 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) /*