From patchwork Mon Jun 10 19:32:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 166363 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1410224ilk; Mon, 10 Jun 2019 12:33:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ58fA+RiMH7OdD4rliYFOI36gJMTR2Sa+uf4MZJaI4C63ZsDJluP2Pg8RClI8mXks5Lwb X-Received: by 2002:a24:90c4:: with SMTP id x187mr8641252itd.172.1560195228413; Mon, 10 Jun 2019 12:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560195228; cv=none; d=google.com; s=arc-20160816; b=POkCTdbwQ/0jlTLafQ1oke90YUUj1Gjhe5ceZ1GLU7+/cut4xaZ4BhegJLXgE7mBck zLYUAGcukxe1aBKk1YdA+cN/WJNbeCRT5ioqzHFl1kmOYATJ5SBoXzhn0TD1Ouiwa/Kd NaM/jE25RR5eIbu4FyZ1kQB1SropK46VAm33XA9hMAXrrZo09sj0VPkuPaGO8ARToNAt oubx4kGbYoIMkJSv7AgWfyh8C/lS/GGpCkGPwd11emk5o+sZLtS3v3gVgUBb7NeZVyX8 mky5zf4enSlpzKbQfN0uInbzxff2lFw+YuA+CPrg04fJJl4Q4wLgB5ruilQ2u2E6+laU W9IQ== 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=stI3LuhrLkBVwotN3m+5tAIqayaM8tyd96UBAHV5Fv0=; b=TKXZQDpv1wCSJcskqqrwDj48kOKXy7MyrqYFrY1ED00OWHScxYKDhy8PepTZ5XTxHX 1Is2FZNGuUv6gPD4xCN5a0cuJxwbZ6OR07sErtSmYoWqvEZEQ9JMVvb71AeVNJfTvsp4 A06O+RdWYz/HChuMPI0ySzPClHMYPX9ULVitkwu95reD2bCUmzRs1Krg8GH12WXv8oLR GGv0F0UIBZ06ogYXvVQZzRF6guqsft2i/4JKLrBteWuhhAq8+rtU0yWm4lQs6K/V9f/z ZzBOj7b+DajFONOPh15blR9VO878x3sxFSnJS4QWxDO+f0bGlY0ruCRMjDriQHWSo6we d+3Q== 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 g127si7083732jag.119.2019.06.10.12.33.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2019 12:33:48 -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 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 X-Inumbo-ID: 7aa408ec-8bb6-11e9-8980-bc764e045a96 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) 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 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: mov x22, #0 /* x22 := is_secondary_cpu */ - 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, =primary_switched + br x0 +primary_switched: + bl setup_fixmap + b launch +ENDPROC(real_start) 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, =secondary_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 el2: PRINT("- Xen starting at EL2 -\r\n") + ret +ENDPROC(check_cpu_mode) +zero_bss: /* Zero BSS only when requested */ cbnz x26, skip_bss @@ -356,6 +383,10 @@ el2: PRINT("- Xen starting at EL2 -\r\n") b.lo 1b skip_bss: + ret +ENDPROC(zero_bss) + +cpu_init: PRINT("- Setting up control registers -\r\n") /* 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) +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 1: + ret +ENDPROC(create_page_tables) + +enable_mmu: PRINT("- Turning on paging -\r\n") /* @@ -524,16 +562,16 @@ virtphys_clash: tlbi alle2 /* Flush hypervisor TLBs */ dsb nsh - ldr x1, =paging /* 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) +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) +launch: PRINT("- Ready -\r\n") /* The boot CPU should go straight into C now */ @@ -594,7 +635,6 @@ paging: dsb sy /* Ensure completion of TLB flush */ isb -launch: ldr x0, =init_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) /* Fail-stop */ fail: PRINT("- Boot failed -\r\n")