From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195212; cv=none; d=zoho.com; s=zohoarc; b=fkHABobwqBHLvVRGXT25J4mSYdzi7YLM8NMTLTHFM3Pzwbhs4lapidGb8/jf4/GKObJ9YhrPzMpqhCbO3cscV8HUaqDrSW0/yUE+MG5Pm+hsknxexmOo71wGkOBbGdIg6BNWDaH3jOxSzXTrRXzGYl/t5D9qqOnhPkHbQ94GnJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195212; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=stNoIKzS5AEm4qABPG6qgnkWmktf4llpWv17UQy68xo=; b=KFT0jLYrjA7LkoWwpHRun2pAoPnazddN2hwIQdqMdDx7Y2CecLN/Gn8xDaROSW9avZ2KMb3EIXjhFLAA9PpVZdCGza5Whj1MxVMUPNNvED24qQHjLkngrGmu05QeulnjmYWwxhv7fHhjU1MGqTaYRu3+AR2NdVq1RSDwbTcmjZ0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195211990901.996090029303; Mon, 10 Jun 2019 12:33:31 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1n-0007cY-KF; Mon, 10 Jun 2019 19:32:23 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1m-0007cJ-Vv for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:23 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7763f4f6-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:21 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3C956346; Mon, 10 Jun 2019 12:32:21 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5468B3F73C; Mon, 10 Jun 2019 12:32:20 -0700 (PDT) X-Inumbo-ID: 7763f4f6-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:31:59 +0100 Message-Id: <20190610193215.23704-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 01/17] xen/arm64: head Mark the end of subroutines with ENDPROC 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" putn() and puts() are two subroutines. Add ENDPROC for the benefits of static analysis tools and the reader. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index ddd3a33108..c8bbdf05a6 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -646,6 +646,7 @@ puts: b puts 1: ret +ENDPROC(puts) =20 /* Print a 32-bit number in hex. Specific to the PL011 UART. * x0: Number to print. @@ -664,6 +665,7 @@ putn: subs x3, x3, #1 b.ne 1b ret +ENDPROC(putn) =20 hex: .ascii "0123456789abcdef" .align 2 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195214; cv=none; d=zoho.com; s=zohoarc; b=LXpZ+cE+SGreNrbjtrHjNwl1Ih8utsE0wnGtVoo9WORQYlSjBpAjeaASKo8BOZTqHg3fAK1Hfx+WC16t2HYValtNLR/+gjYSFs2queTJPdFyR7d+I1HxNDpW4KPuLFfy4X7BOj+6Mbs/GbG6sR+KMXi4aaQTuCUGZiEVnIibzc8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195214; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+GBwWnKF4fPfhll9nS/XOtNFk6tne1Lb1DuPUIdv5fo=; b=aFoZRg9thny5d5cENlg+MOwZxGdSyGO1bMEqYj268ETznZ3qc3ojiW9eP9WWvNHwgVNlkedNXbL5aUVK8nRDudsYZcAZ8ifU+AtH7gLfYbOI6P3QY+RAZCCKX5HkK03HWPZPBE9kL9w5WgTRfb1ZhP+MB9DeKiAYEJdhBucxy7U= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195214658389.67673353641146; Mon, 10 Jun 2019 12:33:34 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1n-0007ce-U4; Mon, 10 Jun 2019 19:32:23 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1n-0007cO-8a for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:23 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 780e1bbf-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:22 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5892BC0A; Mon, 10 Jun 2019 12:32:22 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 708313F73C; Mon, 10 Jun 2019 12:32:21 -0700 (PDT) X-Inumbo-ID: 780e1bbf-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:00 +0100 Message-Id: <20190610193215.23704-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 02/17] xen/arm64: head: Don't clobber x30/lr in the macro PRINT 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The current implementation of the macro PRINT will clobber x30/lr. This means the user should save lr if it cares about it. Follow-up patches will introduce more use of PRINT in place where lr should be preserved. Rather than requiring all the users to preserve lr, the macro PRINT is modified to save and restore it. While the comment state x3 will be clobbered, this is not the case. So PRINT will use x3 to preserve lr. Lastly, take the opportunity to move the comment on top of PRINT and use PRINT in init_uart. Both changes will be helpful in a follow-up patch. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index c8bbdf05a6..a5147c8d80 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -78,12 +78,17 @@ * x30 - lr */ =20 -/* Macro to print a string to the UART, if there is one. - * Clobbers x0-x3. */ #ifdef CONFIG_EARLY_PRINTK +/* + * Macro to print a string to the UART, if there is one. + * + * Clobbers x0 - x3 + */ #define PRINT(_s) \ + mov x3, lr ; \ adr x0, 98f ; \ bl puts ; \ + mov lr, x3 ; \ RODATA_STR(98, _s) #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) @@ -630,9 +635,8 @@ init_uart: #ifdef EARLY_PRINTK_INIT_UART early_uart_init x23, 0 #endif - adr x0, 1f - b puts -RODATA_STR(1, "- UART enabled -\r\n") + PRINT("- UART enabled -\r\n") + ret =20 /* Print early debug messages. * x0: Nul-terminated string to print. --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195226; cv=none; d=zoho.com; s=zohoarc; b=AwPOaF9ERJygoNWZ9pXSdhjbMJ6CoNq/bLhaRX6zkZyM/53yVLkvg41hEQsQCi4lJLKcxcs4ysQ0NluEho5CeLlG93hjzDlIGq1Hjtct5F5u4fDvE+tz7foZUx936AyVDZAYSb035DuBVpq9CFBWPx/rCQVNPEX1w/+Vpg8IoSA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195226; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Sv/6dSL98aVO1rByFdP3G6KIDgIf/H2L2u27iBAIPnc=; b=AyGp2T+NDAXZnwPU/LGwNZE9JphgFmgt/6wqH8dQXqY1KoY8jysxNEL7MRPIWea7kG4Xkzri0kPffDG4j/tM6mxCXdvA77wSKH+YAr85Z2ehptVZUU9kV3kHG0K20Wvy9uKW5mDouj3kG91PeFzzYRCcFmSQTZ3anY0+Aaa00ow= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195226869406.94543917896056; Mon, 10 Jun 2019 12:33:46 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1q-0007d1-I0; Mon, 10 Jun 2019 19:32:26 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1o-0007ck-Hi for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:24 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 78b1c5f8-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:23 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 746D3C15; Mon, 10 Jun 2019 12:32:23 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8C61F3F73C; Mon, 10 Jun 2019 12:32:22 -0700 (PDT) X-Inumbo-ID: 78b1c5f8-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:01 +0100 Message-Id: <20190610193215.23704-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 03/17] xen/arm64: head: Rework UART initialization on boot CPU 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Anything executed after the label common_start can be executed on all CPUs. However most of the instructions executed between the label common_start and init_uart are not executed on the boot CPU. The only instructions executed are to lookup the CPUID so it can be printed on the console (if earlyprintk is enabled). Printing the CPUID is not entirely useful to have for the boot CPU and requires a conditional branch to bypass unused instructions. Furthermore, the function init_uart is only called for boot CPU requiring another conditional branch. This makes the code a bit tricky to follow. The UART initialization is now moved before the label common_start. This now requires to have a slightly altered print for the boot CPU and set the early UART base address in each the two path (boot CPU and secondary CPUs). This has the nice effect to remove a couple of conditional branch in the code. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index a5147c8d80..fd432ee15d 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -265,6 +265,12 @@ real_start_efi: load_paddr x21, _sdtb #endif =20 + /* Initialize the UART if earlyprintk has been enabled. */ +#ifdef CONFIG_EARLY_PRINTK + bl init_uart +#endif + PRINT("- Boot CPU booting -\r\n") + mov x22, #0 /* x22 :=3D is_secondary_cpu */ =20 b common_start @@ -281,14 +287,11 @@ GLOBAL(init_secondary) /* Boot CPU already zero BSS so skip it on secondary CPUs. */ mov x26, #1 /* X26 :=3D skip_zero_bss */ =20 -common_start: mrs x0, mpidr_el1 ldr x13, =3D(~MPIDR_HWID_MASK) bic x24, x0, x13 /* Mask out flags to get CPU ID */ =20 - /* Non-boot CPUs wait here until __cpu_up is ready for them */ - cbz x22, 1f - + /* Wait here until __cpu_up is ready to handle the CPU */ load_paddr x0, smp_up_cpu dsb sy 2: ldr x1, [x0] @@ -300,14 +303,14 @@ common_start: =20 #ifdef CONFIG_EARLY_PRINTK ldr x23, =3DEARLY_UART_BASE_ADDRESS /* x23 :=3D UART base addres= s */ - cbnz x22, 1f - bl init_uart /* Boot CPU sets up the UART too */ -1: PRINT("- CPU ") + PRINT("- CPU ") mov x0, x24 bl putn PRINT(" booting -\r\n") #endif =20 +common_start: + PRINT("- Current EL ") mrs x4, CurrentEL mov x0, x4 @@ -628,10 +631,16 @@ ENTRY(switch_ttbr) ret =20 #ifdef CONFIG_EARLY_PRINTK -/* Bring up the UART. - * x23: Early UART base address - * Clobbers x0-x1 */ +/* + * Initialize the UART. Should only be called on the boot CPU. + * + * Ouput: + * x23: Early UART base physical address + * + * Clobbers x0 - x1 + */ init_uart: + ldr x23, =3DEARLY_UART_BASE_ADDRESS #ifdef EARLY_PRINTK_INIT_UART early_uart_init x23, 0 #endif --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195216; cv=none; d=zoho.com; s=zohoarc; b=iiM228lOWmflIpE15QbbP/QLeNlxqMI/geID+H5bmEbLCrEwNDY1WzzqvgtnBwXLoObHo/V2zzHknL0hEf8rzbIj3jQYyula8crP4gXzQFYw7FjOa1mWUG7SQSI5sxNxfIYUGgo4kZaMuBCOYdc+OmJmHLtJNj88k7uHk5ItO7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195216; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=tLCHm9MhVRJEvoR0LaePO/rqw31LIgLcj+hoyNXaTHE=; b=Ig51A39aXkbcHsvXODtdCfGWjk7DktJj0zy9KnZXj7CuLrzAJKbs3Kj0HNk2VX/eLbK2VBjIkGu2x/K9mJqDcP50E1rojrHitJ5b/5dMNBiM1qOBkuZ/y12MbF6Vbsw2vGSNxgoila8IhiLyrlzMbQ/s4NvUGYFFh/NVQt1ahKc= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195216326466.21446703652293; Mon, 10 Jun 2019 12:33:36 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1t-0007dp-7s; Mon, 10 Jun 2019 19:32:29 +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 1haQ1r-0007dM-KE for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:27 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 794fea56-8bb6-11e9-83b0-8b88c32ede0b; Mon, 10 Jun 2019 19:32:24 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9070E344; Mon, 10 Jun 2019 12:32:24 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A86193F73C; Mon, 10 Jun 2019 12:32:23 -0700 (PDT) X-Inumbo-ID: 794fea56-8bb6-11e9-83b0-8b88c32ede0b From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:02 +0100 Message-Id: <20190610193215.23704-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 04/17] xen/arm64: head: Don't "reserve" x24 for the CPUID 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" After the recent rework, the CPUID is only used at the very beginning of the secondary CPUs boot path. So there is no need to "reserve" x24 for he CPUID. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index fd432ee15d..84e26582c4 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -69,7 +69,7 @@ * x21 - DTB address (boot cpu only) * x22 - is_secondary_cpu * x23 - UART address - * x24 - cpuid + * x24 - * x25 - identity map in place * x26 - skip_zero_bss * x27 - --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195229; cv=none; d=zoho.com; s=zohoarc; b=SyBSLu6hMEEem2EV2yi++5iMt60YeIXqTAChMfxHpb7H5wqZUb3BwBser88vzzQRjGYs5VOjQYbpxw0uKbCqtRXSiTs80shy7enGF15waKvjvhWWSYdTB5a/5kNjEELKXpSkwx21xAuN9yxx5kgLFemf12J7t1c3pJ2ru7HE9Pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=N4oJNDunGDa/Td/RLdifXCu+8Y6Q5w+eLQjyw2EDgkk=; b=IB/f6PB5m11RK1hQlThZScwVTzPu0lIiIGBVI5y4EpGeKJKu/NcecJ/5Q7S9TWh+OVfx60Uluw6/RF7nTnGKcabIurJuyPuBh6+maN+V1pIv4euOrEtF6VFtsNcjfLTeHzaNemZrYuAd4f9X+PM02aQadwfbym1Po3u4QzUb8rE= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195228776324.89309418271785; Mon, 10 Jun 2019 12:33:48 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1r-0007dR-Ts; Mon, 10 Jun 2019 19:32:27 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1r-0007dH-AH for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:27 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 79f136ad-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:25 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ACA74346; Mon, 10 Jun 2019 12:32:25 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C49683F73C; Mon, 10 Jun 2019 12:32:24 -0700 (PDT) X-Inumbo-ID: 79f136ad-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:03 +0100 Message-Id: <20190610193215.23704-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 05/17] xen/arm64: head: Introduce print_reg 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, the user should save x30/lr if it cares about it. Follow-up patches will introduce more use of putn in place where lr should be preserved. Furthermore, any user of putn should also move the value to register x0 if it was stored in a different register. For convenience, a new macro is introduced to print a given register. The macro will take care for us to move the value to x0 and also preserve lr. Lastly the new macro is used to replace all the callsite of putn. This will simplify rework/review later on. Note that CurrentEL is now stored in x5 instead of x4 because the latter will be clobbered by the macro print_reg. Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 84e26582c4..9142b4a774 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -90,8 +90,25 @@ bl puts ; \ mov lr, x3 ; \ RODATA_STR(98, _s) + +/* + * Macro to print the value of register \xb + * + * Clobbers x0 - x4 + */ +.macro print_reg xb + mov x4, lr + mov x0, \xb + bl putn + mov lr, x4 +.endm + #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) + +.macro print_reg xb +.endm + #endif /* !CONFIG_EARLY_PRINTK */ =20 /* Load the physical address of a symbol into xb */ @@ -304,22 +321,20 @@ GLOBAL(init_secondary) #ifdef CONFIG_EARLY_PRINTK ldr x23, =3DEARLY_UART_BASE_ADDRESS /* x23 :=3D UART base addres= s */ PRINT("- CPU ") - mov x0, x24 - bl putn + print_reg x24 PRINT(" booting -\r\n") #endif =20 common_start: =20 PRINT("- Current EL ") - mrs x4, CurrentEL - mov x0, x4 - bl putn + mrs x5, CurrentEL + print_reg x5 PRINT(" -\r\n") =20 /* Are we in EL2 */ - cmp x4, #PSR_MODE_EL2t - ccmp x4, #PSR_MODE_EL2h, #0x4, ne + cmp x5, #PSR_MODE_EL2t + ccmp x5, #PSR_MODE_EL2h, #0x4, ne b.eq el2 /* Yes */ =20 /* OK, we're boned. */ --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195214; cv=none; d=zoho.com; s=zohoarc; b=chJJa7VyEezPgr1NQ7xqqx0mMd+6gKa2fxnU5LbgKokE+9KpsC4BvO57VFPDDxmYK5Cje+FLnqsTKvulVtxGtTOpQm8aBM/Zi5CPnqTzS06yhk0FR3gjN1mDKzJFHOu3KlKcbw38kInDZKNqzZLApajKJtgOQmrfJ1bITDzklX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195214; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=stI3LuhrLkBVwotN3m+5tAIqayaM8tyd96UBAHV5Fv0=; b=gOBO9PfKWHrtThgYKyppqPGlA+qKvBBeq1SFV19H80FwzS6Hu92MBe1Whjw1KowJZRprzzOqVBhcsWX3i5nxxnc9OaAMPS6YVMWA1mhwHlhfLxB+qxNf6uFtNq3NGpuRT01KKt9oENttrA7YZMnnQxIpAvpWcGVL4LqOFq9/R/I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156019521392052.40602252412987; Mon, 10 Jun 2019 12:33:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1u-0007et-Jd; Mon, 10 Jun 2019 19:32:30 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1s-0007dd-JN for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:28 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7aa408ec-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:26 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C921CC0A; Mon, 10 Jun 2019 12:32:26 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E0B713F73C; Mon, 10 Jun 2019 12:32:25 -0700 (PDT) X-Inumbo-ID: 7aa408ec-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:04 +0100 Message-Id: <20190610193215.23704-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 06/17] xen/arm64: head: Introduce distinct paths for the boot CPU and secondary CPUs 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The boot code is currently quite difficult to go through because of the lack of documentation and a number of indirection to avoid executing some path in either the boot CPU or secondary CPUs. In an attempt to make the boot code easier to follow, each parts of the boot are now in separate functions. Furthermore, the paths for the boot CPU and secondary CPUs are now distincted and for now will call each functions. Follow-ups will remove unecessary calls and do further improvement (such as adding documentation and reshuffling). Note that the switch from using the ID mapping to the runtime mapping is duplicated for each path. This is because in the future we will need to stay longer in the ID mapping for the boot CPU. Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 57 ++++++++++++++++++++++++++++++++++++++++---= ---- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 9142b4a774..ccd8a1b0a8 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -290,7 +290,19 @@ real_start_efi: =20 mov x22, #0 /* x22 :=3D is_secondary_cpu */ =20 - b common_start + bl check_cpu_mode + bl zero_bss + bl cpu_init + bl create_page_tables + bl enable_mmu + + /* We are still in the ID map. Jump to the runtime Virtual Address= . */ + ldr x0, =3Dprimary_switched + br x0 +primary_switched: + bl setup_fixmap + b launch +ENDPROC(real_start) =20 GLOBAL(init_secondary) msr DAIFSet, 0xf /* Disable all interrupts */ @@ -324,9 +336,21 @@ GLOBAL(init_secondary) print_reg x24 PRINT(" booting -\r\n") #endif - -common_start: - + bl check_cpu_mode + bl zero_bss + bl cpu_init + bl create_page_tables + bl enable_mmu + + /* We are still in the ID map. Jump to the runtime Virtual Address= . */ + ldr x0, =3Dsecondary_switched + br x0 +secondary_switched: + bl setup_fixmap + b launch +ENDPROC(init_secondary) + +check_cpu_mode: PRINT("- Current EL ") mrs x5, CurrentEL print_reg x5 @@ -343,7 +367,10 @@ common_start: b fail =20 el2: PRINT("- Xen starting at EL2 -\r\n") + ret +ENDPROC(check_cpu_mode) =20 +zero_bss: /* Zero BSS only when requested */ cbnz x26, skip_bss =20 @@ -356,6 +383,10 @@ el2: PRINT("- Xen starting at EL2 -\r\n") b.lo 1b =20 skip_bss: + ret +ENDPROC(zero_bss) + +cpu_init: PRINT("- Setting up control registers -\r\n") =20 /* Set up memory attribute type tables */ @@ -390,7 +421,10 @@ skip_bss: * are handled using the EL2 stack pointer, rather * than SP_EL0. */ msr spsel, #1 + ret +ENDPROC(cpu_init) =20 +create_page_tables: /* Rebuild the boot pagetable's first-level entries. The structure * is described in mm.c. * @@ -515,6 +549,10 @@ virtphys_clash: b fail =20 1: + ret +ENDPROC(create_page_tables) + +enable_mmu: PRINT("- Turning on paging -\r\n") =20 /* @@ -524,16 +562,16 @@ virtphys_clash: tlbi alle2 /* Flush hypervisor TLBs */ dsb nsh =20 - ldr x1, =3Dpaging /* Explicit vaddr, not RIP-relative= */ mrs x0, SCTLR_EL2 orr x0, x0, #SCTLR_Axx_ELx_M /* Enable MMU */ orr x0, x0, #SCTLR_Axx_ELx_C /* Enable D-cache */ dsb sy /* Flush PTE writes and finish reads = */ msr SCTLR_EL2, x0 /* now paging is enabled */ isb /* Now, flush the icache */ - br x1 /* Get a proper vaddr into PC */ -paging: + ret +ENDPROC(enable_mmu) =20 +setup_fixmap: /* Now we can install the fixmap and dtb mappings, since we * don't need the 1:1 map any more */ dsb sy @@ -575,7 +613,10 @@ paging: tlbi alle2 dsb sy /* Ensure completion of TLB flush */ isb + ret +ENDPROC(setup_fixmap) =20 +launch: PRINT("- Ready -\r\n") =20 /* The boot CPU should go straight into C now */ @@ -594,7 +635,6 @@ paging: dsb sy /* Ensure completion of TLB flush */ isb =20 -launch: ldr x0, =3Dinit_data add x0, x0, #INITINFO_stack /* Find the boot-time stack */ ldr x0, [x0] @@ -609,6 +649,7 @@ launch: b start_xen /* and disappear into the land of C */ 1: b start_secondary /* (to the appropriate entry point) */ +ENDPROC(launch) =20 /* Fail-stop */ fail: PRINT("- Boot failed -\r\n") --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195230; cv=none; d=zoho.com; s=zohoarc; b=jyauK//oxpWf3HZF/pWrFB3M4rklCuQCa1jn6pt6pYa/y740/rgOlirXAFjqV4t/B8OTidIDLDzys2AHiuVu5EdnW5cjihwA3i3mZ89Nj5h4os0N0Yv676ru1JZkCZoIcJVxOwBLhOLdX9+aDxvnW7EdPoZBfjTY+s5vYCi6lKQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195230; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/2efVw76EpIlAWOmz7Lpp+ufSJVO7tyorxPJ5n4UkVA=; b=BDbjw7juOVF/Wa95nm8oQUCC8E6NhYMqy9n0KnMcID5p1VN3R8xuykrcKq7yY0hKvlr+9naCv2qOaVDfKtA+TcyP6RtEWtTq3NOJwDn7v/WtvsH3UdjcxCtzNTE7q4jAbyBlu9vyizxoGUuJmuMKO45nFPYi/VBWwlOenaKIsyw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195230225747.6294569717884; Mon, 10 Jun 2019 12:33:50 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1u-0007fE-Vf; Mon, 10 Jun 2019 19:32:30 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1s-0007di-Ri for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:28 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7b48ac70-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:28 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E5F4A344; Mon, 10 Jun 2019 12:32:27 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0922F3F73C; Mon, 10 Jun 2019 12:32:26 -0700 (PDT) X-Inumbo-ID: 7b48ac70-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:05 +0100 Message-Id: <20190610193215.23704-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 07/17] xen/arm64: head: Rework and document check_cpu_mode() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" A branch in the success case can be avoided by inverting the branch condition. At the same time, remove a pointless comment as Xen can only run at EL2. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index ccd8a1b0a8..87fcd3be6c 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -350,6 +350,13 @@ secondary_switched: b launch ENDPROC(init_secondary) =20 +/* + * Check if the CPU has been booted in Hypervisor mode. + * This function will never return when the CPU is booted in another mode + * than Hypervisor mode. + * + * Clobbers x0 - x5 + */ check_cpu_mode: PRINT("- Current EL ") mrs x5, CurrentEL @@ -359,15 +366,13 @@ check_cpu_mode: /* Are we in EL2 */ cmp x5, #PSR_MODE_EL2t ccmp x5, #PSR_MODE_EL2h, #0x4, ne - b.eq el2 /* Yes */ - + b.ne 1f /* No */ + ret +1: /* OK, we're boned. */ PRINT("- Xen must be entered in NS EL2 mode -\r\n") PRINT("- Please update the bootloader -\r\n") b fail - -el2: PRINT("- Xen starting at EL2 -\r\n") - ret ENDPROC(check_cpu_mode) =20 zero_bss: --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195217; cv=none; d=zoho.com; s=zohoarc; b=AaSadi9pDZv/VDdsYF0xhrcS/ttrW+nssuyd0lCvDumy7iBJRNVxmj77/QLmfGwckY+eIvEICpOgUOMAsfFBBtJJB++kGSddRGDADJgux6zg7Mky/Sj8XFjcv0hyQbTqU94dhem6HgS4N1oe4bF2LGjoHrCBi6THJ+ixgASBmp4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195217; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=toLMwV51nwk3tyYHMbZHqJfezWKBnIhVGofydTZX5cU=; b=Q5dug8nPme4prp5H4LzgOhAhRZ2Ioj5fJt+fPLfhKZfJWMdR3HqkrLhvcfRKtnavdsaPF1Z43wWZsj+8tMrfWDuUUC8egyvxb+eexz18IlNtZQw+kOKqEqakrtd+XmvRjKmIPc2NczoSvJWC1uebAZwz1vA2ErZulbY3ZUoyOJk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195217426997.5882407296198; Mon, 10 Jun 2019 12:33:37 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1w-0007hY-WB; Mon, 10 Jun 2019 19:32: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 1haQ1v-0007fS-7t for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:31 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7bfa0d68-8bb6-11e9-a239-6f7b6f0f0c80; Mon, 10 Jun 2019 19:32:29 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0E115346; Mon, 10 Jun 2019 12:32:29 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 25EDD3F73C; Mon, 10 Jun 2019 12:32:28 -0700 (PDT) X-Inumbo-ID: 7bfa0d68-8bb6-11e9-a239-6f7b6f0f0c80 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:06 +0100 Message-Id: <20190610193215.23704-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 08/17] xen/arm64: head: Rework and document zero_bss() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On secondary CPUs, zero_bss() will be a NOP because BSS only need to be zeroed once at boot. So the call in the secondary CPUs path can be removed. It also means that x26 does not need to set and is now only used by the boot CPU. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 87fcd3be6c..6aa3148192 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -71,7 +71,7 @@ * x23 - UART address * x24 - * x25 - identity map in place - * x26 - skip_zero_bss + * x26 - skip_zero_bss (boot cpu only) * x27 - * x28 - * x29 - @@ -313,8 +313,6 @@ GLOBAL(init_secondary) sub x20, x19, x0 /* x20 :=3D phys-offset */ =20 mov x22, #1 /* x22 :=3D is_secondary_cpu */ - /* Boot CPU already zero BSS so skip it on secondary CPUs. */ - mov x26, #1 /* X26 :=3D skip_zero_bss */ =20 mrs x0, mpidr_el1 ldr x13, =3D(~MPIDR_HWID_MASK) @@ -337,7 +335,6 @@ GLOBAL(init_secondary) PRINT(" booting -\r\n") #endif bl check_cpu_mode - bl zero_bss bl cpu_init bl create_page_tables bl enable_mmu @@ -375,6 +372,14 @@ check_cpu_mode: b fail ENDPROC(check_cpu_mode) =20 +/* + * Zero BSS + * + * Inputs: + * x26: Do we need to zero BSS? + * + * Clobbers x0 - x3 + */ zero_bss: /* Zero BSS only when requested */ cbnz x26, skip_bss --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195229; cv=none; d=zoho.com; s=zohoarc; b=m0ovss/R+/8V7YadQVrbL4AhnojZ+F7vfIGnaElmq5NgxTzIpI5gAm6+dbvzRnjVpLVUlShN9YzNQPSORJ2RrzFhNLLVqmQklVBQTaBrt8XvvIJcgYFBe92oxFn4nAt6MG2mtbMjX5O/bxxVGmYhKfSTxKJeY3gi+IDXfo77/mI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=5MxHbm99ugLBZbK08cA+blZ8kYFB1QQxE/bTY2ge4TY=; b=LSbRthmB0fO71UH5FVC/Oy4e7ifivHVu1OWJi5wtvy7BfVGfgbNDkZ+Cpv7zukynsWpLshWwY1AQweYzGxfOt1KHXBWjdJ1hzlF8UbIgps0l6yiZZRlOhcLASo5YKGovWht17oyHknl59P8dfoMPMnhJuNOY4759jz+1/H8S31I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156019522944014.137639897701547; Mon, 10 Jun 2019 12:33:49 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1w-0007h4-Hc; Mon, 10 Jun 2019 19:32:32 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1u-0007ez-SM for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:30 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7ca62288-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:30 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A096C0A; Mon, 10 Jun 2019 12:32:30 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 420733F73C; Mon, 10 Jun 2019 12:32:29 -0700 (PDT) X-Inumbo-ID: 7ca62288-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:07 +0100 Message-Id: <20190610193215.23704-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 09/17] xen/arm64: head: Improve coding style and document cpu_init() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Adjust the coding style used in the comments within cpu_init(). Take the opportunity to alter the early print to match the function name. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 6aa3148192..ee0024173e 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -396,19 +396,26 @@ skip_bss: ret ENDPROC(zero_bss) =20 +/* + * Initialize the processor for turning the MMU on. + * + * Clobbers x0 - x4 + */ cpu_init: - PRINT("- Setting up control registers -\r\n") + PRINT("- Initialize CPU -\r\n") =20 /* Set up memory attribute type tables */ ldr x0, =3DMAIRVAL msr mair_el2, x0 =20 - /* Set up TCR_EL2: + /* + * Set up TCR_EL2: * PS -- Based on ID_AA64MMFR0_EL1.PARange * Top byte is used * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, - * 48-bit virtual address space goes through this table. */ + * 48-bit virtual address space goes through this table. + */ ldr x0, =3D(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TC= R_T0SZ(64-48)) /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (= PS) */ mrs x1, ID_AA64MMFR0_EL1 @@ -427,9 +434,11 @@ cpu_init: ldr x0, =3D(HSCTLR_BASE) msr SCTLR_EL2, x0 =20 - /* Ensure that any exceptions encountered at EL2 + /* + * Ensure that any exceptions encountered at EL2 * are handled using the EL2 stack pointer, rather - * than SP_EL0. */ + * than SP_EL0. + */ msr spsel, #1 ret ENDPROC(cpu_init) --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195213; cv=none; d=zoho.com; s=zohoarc; b=gCdiGJtuff3v0d2xLUWf/xeYas6R8TFtaT53i5jTC7uVVZUeosmRwfss+qdd2DJUqcHPBTIVdlpRy8rs8O8x03zx1NUhVoWH0qmSW21MDK5cioH2M0JL+DpjR0zFYEicrSTyd4PBdJd/8suF6VHFydQyotf2m8Rg2OTiBGgdi+g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195213; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RiqPuHz9/Yp7iuQooQJztIz9b9BdELP6mCLZCA1UYOI=; b=YdDr+/pmePMM6Jsp/ya1mXldOOeUgwQ7mb6e/ugljewr97RtshjTXOaC4O2FwIC0hTHqHlWkW0eaKzFCP+llUPdwER/9n0jUUnHGjCPI4aWHR+KzK/jnI04gj+7bSknFw23UbxZK51yCSrbOO2nXWcXHkFLyKJiv2s/btEZlsN4= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 156019521344952.62896460088916; Mon, 10 Jun 2019 12:33:33 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1x-0007i8-Eg; Mon, 10 Jun 2019 19:32:33 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1w-0007gZ-44 for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:32 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7d59b95d-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:31 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 46523344; Mon, 10 Jun 2019 12:32:31 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5E2CC3F73C; Mon, 10 Jun 2019 12:32:30 -0700 (PDT) X-Inumbo-ID: 7d59b95d-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:08 +0100 Message-Id: <20190610193215.23704-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 10/17] xen/arm64: head: Improve coding style and document create_pages_tables() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Adjust the coding style used in the comments within create_pages_tables() Lastly, document the behavior and the main registers usage within the function. Note that x25 is now only used within the function, so it does not need to be part of the common register. Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index ee0024173e..7b92c1c8eb 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -70,7 +70,7 @@ * x22 - is_secondary_cpu * x23 - UART address * x24 - - * x25 - identity map in place + * x25 - * x26 - skip_zero_bss (boot cpu only) * x27 - * x28 - @@ -443,16 +443,27 @@ cpu_init: ret ENDPROC(cpu_init) =20 +/* + * Rebuild the boot pagetable's first-level entries. The structure + * is described in mm.c. + * + * After the CPU enables paging it will add the fixmap mapping + * to these page tables, however this may clash with the 1:1 + * mapping. So each CPU must rebuild the page tables here with + * the 1:1 in place. + * + * Inputs: + * x19: paddr(start) + * x20: phys offset + * + * Clobbers x0 - x4, x25 + * + * Register usage within this function: + * x25: Identity map in place + */ create_page_tables: - /* Rebuild the boot pagetable's first-level entries. The structure - * is described in mm.c. - * - * After the CPU enables paging it will add the fixmap mapping - * to these page tables, however this may clash with the 1:1 - * mapping. So each CPU must rebuild the page tables here with - * the 1:1 in place. */ - - /* If Xen is loaded at exactly XEN_VIRT_START then we don't + /* + * If Xen is loaded at exactly XEN_VIRT_START then we don't * need an additional 1:1 mapping, the virtual mapping will * suffice. */ @@ -476,7 +487,8 @@ create_page_tables: cbz x1, 1f /* It's in slot 0, map in boot_first * or boot_second later on */ =20 - /* Level zero does not support superpage mappings, so we have + /* + * Level zero does not support superpage mappings, so we have * to use an extra first level page in which we create a 1GB mappi= ng. */ load_paddr x2, boot_first_id --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195229; cv=none; d=zoho.com; s=zohoarc; b=k+6GyGsSw3FYqguNu82WHV+AWAKBAB1ssQ4JS3vS37CpKqnf1Bi5XmaA8mZgIhwRhDzPe/Oa56ozgmlIO/C1irGNsPPr639W0fOv2cKctfdBRtTPltDpH03+r4fq4G6GBUy2BBk/KWGLH/MupRrl+nem5q+8zByAAiqGiSKKT5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=gPZaE2P7XLaWHYaYxb+lbT4GWbyyaJ6XmLNaH0tlIIg=; b=hUcteR0ymeVV1d6v7GsfHfFc8Nl+m6mVxjU4zse6Tn0irLxO31jU0fBF4xEFPiTynAxeJ1AfoKxKUoDs4UGWwk4LGikKw93JUjPtN13/xa1S1Dxm7dtXSr4ri9HLSyO+EAQus0m0qLi0yv6xgiZJXEFKE1NQ0OsA9a+K7glDTKI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195229297937.9864305081559; Mon, 10 Jun 2019 12:33:49 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1y-0007jV-SC; Mon, 10 Jun 2019 19:32:34 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ1x-0007hz-Cx for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:33 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7df36253-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:32 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6381C346; Mon, 10 Jun 2019 12:32:32 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A5833F73C; Mon, 10 Jun 2019 12:32:31 -0700 (PDT) X-Inumbo-ID: 7df36253-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:09 +0100 Message-Id: <20190610193215.23704-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 11/17] xen/arm64: head: Document enable_mmu() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Document the behavior and the main registers usage within enable_mmu(). Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 7b92c1c8eb..d673f7c0d8 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -583,6 +583,13 @@ virtphys_clash: ret ENDPROC(create_page_tables) =20 +/* + * Turn on the Data Cache and the MMU. The function will return on the ID + * mapping. In other word, the caller is responsible to switch to the runt= ime + * mapping. + * + * Clobbers x0 - x1 + */ enable_mmu: PRINT("- Turning on paging -\r\n") =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195230; cv=none; d=zoho.com; s=zohoarc; b=e9tjf2F6WPZR4sAaynnkLeBKELOf+fKqK0ZQtWCxW+bm6AOT/zd/JuwSFgqRtqqAxc7LmCoV9Ye0z2oZq+d5PD7Te487Sl3eRurvNFaTnYtRoolWhEnu56WsRqMHJEzb/oQWNYk01YHI5az5nAOapEXNpUqmFRlEwgy0huBqNT0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195230; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=BaS6XLcyEagxyjWEGBHxkSxRIrJcINIU0pkHSWPDm8o=; b=goKXal5PeotWzVsW8LbarpuxZsHcR/JPzf03f4MobvW0k3Ee+IudXYEJCzE8tiPj4czaTUQ+4R1eFRiNLagt7p2gZM1lDJn7QKAJpKXl/AX6G1phsJtHeAmbaV2xxWPekbpFP1hBsHgMNtugiQTV6LtxJjm4LaiemhBJp4FarlU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195230660734.3066351188825; Mon, 10 Jun 2019 12:33:50 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ20-0007kt-BS; Mon, 10 Jun 2019 19:32: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 1haQ1z-0007kH-Gp for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:35 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7ea70a16-8bb6-11e9-a861-33f576285945; Mon, 10 Jun 2019 19:32:33 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7E7C2C0A; Mon, 10 Jun 2019 12:32:33 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 965C33F73C; Mon, 10 Jun 2019 12:32:32 -0700 (PDT) X-Inumbo-ID: 7ea70a16-8bb6-11e9-a861-33f576285945 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:10 +0100 Message-Id: <20190610193215.23704-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 12/17] xen/arm64: head: Move assembly switch to the runtime PT in secondary CPUs path 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The assembly switch to the runtime PT is only necessary for the secondary CPUs. So move the code in the secondary CPUs path. While this is definitely not compliant with the Arm Arm as we are switching between two differents set of page-tables without turning off the MMU. Turning off the MMU is impossible here as the ID map may clash with other mappings in the runtime page-tables. This will require more rework to avoid the problem. So for now add a TODO in the code. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index d673f7c0d8..6be4af7579 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -344,6 +344,23 @@ GLOBAL(init_secondary) br x0 secondary_switched: bl setup_fixmap + + /* + * Non-boot CPUs need to move on to the proper pagetables, which w= ere + * setup in init_secondary_pagetables. + * + * XXX: This is not compliant with the Arm Arm. + */ + ldr x4, =3Dinit_ttbr /* VA of TTBR0_EL2 stashed by CPU 0= */ + ldr x4, [x4] /* Actual value */ + dsb sy + msr TTBR0_EL2, x4 + dsb sy + isb + tlbi alle2 + dsb sy /* Ensure completion of TLB flush */ + isb + b launch ENDPROC(init_secondary) =20 @@ -657,22 +674,6 @@ ENDPROC(setup_fixmap) launch: PRINT("- Ready -\r\n") =20 - /* The boot CPU should go straight into C now */ - cbz x22, launch - - /* Non-boot CPUs need to move on to the proper pagetables, which w= ere - * setup in init_secondary_pagetables. */ - - ldr x4, =3Dinit_ttbr /* VA of TTBR0_EL2 stashed by CPU 0= */ - ldr x4, [x4] /* Actual value */ - dsb sy - msr TTBR0_EL2, x4 - dsb sy - isb - tlbi alle2 - dsb sy /* Ensure completion of TLB flush */ - isb - ldr x0, =3Dinit_data add x0, x0, #INITINFO_stack /* Find the boot-time stack */ ldr x0, [x0] --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195195; cv=none; d=zoho.com; s=zohoarc; b=AvvUHFuGtdgFTnIxRkXZznqfUFArN3hjTTRkt4rPn/pPGN2VTiyGS3ThAy0hUzdvK1xz96PgIGzeav2YZi/g5sOMrEv6xMysEcLgHy6F9PCn3W7kBR1cmUjNuCSu81SAxrUweCe+9wbPsLuOBd6yL7L7NxQRaBUpe6KPM9K1XoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195195; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=/TBBTbv2enzASeFljd2cv9hvy15vTVhfljlopMp0Jh0=; b=YWUMAufuQxA2oew0L7Hvo51nubX5PZ3TDSpnJ70ErtiUxU4xPwvr5M6p7m3sC+g4vBsnD4OrC3B/Dn7HYmYdIl6PWWf8V9/3tvgxSWrA64D7duEg2XrLa2c/2iLmvgnxoy+2jaqOxvdKA6PvRpytLC5g3H9ZM6ABb11enNBJOHs= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195195237393.881996487508; Mon, 10 Jun 2019 12:33:15 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ23-0007pG-MO; Mon, 10 Jun 2019 19:32:39 +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 1haQ21-0007mv-Op for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:37 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 7f51d9fa-8bb6-11e9-99cd-e7629283a8cb; Mon, 10 Jun 2019 19:32:34 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9AF41344; Mon, 10 Jun 2019 12:32:34 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2AED3F73C; Mon, 10 Jun 2019 12:32:33 -0700 (PDT) X-Inumbo-ID: 7f51d9fa-8bb6-11e9-99cd-e7629283a8cb From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:11 +0100 Message-Id: <20190610193215.23704-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 13/17] xen/arm64: head: Don't setup the fixmap on secondary CPUs 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" setup_fixmap() will setup the fixmap in the boot page tables in order to use earlyprintk and also update the register x23 holding the address to the UART. However, secondary CPUs are switching to the runtime page tables before using the earlyprintk again. So settting up the fixmap in the boot pages tables is pointless. This means most of setup_fixmap() is not necessary for the secondary CPUs. The update of UART address is now moved out of setup_fixmap() and duplicated in the CPU boot and secondary CPUs boot. Additionally, the call to setup_fixmap() is removed from secondary CPUs boot. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 6be4af7579..192af3e8a2 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -301,6 +301,10 @@ real_start_efi: br x0 primary_switched: bl setup_fixmap +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + ldr x23, =3DEARLY_UART_VIRTUAL_ADDRESS +#endif b launch ENDPROC(real_start) =20 @@ -343,8 +347,6 @@ GLOBAL(init_secondary) ldr x0, =3Dsecondary_switched br x0 secondary_switched: - bl setup_fixmap - /* * Non-boot CPUs need to move on to the proper pagetables, which w= ere * setup in init_secondary_pagetables. @@ -361,6 +363,10 @@ secondary_switched: dsb sy /* Ensure completion of TLB flush */ isb =20 +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + ldr x23, =3DEARLY_UART_VIRTUAL_ADDRESS +#endif b launch ENDPROC(init_secondary) =20 @@ -631,10 +637,6 @@ setup_fixmap: * don't need the 1:1 map any more */ dsb sy #if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ - /* Non-boot CPUs don't need to rebuild the fixmap itself, just - * the mapping from boot_second to xen_fixmap */ - cbnz x22, 1f - /* Add UART to the fixmap table */ ldr x1, =3Dxen_fixmap /* x1 :=3D vaddr (xen_fixmap) */ lsr x2, x23, #THIRD_SHIFT @@ -642,7 +644,6 @@ setup_fixmap: mov x3, #PT_DEV_L3 orr x2, x2, x3 /* x2 :=3D 4K dev map including UART = */ str x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap'= s slot */ -1: =20 /* Map fixmap into boot_second */ ldr x4, =3Dboot_second /* x4 :=3D vaddr (boot_second) */ @@ -652,9 +653,6 @@ setup_fixmap: ldr x1, =3DFIXMAP_ADDR(0) lsr x1, x1, #(SECOND_SHIFT - 3) /* x1 :=3D Slot for FIXMAP(0) = */ str x2, [x4, x1] /* Map it in the fixmap's slot */ - - /* Use a virtual address to access the UART. */ - ldr x23, =3DEARLY_UART_VIRTUAL_ADDRESS #endif =20 /* --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195229; cv=none; d=zoho.com; s=zohoarc; b=RvFROwdFCHnEen8TKM/3wva/+V0kw7p3MfajziH47SQWjkDXGiHZwZfmr5kY0LvCy7D4ma5yDA0kvcjyRWnAE+7+9dngpSrIaBbYy9II1qK54Y/UKhmi6R5eqwwbJ5kW2lzUH0mYTX1KTPJ6xLKQPjymo25EgAYAgLcqkB+lgOk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195229; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=3vu+CqL4SmecEVjbJAZagk9I7gFKwOhmNrdptafPl0I=; b=Zw/vsDsHVMV459HhLPKq2R1tuxoxR9dJt5Xk/Jro5n2prXqJUeoE+iujEz1JQ8UcuIgMAJlULxwXdjGRy1Ynfk+hIImeHdnp3+5KwE3ctSk2lAG2VeNvgn2I/xq8AEQQZUvvUCF1twcw0siLqIM6eO0AFxpir/3mGa25JycHj2I= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195229141932.4318370586012; Mon, 10 Jun 2019 12:33:49 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ22-0007nm-Mn; Mon, 10 Jun 2019 19:32:38 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ21-0007m8-8C for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:37 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 7feffa3f-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:35 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6D97346; Mon, 10 Jun 2019 12:32:35 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CED6C3F73C; Mon, 10 Jun 2019 12:32:34 -0700 (PDT) X-Inumbo-ID: 7feffa3f-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:12 +0100 Message-Id: <20190610193215.23704-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 14/17] xen/arm64: head: Remove ID map as soon as it is not used 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" The ID map may clash with other parts of the Xen virtual memory layout. At the moment, Xen is handling the clash by only creating a mapping to the runtime virtual address before enabling the MMU. The rest of the mappings (such as the fixmap) will be mapped after the MMU is enabled. However, the code doing the mapping is not safe as it replace mapping without using the Break-Before-Make sequence. As the ID map can be anywhere in the memory, it is easier to remove all the entries added as soon as the ID map is not used rather than adding the Break-Before-Make sequence everywhere. It is difficult to track where exactly the ID map was created without a full rework of create_page_tables(). Instead, introduce a new function remove_id_map() will look where is the top-level entry for the ID map and remove it. The new function is only called for the boot CPU. Secondary CPUs will switch directly to the runtime page-tables so there are no need to remove the ID mapping. Note that this still doesn't make the Secondary CPUs path safe but it is not making it worst. --- Note that the comment refers to the patch "xen/arm: tlbflush: Rework TLB helpers" under review (see [1]). Furthermore, it is very likely we will need to re-introduce the ID map to cater secondary CPUs boot and suspend/resume. For now, the attempt is to make boot CPU path fully Arm Arm compliant. [1] https://lists.xenproject.org/archives/html/xen-devel/2019-05/msg01134.h= tml --- xen/arch/arm/arm64/head.S | 86 ++++++++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 71 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 192af3e8a2..96e85f8834 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -300,6 +300,13 @@ real_start_efi: ldr x0, =3Dprimary_switched br x0 primary_switched: + /* + * The ID map may clash with other parts of the Xen virtual memory + * layout. As it is not used anymore, remove it completely to + * avoid having to worry about replacing existing mapping + * afterwards. + */ + bl remove_id_map bl setup_fixmap #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ @@ -632,10 +639,68 @@ enable_mmu: ret ENDPROC(enable_mmu) =20 +/* + * Remove the ID map for the page-tables. It is not easy to keep track + * where the ID map was mapped, so we will look for the top-level entry + * exclusive to the ID Map and remove it. + * + * Inputs: + * x19: paddr(start) + * + * Clobbers x0 - x1 + */ +remove_id_map: + /* + * Find the zeroeth slot used. Remove the entry from zeroeth + * table if the slot is not 0. For slot 0, the ID map was either + * done in first or second table. + */ + lsr x1, x19, #ZEROETH_SHIFT /* x1 :=3D zeroeth slot */ + cbz x1, 1f + /* It is not in slot 0, remove the entry */ + ldr x0, =3Dboot_pgtable /* x0 :=3D root table */ + str xzr, [x0, x1, lsl #3] + b id_map_removed + +1: + /* + * Find the first slot used. Remove the entry for the first + * table if the slot is not 0. For slot 0, the ID map was done + * in the second table. + */ + lsr x1, x19, #FIRST_SHIFT + and x1, x1, #LPAE_ENTRY_MASK /* x1 :=3D first slot */ + cbz x1, 1f + /* It is not in slot 0, remove the entry */ + ldr x0, =3Dboot_first /* x0 :=3D first table */ + str xzr, [x0, x1, lsl #3] + b id_map_removed + +1: + /* + * Find the second slot used. Remove the entry for the first + * table if the slot is not 1 (runtime Xen mapping is 2M - 4M). + * For slot 1, it means the ID map was not created. + */ + lsr x1, x19, #SECOND_SHIFT + and x1, x1, #LPAE_ENTRY_MASK /* x1 :=3D first slot */ + cmp x1, #1 + beq id_map_removed + /* It is not in slot 1, remove the entry */ + ldr x0, =3Dboot_second /* x0 :=3D second table */ + str xzr, [x0, x1, lsl #3] + +id_map_removed: + /* See asm-arm/arm64/flushtlb.h for the explanation of the sequenc= e. */ + dsb nshst + tlbi alle2 + dsb nsh + isb + + ret +ENDPROC(remove_id_map) + setup_fixmap: - /* Now we can install the fixmap and dtb mappings, since we - * don't need the 1:1 map any more */ - dsb sy #if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ /* Add UART to the fixmap table */ ldr x1, =3Dxen_fixmap /* x1 :=3D vaddr (xen_fixmap) */ @@ -653,19 +718,10 @@ setup_fixmap: ldr x1, =3DFIXMAP_ADDR(0) lsr x1, x1, #(SECOND_SHIFT - 3) /* x1 :=3D Slot for FIXMAP(0) = */ str x2, [x4, x1] /* Map it in the fixmap's slot */ -#endif =20 - /* - * Flush the TLB in case the 1:1 mapping happens to clash with - * the virtual addresses used by the fixmap or DTB. - */ - dsb sy /* Ensure any page table updates made= above - * have occurred. */ - - isb - tlbi alle2 - dsb sy /* Ensure completion of TLB flush */ - isb + /* Ensure any page table updates made above have occurred */ + dsb nshst +#endif ret ENDPROC(setup_fixmap) =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195220; cv=none; d=zoho.com; s=zohoarc; b=kACAvzVKnw6nsvxShAn58qkcqhs9dgFIZtjvBolEOmCK+kP/JToHvyV6V6iAeCkG6rScSSd6iAcfBz20fGiFYeAQJR3rAyWhY3GlfJyNae1Cq8bfa68qdWTp72Q0I+4UHJ8nk+5QCi5HZZTcVjB7R6Z3QnF4aqdqTjyUc+gwu+E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195220; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=7ECuch8Odd3W4FaWwUogDq7dtZ0Ec/IG1hrBaMOZg/Y=; b=AlcnqOGxO4L1j2DqS2laHKN52IlP1w2K1hkqB36ZuqcNk8FjM0Yq0jHtc6ZlnsjL6HPthvdxscW5GKZ8e4gjmrFgZGdVFBEvHCOHZn1eeUmqH4lV4NYRO1VDF7/UC4lNT/m5tG4kji04xdimwvzJBVIyUQux0HS8isQj9rSvw3E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195220334294.7126175044175; Mon, 10 Jun 2019 12:33:40 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ23-0007oP-50; Mon, 10 Jun 2019 19:32:39 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ21-0007mR-FR for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:37 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 8096a8d5-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:36 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D316AC0A; Mon, 10 Jun 2019 12:32:36 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB3913F73C; Mon, 10 Jun 2019 12:32:35 -0700 (PDT) X-Inumbo-ID: 8096a8d5-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:13 +0100 Message-Id: <20190610193215.23704-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 15/17] xen/arm64: head: Rework and document setup_fixmap() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment, the fixmap table is only hooked when earlyprintk is used. This is fine today because in C land, the fixmap is not used by anyone until the the boot CPU is switching to the runtime page-tables. In the future, the boot CPU will not switch between page-tables to avoid TLB conflict. This means the fixmap table will need to be hooked before any use. For simplicity, setup_fixmap() will now do that job. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 96e85f8834..4f7fa6769f 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -700,8 +700,17 @@ id_map_removed: ret ENDPROC(remove_id_map) =20 +/* + * Map the UART in the fixmap (when earlyprintk is used) and hook the + * fixmap table in the page tables. + * + * The fixmap cannot be mapped in create_page_tables because it may + * clash with the ID map. + * + * Clobbers x0 - x1 + */ setup_fixmap: -#if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ +#ifdef CONFIG_EARLY_PRINTK /* Add UART to the fixmap table */ ldr x1, =3Dxen_fixmap /* x1 :=3D vaddr (xen_fixmap) */ lsr x2, x23, #THIRD_SHIFT @@ -709,6 +718,7 @@ setup_fixmap: mov x3, #PT_DEV_L3 orr x2, x2, x3 /* x2 :=3D 4K dev map including UART = */ str x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap'= s slot */ +#endif =20 /* Map fixmap into boot_second */ ldr x4, =3Dboot_second /* x4 :=3D vaddr (boot_second) */ @@ -721,7 +731,6 @@ setup_fixmap: =20 /* Ensure any page table updates made above have occurred */ dsb nshst -#endif ret ENDPROC(setup_fixmap) =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195195; cv=none; d=zoho.com; s=zohoarc; b=h4yYbxEbDdVKRf4KvzCyBQ5zeHEv/dsdxoj/nWYhgtc6npVBWj4bPKhYOuxdpmFBdmO2p1qte3jp2iLziBAMyxlqZJOyXMekwrTpnaCnTcQVti08Cptnt63S/2hOdKzhH9VTKK0+QP0OcakyAsEFqC9PfFve1SXpGrmZbSYHvJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195195; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=dVg36GpuHS3j6xpC6nndZXPHBXCyiCJjMVzEC316tog=; b=RpVRmByZdJ9kQDggvWSkKaUuI5gHSetPop31+ou5LLcK5/fgnuFdONMC4CqsmBnURSDS4qnH4DAtW1syuCFgDfT4dI722sidf2y3pmQ0y8TnaoaCDw1Wr9ten7K++yFtBm8rQ7hFDWukK1aDm+MQsns0xiaHo9ux4xlOolxXeEI= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195195175481.7964539041325; Mon, 10 Jun 2019 12:33:15 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ24-0007rM-Pu; Mon, 10 Jun 2019 19:32:40 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ22-0007nw-Sw for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:38 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 815a49c3-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:38 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EF725344; Mon, 10 Jun 2019 12:32:37 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 131E73F73C; Mon, 10 Jun 2019 12:32:36 -0700 (PDT) X-Inumbo-ID: 815a49c3-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:14 +0100 Message-Id: <20190610193215.23704-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 16/17] xen/arm64: head: Rework and document launch() 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Boot CPU and secondary CPUs will use different entry point to C code. At the moment, the decision on which entry to use is taken within launch(). In order to avoid a branch for the decision and make the code clearer, launch() is reworked to take in parameters the entry point and its arguments. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall --- xen/arch/arm/arm64/head.S | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 4f7fa6769f..130ab66d8e 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -312,6 +312,11 @@ primary_switched: /* Use a virtual address to access the UART. */ ldr x23, =3DEARLY_UART_VIRTUAL_ADDRESS #endif + PRINT("- Ready -\r\n") + /* Setup the arguments for start_xen and jump to C world */ + mov x0, x20 /* x0 :=3D phys_offset */ + mov x1, x21 /* x1 :=3D paddr(FDT) */ + ldr x2, =3Dstart_xen b launch ENDPROC(real_start) =20 @@ -374,6 +379,9 @@ secondary_switched: /* Use a virtual address to access the UART. */ ldr x23, =3DEARLY_UART_VIRTUAL_ADDRESS #endif + PRINT("- Ready -\r\n") + /* Jump to C world */ + ldr x2, =3Dstart_secondary b launch ENDPROC(init_secondary) =20 @@ -734,23 +742,24 @@ setup_fixmap: ret ENDPROC(setup_fixmap) =20 +/* + * Setup the initial stack and jump to the C world + * + * Inputs: + * x0 : Argument 0 of the C function to call + * x1 : Argument 1 of the C function to call + * x2 : C entry point + */ launch: - PRINT("- Ready -\r\n") - - ldr x0, =3Dinit_data - add x0, x0, #INITINFO_stack /* Find the boot-time stack */ - ldr x0, [x0] - add x0, x0, #STACK_SIZE /* (which grows down from the top). */ - sub x0, x0, #CPUINFO_sizeof /* Make room for CPU save record */ - mov sp, x0 - - cbnz x22, 1f - - mov x0, x20 /* Marshal args: - phys_offset */ - mov x1, x21 /* - FDT */ - b start_xen /* and disappear into the land of C */ -1: - b start_secondary /* (to the appropriate entry point) */ + ldr x4, =3Dinit_data + add x4, x4, #INITINFO_stack /* Find the boot-time stack */ + ldr x4, [x4] + add x4, x4, #STACK_SIZE /* (which grows down from the top). */ + sub x4, x4, #CPUINFO_sizeof /* Make room for CPU save record */ + mov sp, x4 + + /* Jump to C world */ + br x2 ENDPROC(launch) =20 /* Fail-stop */ --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Mon Feb 9 09:05:45 2026 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1560195207; cv=none; d=zoho.com; s=zohoarc; b=VWXTb7a+eodI1kp+ihOfKDJojOV3yosuUFUhd2Vh/6F4upN0npvaGEX+fsu7WWzEpPihDqBO6FPNo651MFUn6haG5XEnb6hyZ53VTR9QyrEDXzC535ndjxTyx7pff3Me6pbg0W0CSCw9s9h3Zxdyj/OX1zbuMiZkJw+r/8zjYb0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560195207; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=+W48fn6iy/shOAF5ygCUvnTMxk8SS7FByIl6XjhWOmE=; b=N+TC1Uxx6jeodzs4uCg55CtcfK4P1lE7yY08e6ORPfVEEI9Y5ys1H/oVOONgPhsuOy/hkKKBSSB/yS5Jx2c97LrCpE0sU6IBtMO4pOzN/2ZVZZguutw6TSBDYAoUqCXIN7yzKnPPZe1L2tBauzkeQA+vVBvpAU5/+7gHiLVuONU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1560195206980902.1453271300566; Mon, 10 Jun 2019 12:33:26 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ26-0007tl-9L; Mon, 10 Jun 2019 19:32:42 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haQ24-0007q8-5Z for xen-devel@lists.xenproject.org; Mon, 10 Jun 2019 19:32:40 +0000 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 81f53be7-8bb6-11e9-8980-bc764e045a96; Mon, 10 Jun 2019 19:32:39 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1740C346; Mon, 10 Jun 2019 12:32:39 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2F32B3F73C; Mon, 10 Jun 2019 12:32:38 -0700 (PDT) X-Inumbo-ID: 81f53be7-8bb6-11e9-8980-bc764e045a96 From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 10 Jun 2019 20:32:15 +0100 Message-Id: <20190610193215.23704-18-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190610193215.23704-1-julien.grall@arm.com> References: <20190610193215.23704-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 17/17] xen/arm64: Zero BSS after the MMU and D-cache is turned on 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: andre.przywara@arm.com, Julien Grall , Stefano Stabellini , andrii_anisov@epam.com, Oleksandr_Tyshchenko@epam.com MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the moment BSS is zeroed before the MMU and D-Cache is turned on. In other words, the cache will be bypassed when zeroing the BSS section. Per the Image protocol [1], the state of the cache for BSS region is not known because it is not part of the "loaded kernel image". This means that the cache will need to be invalidated twice for the BSS region: 1) Before zeroing to remove any dirty cache line. Otherwise they may get evicted while zeroing and therefore overriding the value. 2) After zeroing to remove any cache line that may have been speculated. Otherwise when turning on MMU and D-Cache, the CPU may see old values. However, the only reason to have the BSS zeroed early is because the boot page tables are part of BSS. To avoid the two cache invalidations, it is possible to move the page tables in the section .data.page_aligned. A new macro DEFINE_BOOT_PAGE_TABLE is introduced to create and mark page-tables used before BSS is zeroed. This includes all boot_* but also xen_fixmap as zero_bss() will print a message when earlyprintk is enabled. [1] linux/Documentation/arm64/booting.txt Acked-by: Stefano Stabellini --- Note that the arm32 support is not there yet. This will need to be addressed here or separately depending on when the Arm32 boot rework is sent. --- xen/arch/arm/arm64/head.S | 6 +++--- xen/arch/arm/mm.c | 23 +++++++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 130ab66d8e..6c3edbbc81 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -291,7 +291,6 @@ real_start_efi: mov x22, #0 /* x22 :=3D is_secondary_cpu */ =20 bl check_cpu_mode - bl zero_bss bl cpu_init bl create_page_tables bl enable_mmu @@ -312,6 +311,7 @@ primary_switched: /* Use a virtual address to access the UART. */ ldr x23, =3DEARLY_UART_VIRTUAL_ADDRESS #endif + bl zero_bss PRINT("- Ready -\r\n") /* Setup the arguments for start_xen and jump to C world */ mov x0, x20 /* x0 :=3D phys_offset */ @@ -423,8 +423,8 @@ zero_bss: cbnz x26, skip_bss =20 PRINT("- Zero BSS -\r\n") - load_paddr x0, __bss_start /* Load paddr of start & end of bss = */ - load_paddr x1, __bss_end + ldr x0, =3D__bss_start /* x0 :=3D vaddr(__bss_start) */ + ldr x1, =3D__bss_end /* x1 :=3D vaddr(__bss_start) */ =20 1: str xzr, [x0], #8 cmp x0, x1 diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 6a549e9283..0b2d07a258 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -48,6 +48,17 @@ #undef mfn_to_virt #define mfn_to_virt(mfn) __mfn_to_virt(mfn_x(mfn)) =20 +/* + * Macros to define page-tables: + * - DEFINE_BOOT_PAGE_TABLE is used to define page-table that are used + * in assembly code before BSS is zeroed. + * - DEFINE_PAGE_TABLE{,S} are used to define one or multiple + * page-tables to be used after BSS is zeroed (typically they are only us= ed + * in C). + */ +#define DEFINE_BOOT_PAGE_TABLE(name) = \ +lpae_t __aligned(PAGE_SIZE) __section(".data.page_aligned") name[LPAE_ENTR= IES] + #define DEFINE_PAGE_TABLES(name, nr) \ lpae_t __aligned(PAGE_SIZE) name[LPAE_ENTRIES * (nr)] =20 @@ -76,13 +87,13 @@ lpae_t __aligned(PAGE_SIZE) name[LPAE_ENTRIES * (nr)] * Finally, if EARLY_PRINTK is enabled then xen_fixmap will be mapped * by the CPU once it has moved off the 1:1 mapping. */ -DEFINE_PAGE_TABLE(boot_pgtable); +DEFINE_BOOT_PAGE_TABLE(boot_pgtable); #ifdef CONFIG_ARM_64 -DEFINE_PAGE_TABLE(boot_first); -DEFINE_PAGE_TABLE(boot_first_id); +DEFINE_BOOT_PAGE_TABLE(boot_first); +DEFINE_BOOT_PAGE_TABLE(boot_first_id); #endif -DEFINE_PAGE_TABLE(boot_second); -DEFINE_PAGE_TABLE(boot_third); +DEFINE_BOOT_PAGE_TABLE(boot_second); +DEFINE_BOOT_PAGE_TABLE(boot_third); =20 /* Main runtime page tables */ =20 @@ -135,7 +146,7 @@ static __initdata int xenheap_first_first_slot =3D -1; */ static DEFINE_PAGE_TABLES(xen_second, 2); /* First level page table used for fixmap */ -DEFINE_PAGE_TABLE(xen_fixmap); +DEFINE_BOOT_PAGE_TABLE(xen_fixmap); /* First level page table used to map Xen itself with the XN bit set * as appropriate. */ static DEFINE_PAGE_TABLE(xen_xenmap); --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel