From patchwork Mon Jun 10 19:32:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 166358 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1409939ilk; Mon, 10 Jun 2019 12:33:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwNapioV17uCDC10vami/twHqz4QKGDzHxluePpWAvXbrwDcyeNyE/eSYXaL/c0vweFzGG X-Received: by 2002:a6b:8b51:: with SMTP id n78mr47262605iod.192.1560195211379; Mon, 10 Jun 2019 12:33:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560195211; cv=none; d=google.com; s=arc-20160816; b=vtk6Gmrd4sdUCdgTzEb050M0QS3cxMtcQPqgfUSq+NfQWOFWVI1bvbHkjV+lKNXcbd Pp1PSUxILurZ2glMCTOZsNZeEnwELpMKL3s8LlfI1glpFlI0oNsEO4ywl8Mleunb8UKx QEpd5dy9c8ffMmt5UswtidkwHGQ1m/H6mk57K8XyOgQd94NakSQBZJygYZF6Dp0mcElw 3HEt3b7jTCt50gUbVgrWF7qxcQ06aR7BNmAx0sFVIXhA1SO4iwJnUdSaxQYO7cUUz/fS lNFZTof30MXuFO5Js+uytyI0sG3K35Ako5QjGOxcjev+vj57K2ogqIAbBhimn1bjxVm9 Q8PA== 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=dVg36GpuHS3j6xpC6nndZXPHBXCyiCJjMVzEC316tog=; b=CSewaSvk1A+DNm26ZVy/WGSb1Gj6Tpdr/1LiRzpKluxPXbyZoju4WZ4tBDyjrY/j7F MgIxcEJ7B0jub15mKgf6VIIfdyIOnKwaHYw56El8pAJxT3va8oIsuR19G8mmk85oWWnL 9iJwdQOM4AGwTFqZ89L5IPf+2Rzcm7nLjlxRQ5/7jEULs+4nb4EBNuVjq3McvWPaoCwZ uTpdSNVGMrwJGgezLUIlqm76I6oO6Wb4cQhP4tLjAqiOma0jqGvqIgO/q6YktDtkfwsF jr2CIIqrUV6xwyqsao5St+7kVt9JBPTDsNGxNlmLUGGiS03UY5YVVyRpHfwo/LXM6faY K9Kw== 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 m47si207846iti.111.2019.06.10.12.33.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jun 2019 12:33:31 -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 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 X-Inumbo-ID: 815a49c3-8bb6-11e9-8980-bc764e045a96 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) 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 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, =EARLY_UART_VIRTUAL_ADDRESS #endif + PRINT("- Ready -\r\n") + /* Setup the arguments for start_xen and jump to C world */ + mov x0, x20 /* x0 := phys_offset */ + mov x1, x21 /* x1 := paddr(FDT) */ + ldr x2, =start_xen b launch ENDPROC(real_start) @@ -374,6 +379,9 @@ secondary_switched: /* Use a virtual address to access the UART. */ ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif + PRINT("- Ready -\r\n") + /* Jump to C world */ + ldr x2, =start_secondary b launch ENDPROC(init_secondary) @@ -734,23 +742,24 @@ setup_fixmap: ret ENDPROC(setup_fixmap) +/* + * 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, =init_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, =init_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) /* Fail-stop */