From patchwork Mon Aug 12 17:29:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 171111 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp3120248ily; Mon, 12 Aug 2019 10:31:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqwy9n0kR+PdNEj8vUHgGtgHNJ7qDeEj306vEHW0pl3Qi8XFxGJUB5Pem5Bz5qFW+hMa+Cbq X-Received: by 2002:a6b:e90c:: with SMTP id u12mr1212648iof.221.1565631108461; Mon, 12 Aug 2019 10:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565631108; cv=none; d=google.com; s=arc-20160816; b=lAHvHOA5ENfb5sVeyiTSpAfxf+h0XXMPFURInIrcB0Su7M5c0t2FLjJh42QZuhivbu Nhcq0HF9+NvRsJEfICJrnlcW//Zu1OtKIjqTCYN+RmhEawV84qyGTgBIG9BJcWIdK+rk +MzNYSunq8Q1NhA6TdpyNzGFzik0VlLzEzuVeXDROoI/P5jaRN/93QOpkynsURitlWpo aoaP7KmFffHzwsuADYdMl73C0A8E00eiLDU0tfNoE33ePgX2EWq72GEFjt3Z/w+n1TeD HZUd6GQY4rWd5F52B99r4wXQIOMFPNmzGlikubtym3MyIWAjrvqdxlO1Dzt6YlMct/cy vWoQ== 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=V6QdoZY6mMvtxJVkiaKhbKEcrN57JCAWdTaKQhRrIsY=; b=vn5DCiIgqFBXKTFnE5eRGezroSOzEYJ/T0oTXybjhTX7iKdHEubLMlhJDKePc9ylvN nzMYSMAEXFwcz+T7u36BubvKkrW4xNhJDNX0F2ZdvPGl+0xSum6Th8yy4h3S+ncfN8Ii ijOElPxb1/nKadCRaOIDap0b9qs9KN7UhltV2jEr/Cx31HffLfLygoNbF1CGxsdGTg3b DR8WyntcTsJL01tYQwYf7trgdffDlKA7FVdw7XkXr81a61JyeUk9IYxzvP6odaBdlD5Z kPuB8GU+GDASCuXDI2MbOkTBdW//uv1wUURteqTCSIGhiX/oYTJAWtiB3iAewAsDuRDu BqSQ== 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 y8si22200896jap.72.2019.08.12.10.31.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Aug 2019 10:31: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 1hxE9V-0006hX-B4; Mon, 12 Aug 2019 17:30:37 +0000 Received: from [172.99.69.81] (helo=us1-rack-iad1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hxE9T-0006hC-Lo for xen-devel@lists.xenproject.org; Mon, 12 Aug 2019 17:30:35 +0000 X-Inumbo-ID: e206497c-bd26-11e9-9c85-8b766f5a9059 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-iad1.inumbo.com (Halon) with ESMTP id e206497c-bd26-11e9-9c85-8b766f5a9059; Mon, 12 Aug 2019 17:30: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 D5A8315AB; Mon, 12 Aug 2019 10:30: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 2FF9A3F706; Mon, 12 Aug 2019 10:30:30 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 18:29:55 +0100 Message-Id: <20190812173019.11956-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812173019.11956-1-julien.grall@arm.com> References: <20190812173019.11956-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v3 04/28] 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 v3: - Indent all the comments the same way - Add Stefano's reviewed-by 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 7b6b820726..925fb93e58 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -318,6 +318,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) @@ -380,6 +385,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) @@ -741,23 +749,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 */