From patchwork Mon Jul 22 21:39:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169446 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012452ilk; Mon, 22 Jul 2019 14:41:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxh9nC5N1/xhXb6V666nyRfgwI1TSja4ZXzomBNeLGETlnjKujil7qXs4OKloEnIgVUCimV X-Received: by 2002:a6b:6001:: with SMTP id r1mr64887391iog.229.1563831689618; Mon, 22 Jul 2019 14:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831689; cv=none; d=google.com; s=arc-20160816; b=Ld9H3mswygmI7KQcNtJE3NuEr/IPejd1MJu3+I9x6sUy5bp6g2WQmoV4tZeYlmBIwB wv97mzVZ0CPxf5i/zAoCDU8bbGmd0hQzpL7IOT8G6z0DjuYKhyxXIpQ8NLIUqaHu0vsv YYBEV8XN/pzDDXRWUqPe2ytrFxmm6o2QcA53Xwrao1rHXbwF1ldRiGRg5zusaQr454VS XopqLAHxynFSSYBioc85hh0y7u0wTKOb8HycdjVwZj10WnkDx3V6ETnadfw8g+0If0aa 3MB2fAMK72VcYZWaIzfCd9TbGAR9RrHz5E6UvNaxkL+WRjK/98sVsZ91lsE1QAGlA1Oy er1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=51r7muPtd4xfNEUZUf0bBX3EScuapTd9EwmNKW+CJSU=; b=cLVaaqy1Tn0S/OGhjjnrFSGayhWsN5j0ACSjEWyLbKaZX6VvfHKlhIOJxGtvZG+Yso KUZT4+fObJJMC8VawPfg+Ovsek7C1+B0JUXXZcsAB0Do34CGDCoWTQvRUfgLyjqj8yJs yoR2FOR77ufkeYeUUoYENjixTB5CH1bzA3eSNV77MiyLOd51AoXJ/wKA4i+6erYq4kyx mB1vbHTSmUWnKh7btFOaQMtQGtjExwuU+JoZBQDO4RWDGeFBou+exCwLtEWru1FvPuHd X7ywc5A4S3ybdm+2mpTedvTWor6Ck3Ldz4YJkzgdwrdxMZJbLucdSli/QJ3PqbOD1uQ2 dlug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h9si37603457jaj.88.2019.07.22.14.41.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2Y-0002Sm-Ca; Mon, 22 Jul 2019 21:40:14 +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 1hpg2W-0002Ri-Et for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:12 +0000 X-Inumbo-ID: 474f1cf0-acc9-11e9-950f-87b7baaea3f8 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 474f1cf0-acc9-11e9-950f-87b7baaea3f8; Mon, 22 Jul 2019 21:40:09 +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 4FCF0344; Mon, 22 Jul 2019 14:40:09 -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 9D1AA3F71F; Mon, 22 Jul 2019 14:40:08 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:27 +0100 Message-Id: <20190722213958.5761-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190722213958.5761-1-julien.grall@arm.com> References: <20190722213958.5761-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 04/35] 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk MIME-Version: 1.0 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. After this 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 the CPUID. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Fold "xen/arm64: head: Don't "reserve" x24 for the CPUID" in this patch --- xen/arch/arm/arm64/head.S | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 6afe83c347..b684091aac 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 - @@ -265,6 +265,12 @@ real_start_efi: load_paddr x21, _sdtb #endif + /* 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 := is_secondary_cpu */ 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 := skip_zero_bss */ -common_start: mrs x0, mpidr_el1 ldr x13, =(~MPIDR_HWID_MASK) bic x24, x0, x13 /* Mask out flags to get CPU ID */ - /* 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: #ifdef CONFIG_EARLY_PRINTK ldr x23, =EARLY_UART_BASE_ADDRESS /* x23 := UART base address */ - 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 +common_start: + PRINT("- Current EL ") mrs x4, CurrentEL mov x0, x4 @@ -620,10 +623,16 @@ ENTRY(switch_ttbr) ret #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, =EARLY_UART_BASE_ADDRESS #ifdef EARLY_PRINTK_INIT_UART early_uart_init x23, 0 #endif