From patchwork Mon Jul 22 21:39:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169452 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012626ilk; Mon, 22 Jul 2019 14:41:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxokj40ZL2m1Rax0swOL+HgGj64gFaUhvhSDU/TsnAZi/uLiZ/w48rmAij+rXDBe57AqHGL X-Received: by 2002:a6b:4107:: with SMTP id n7mr23239ioa.12.1563831700603; Mon, 22 Jul 2019 14:41:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831700; cv=none; d=google.com; s=arc-20160816; b=YlIN9lcn/2pULU+WF5q5PGXaTz2uyyxrI+ISwGbF3AM2VX574YjG6kXc5P8jD4Q2zZ THrhvbFmqCn3f8HOmH00ZToHrSrciB9KV5gOz+KWMaidbVIxzcFE39hWE2Slp3XZy8fr 3J+je2xc8BHUQdZlBNBV5bpGGGxjHTavWz5IeTQME//XoOjG+mFAeE3nwN4pDfQduBZp EJHhiyNhXua4qQc2EBJDOk1/FTLY1nNNQLgzNmbb99GUjOStC3as1U4RDEuF92fFrJLD EUOc2t6HuVgGIIHsLMCEKtBJRz8OPMyqNIW24iJHSkfKbTWXLJAxHNdhhne/fSfZMhzI rfvA== 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=SjqRVSO5lJFIg1CfFkwYbAACc31yn1SPKha1DG7+T9M=; b=ufPzGJgnwnEdiU7oDWwyXcxa3kZKwkRND2N4akoYc5dFoi3KHQ5UtS+sCF7fYVmsRL 5uTmA4t2A69/4bTmA6zD+THMv40fFIQYVTpNMetgKZBXugYJEypAh/sTa16wv3RaGoUn re+wL+rO7CvLfdCKJxGnbh1zc2W7WToMERry73Lvf3dRov21IWcbKoLb7LyXRup4MFX7 hrg1imQKwvE8nUnSwAHJ01B1pDZ7Elbd+S032OX8WtNWTCrb0KSmDYpIj5nE7FnPyDhG qFNgER6EgDZEo5pdZnT06jkZ9BjeFXQDfaQ1Nf2Uh5kkITh2ydu4cQyRXTP/XnCcaaWb khQw== 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 p18si53561199iob.109.2019.07.22.14.41.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:40 -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 1hpg2g-0002h1-R9; Mon, 22 Jul 2019 21:40:22 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2f-0002en-Js for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:21 +0000 X-Inumbo-ID: 4dba2799-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4dba2799-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:20 +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 319B51597; Mon, 22 Jul 2019 14:40:20 -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 7F8DB3F71F; Mon, 22 Jul 2019 14:40:19 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:39 +0100 Message-Id: <20190722213958.5761-17-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 16/35] 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk 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 Reviewed-by: Stefano Stabellini --- Changes in v2: - Use x3 instead of x4 - Add a clobbers section --- xen/arch/arm/arm64/head.S | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index f165dd61ca..7541635102 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 := Physical 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) @@ -732,23 +740,26 @@ 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 + * + * Clobbers x3 + */ 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 x3, =init_data + add x3, x3, #INITINFO_stack /* Find the boot-time stack */ + ldr x3, [x3] + add x3, x3, #STACK_SIZE /* (which grows down from the top). */ + sub x3, x3, #CPUINFO_sizeof /* Make room for CPU save record */ + mov sp, x3 + + /* Jump to C world */ + br x2 ENDPROC(launch) /* Fail-stop */