From patchwork Mon Jul 22 21:39:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169440 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012396ilk; Mon, 22 Jul 2019 14:41:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHRqhW2pWG54bj3SuXbuZO3rQfLwcSmdsqVpUb1/A5rHzVeKnEj2yhY8sswvfJNpx/J2lv X-Received: by 2002:a5e:a712:: with SMTP id b18mr66042865iod.220.1563831685247; Mon, 22 Jul 2019 14:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831685; cv=none; d=google.com; s=arc-20160816; b=DR3q5bgMx1lDhFM6+1jGOR4f16KBoDZqFgCPTMdtTOBFB54gnM2ue4MTZKtlzOSw6Y /8YG5ACvLNfuzLyTLSmWEmEQzff5AFut0dpy6ODWeVbFB4HVgUssgDjhdprRWCKx6n0y lzz9kH6rzHV80px3jSAfQ/my8e+rRNT5Wql4tfQYm21Ul/KpN/gWgoEPRAx1ywqMNCzb BGkUiRb761UE0NiC7guhp91A0pOsMS6MPN2etCxyjWs6rGxNM2Hc6AQFL8Cfn3/jm4db GbGyOf69gkCrnsvOWhE1vuFNuXyH/J7btu60G0S5xyx/SNmaPdAIHj61Nkj11NSTrzCm V2KA== 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=TYv3f8tMVHJdr6F8EK2AuYGzfLhhgMD8Z+QfpFCT8HM=; b=pWBrx/qPyv5RrEnsXntRgbEl4z7IORZ2YM4ttWndHYSgNlMqTk9tMQyXvf08X0SdgT 2nsuKxIKQKFfQFyEqzJkMlIAoiRv3q4/XIj3bzIexRh/9xcQOaxES4tFa6ckvE8A0349 pxrHcCmUPtJMmg9dtQBnG7KmLvBYQSJ6xtkV9+a97IksWKXbkBLh1VKRwW2b+xMlAnYL Kqn9eK7O/KINPC5HTHcjaLjHWm/rU95/BVZLbHYSjUp5nKBBVyxYezTbGAD60FEIQRoO HtzwLaQrPT6S39rlqsiG3m0Tc/aneMJfMGsws356+ahfJZo2Pjko/mSzf8CUdHGJksA3 f/Ww== 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 g10si43122714jag.105.2019.07.22.14.41.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:25 -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 1hpg2T-0002Q3-ED; Mon, 22 Jul 2019 21:40:09 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2R-0002MX-V8 for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:07 +0000 X-Inumbo-ID: 45b43da2-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 45b43da2-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:06 +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 9C54D1509; Mon, 22 Jul 2019 14:40:06 -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 E87433F71F; Mon, 22 Jul 2019 14:40:05 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:24 +0100 Message-Id: <20190722213958.5761-2-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 01/35] xen/arm64: macros: Introduce an assembly macro to alias x30 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" The return address of a function is always stored in x30. For convenience, introduce a register alias so "lr" can be used in assembly. This is defined in asm-arm/arm64/macros.h to allow all assembly files to use it. Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm64/entry.S | 5 ----- xen/include/asm-arm/arm64/macros.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index 97b05f53ea..2d9a2713a1 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -7,11 +7,6 @@ #include /* - * Register aliases. - */ -lr .req x30 /* link register */ - -/* * Stack pushing/popping (register pairs only). Equivalent to store decrement * before, load increment after. */ diff --git a/xen/include/asm-arm/arm64/macros.h b/xen/include/asm-arm/arm64/macros.h index 9c5e676b37..f981b4f43e 100644 --- a/xen/include/asm-arm/arm64/macros.h +++ b/xen/include/asm-arm/arm64/macros.h @@ -21,5 +21,10 @@ ldr \dst, [\dst, \tmp] .endm +/* + * Register aliases. + */ +lr .req x30 /* link register */ + #endif /* __ASM_ARM_ARM64_MACROS_H */ From patchwork Mon Jul 22 21:39:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169444 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012437ilk; Mon, 22 Jul 2019 14:41:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaDePu1KttBuivT9JWBfBjhst+4IBgI+vsHMB/O4QXF6QJIqQSFf+dTkrbmcnZ2F0otlHU X-Received: by 2002:a5d:8a10:: with SMTP id w16mr32345542iod.175.1563831688289; Mon, 22 Jul 2019 14:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831688; cv=none; d=google.com; s=arc-20160816; b=wg68UuDzHMKbcQIcWw65bzmQ4emr9R8ISwTFJPW634AMrxl0W80/juAXQIdefDndDq 9chyGgHctFje3hwVLt0wanuy/a7D2F/JvbkUw+9dlEUzZWKMc/1W9JWe0SBhUInpMXxc QpCo6YPQCouzD3B2oMS5EKQdhgYAODj34K766bN/rvPEEVdmZwEnuRAl0Ul1/XHBlai5 EwVPDV337+wRWe0Fu+1zx6KNHgFb8ifT1JCKNuiL8koE9N3ZgcUPKi3OSVcFyDkoFAoB YL2Y0I5SM+HoV6Kd1DI6kIJslSEewfSWP21GXfchR2g4gp92w1r5oq3V/EVlELND5vby G3yg== 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=w+AP9nQ20YDyQJjh61pznCWkTSZ1bBcQWO4CgmPItSs=; b=VQiK9dL68uucdnaooBrvioLbo6xGD0QQwUgtLMbW6vj086ZXNZvcqRt1o/X0CKclgN r0TwNzUED37do3+upMXXigVq7F2tRPoVQ3Lz+R1c9WXtLv1QhSGV/el1Kc4lJT/rWzab b4jQC3Se4gpmNjacukTRK5ll9EsGbVP9M2mqHZr+348bsVp8wtc/kkIR3/bG05mqdFAg ARcQdCnLYrpEeAcLYNdTrth39FLn/K1hvpYr3gG4fggAam+m93fz/oBp2zouk+h7yYSO wD4V0bpIm3iSJx2HEpybPmecIM0d09UJsICkoD+GwHFrsDt6grMFHu0cRXB2o3ctSTpK 5ZDw== 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 b5si55315941iok.70.2019.07.22.14.41.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:28 -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 1hpg2V-0002R5-1T; Mon, 22 Jul 2019 21:40:11 +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 1hpg2U-0002QR-75 for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:10 +0000 X-Inumbo-ID: 462f4016-acc9-11e9-82ce-3b34b8d0f432 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 462f4016-acc9-11e9-82ce-3b34b8d0f432; Mon, 22 Jul 2019 21:40:07 +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 82D38152F; Mon, 22 Jul 2019 14:40:07 -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 D0BC13F71F; Mon, 22 Jul 2019 14:40:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:25 +0100 Message-Id: <20190722213958.5761-3-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 02/35] xen/arm64: head: Mark the end of subroutines with ENDPROC 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" putn() and puts() are two subroutines. Add ENDPROC for the benefits of static analysis tools and the reader. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Fix typo in the commit title - Add Stefano's reviewed-by --- xen/arch/arm/arm64/head.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 08094a273e..f2d7445f6a 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -638,6 +638,7 @@ puts: b puts 1: ret +ENDPROC(puts) /* Print a 32-bit number in hex. Specific to the PL011 UART. * x0: Number to print. @@ -656,6 +657,7 @@ putn: subs x3, x3, #1 b.ne 1b ret +ENDPROC(putn) hex: .ascii "0123456789abcdef" .align 2 From patchwork Mon Jul 22 21:39:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169457 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012400ilk; Mon, 22 Jul 2019 14:41:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8olIXK3gFIXSE7qDXkF1aUK9E6LuMguYrm3xaLoHQCvQictelyCRAgAcSaBxJXaIL0kcd X-Received: by 2002:a02:13c3:: with SMTP id 186mr73897435jaz.30.1563831685372; Mon, 22 Jul 2019 14:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831685; cv=none; d=google.com; s=arc-20160816; b=jxk5zsK3Vn41vQ6EU1WhJ6Md6x/af5P9GfbWHcy1O5Aj4eJf6Dp154GySghyE5qmul oe72hQcQbtyv58kCY6lTynGdHYXcCxCk1VH67tJIKPasIX2vOFFyx7KLTmFfbFEgZ2Hx Tqpu5Ofg7a+04Cf0kdaZz2ZLo8PfEUrq7eku0YzGmNgRxG8wNNbW+rON7Tr+26C/ju8l f2CD6LB36T+2ZdkFIhF8ljuX6kq/us09CH73+XpCSbEDf7IHyjia1tIBKiPjJ2ZcA6T5 sZF9LYiAnKyuJw8ulpNNktiY0Kpo1MPAz4JctxigHdvtARsS8BEf57i1BvEVSboD53Ay 9ubw== 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=3/nnOe5Y+HseZ2FfHzka+U4SBK/fb0ToVMN4nJBi3LE=; b=JfVbNiwFYpSgF0l1eQl/+F427zbOdMLjO6J9cBMNaO5ntUo/luLF01mvm3wPk6PBBX Iv8qzi1Oo0BdeGnwr609Wr/5GNg22jrOakqC+/hoD4xKDDoh4rw1vTkdeqa5H/qdbmGE YlAtnAwHcZSWXtZYf/1yVFe3bfnF4haer1MIbhXih2r6QBzL3j5Cb445sEUMumpAZ5hw dhoNNTh4YTZ8nfzC4hWB9VOMfXDLYF+vGbAC1j43rvAhxVk0/5Xjw/CQ7W5waQUce+5w epG6vB6C1BAsFJ9dkin6IdRzpr0c+d+QavIUB9gER1IyjlecVTuG3wGQJN1ef7Z1wjcZ Qa7w== 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 l10si37478000ion.114.2019.07.22.14.41.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:25 -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 1hpg2U-0002Qg-NM; Mon, 22 Jul 2019 21:40:10 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2T-0002Ps-7e for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:09 +0000 X-Inumbo-ID: 46acabbc-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 46acabbc-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:08 +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 68F93153B; Mon, 22 Jul 2019 14:40:08 -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 B6F463F71F; Mon, 22 Jul 2019 14:40:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:26 +0100 Message-Id: <20190722213958.5761-4-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 03/35] xen/arm64: head: Don't clobber x30/lr in the macro PRINT 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" The current implementation of the macro PRINT will clobber x30/lr. This means the user should save lr if it cares about it. Follow-up patches will introduce more use of PRINT in place where lr should be preserved. Rather than requiring all the users to preserve lr, the macro PRINT is modified to save and restore it. While the comment state x3 will be clobbered, this is not the case. So PRINT will use x3 to preserve lr. Lastly, take the opportunity to move the comment on top of PRINT and use PRINT in init_uart. Both changes will be helpful in a follow-up patch. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/arm64/head.S | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index f2d7445f6a..6afe83c347 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -78,12 +78,17 @@ * x30 - lr */ -/* Macro to print a string to the UART, if there is one. - * Clobbers x0-x3. */ #ifdef CONFIG_EARLY_PRINTK -#define PRINT(_s) \ - adr x0, 98f ; \ - bl puts ; \ +/* + * Macro to print a string to the UART, if there is one. + * + * Clobbers x0 - x3 + */ +#define PRINT(_s) \ + mov x3, lr ; \ + adr x0, 98f ; \ + bl puts ; \ + mov lr, x3 ; \ RODATA_STR(98, _s) #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) @@ -622,9 +627,8 @@ init_uart: #ifdef EARLY_PRINTK_INIT_UART early_uart_init x23, 0 #endif - adr x0, 1f - b puts -RODATA_STR(1, "- UART enabled -\r\n") + PRINT("- UART enabled -\r\n") + ret /* Print early debug messages. * x0: Nul-terminated string to print. 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 From patchwork Mon Jul 22 21:39:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169450 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012528ilk; Mon, 22 Jul 2019 14:41:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxS5n0P4LzB+/JJBjOC4nQ7qp0LwSSo0/vE70huv+RtoXlXC/J8r6Z9xyLPnQTW6tcFOMvz X-Received: by 2002:a5d:8447:: with SMTP id w7mr70416848ior.197.1563831694318; Mon, 22 Jul 2019 14:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831694; cv=none; d=google.com; s=arc-20160816; b=MdEq4nUB20wDpNLnqImJCvnjXWNoQ+e7M18PoEOQ7IomFD/oLo8VoeW1Va3KkSKu11 MwznPrH/1XJ+G//+5Ex9Y2ARspO0mNpRYAm47WTeaoN4AVis5m9uKZaH7xlnObyE6sxp kljfyoR3KntE1Dn5NloF+Q8Twink8GwoE1ToD/hZXIbY3WOfW1pvHyMZO2+ncxgsxKCm a27oZlZzZIDul0eaGDKKqQLvVQgev9Yuuv7FNCIfNLy8127aCiaNMDKi7AuJ/ogsWbgS JhsHtE0FBD6fdi5AI6x4lC1gNNW4L2l9eDVKuMykNQgLd+b2pDasaFuUhgGG1o9o9K8T Eczw== 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=mAgloyQJo26Ncqb7KJsFgSWM8G1t1QUHFm0BNDrt4YE=; b=jZUju7ThLTIlbw12geOPDdKbKrvsKJzq1TBqUpXoKPb7itKoG7OeiDNrK0mxsWJ8G2 ajAHdF/imTKA5NYppRMSAwZHCAtlSdTGQdCDk5VouObEpx8eYE2g08+4KCdjtxDg7fhS 88/djK/AIeaG1SfqW7FK1Scimj11/u7ea3ifAErCSOkyrMTZqYx7wIhDifRkOsU2kMcG PiwH9K8CNUzNUgkC/0KjU3j5BipVwSeaMHYFyRjwoTBYUlRmKKrO0IBuhzYXhR8bvB1g 1hPIJRmPAwtKiwcu2g1tNP0WzL/AbUMOt3EbNiTCuUll99la9r3awsCzlt8/MBhURvtI 416g== 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 f43si33033493jaa.34.2019.07.22.14.41.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:34 -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-0002TJ-O3; 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-0002Rj-FM for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:12 +0000 X-Inumbo-ID: 47ca57b2-acc9-11e9-9a00-33efccef8bfa Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 47ca57b2-acc9-11e9-9a00-33efccef8bfa; Mon, 22 Jul 2019 21:40:10 +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 363241509; Mon, 22 Jul 2019 14:40:10 -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 83E673F71F; Mon, 22 Jul 2019 14:40:09 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:28 +0100 Message-Id: <20190722213958.5761-6-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 05/35] xen/arm64: head: Introduce print_reg 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" At the moment, the user should save x30/lr if it cares about it. Follow-up patches will introduce more use of putn in place where lr should be preserved. Furthermore, any user of putn should also move the value to register x0 if it was stored in a different register. For convenience, a new macro is introduced to print a given register. The macro will take care for us to move the value to x0 and also preserve lr. Lastly the new macro is used to replace all the callsite of putn. This will simplify rework/review later on. Note that CurrentEL is now stored in x5 instead of x4 because the latter will be clobbered by the macro print_reg. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Re-order the instructions to avoid cloberring x4 early. This allows to print content of x4. --- xen/arch/arm/arm64/head.S | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index b684091aac..63d63bc8ec 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -90,8 +90,25 @@ bl puts ; \ mov lr, x3 ; \ RODATA_STR(98, _s) + +/* + * Macro to print the value of register \xb + * + * Clobbers x0 - x4 + */ +.macro print_reg xb + mov x0, \xb + mov x4, lr + bl putn + mov lr, x4 +.endm + #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) + +.macro print_reg xb +.endm + #endif /* !CONFIG_EARLY_PRINTK */ /* Load the physical address of a symbol into xb */ @@ -304,22 +321,20 @@ GLOBAL(init_secondary) #ifdef CONFIG_EARLY_PRINTK ldr x23, =EARLY_UART_BASE_ADDRESS /* x23 := UART base address */ PRINT("- CPU ") - mov x0, x24 - bl putn + print_reg x24 PRINT(" booting -\r\n") #endif common_start: PRINT("- Current EL ") - mrs x4, CurrentEL - mov x0, x4 - bl putn + mrs x5, CurrentEL + print_reg x5 PRINT(" -\r\n") /* Are we in EL2 */ - cmp x4, #PSR_MODE_EL2t - ccmp x4, #PSR_MODE_EL2h, #0x4, ne + cmp x5, #PSR_MODE_EL2t + ccmp x5, #PSR_MODE_EL2h, #0x4, ne b.eq el2 /* Yes */ /* OK, we're boned. */ From patchwork Mon Jul 22 21:39:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169465 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8014058ilk; Mon, 22 Jul 2019 14:43:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwZShZD66pw8LWGK7dL1FcMtFoe1jCrHGq6Njm8+3XNwnXOightrsn1zntkMpnyCGN6gPRb X-Received: by 2002:a6b:8f0d:: with SMTP id r13mr2890436iod.121.1563831694580; Mon, 22 Jul 2019 14:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831694; cv=none; d=google.com; s=arc-20160816; b=yj8Y1+KCP1ZZAxb6LQC8ZZ0XVQPtL89G+86JJwjYPQTG8xqZAXgDsT8yOmpRm/8APi c6L9+2M3Y5m5xJ440jzzqx8c8EEjteJ6CTOVOjm6wyI1T3Xk2pJEfdwjDoAOqgZXdWfr ffcEScv8Pn2buFF5ltMkOd2T23pvauOxme5fycX8jNZ5vUYCaJnzAeedIHd52ZYB2dgO NXPc8BR67apHvK4Ytomixa5Y6psAfxzm+RN1K8ynXHhKuu2CkGSqosPVJc5lIcIMlGNX SbdBdZe9e3ObJluTIWLaVwQuivET21hjW+LU8W3+92Z+Df3nPQQP3r6fwtLLJqurD0fV Cn0w== 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=xKlKJljYshzYKqLOM3fX7HqA4WqBAV32UhqLP4B6dAA=; b=HFye/fzUuz+EJoz+5qaBpxaNKfV+0FAH+QV4HZmq3WBN1RcdP/UcDxJae/KbZSFFpJ 9HuwXlTxkCyL8GncrvMNYwXWzIPt+pz4NJvSpi3HlbExh6SNx1CV/6KdVmN/tEbe1YXz +HNaG8yEAYIvWo8fo4AHw75QklcCnz65QxtdipfvQflY2QaDBTVAkRu7tj8MQRJV5avv 9ALK52mhZDbP5WhGYa2Fo95sfEDF9U1/04jNGGF3Ho/anKi3UYxnJ0ECCoAasVN1iu8X 4iHbsrNp8Q6SRMusCgHh1oxzsAo5SGLm86UxZXcYaS0p+bgah6dKv3RFbSp0rqPZYtJ1 owUA== 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 u1si53996594iom.155.2019.07.22.14.41.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:34 -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 1hpg2a-0002Wf-Qg; Mon, 22 Jul 2019 21:40:16 +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 1hpg2Y-0002TE-NM for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:14 +0000 X-Inumbo-ID: 484659ac-acc9-11e9-801e-1bd7ebfa9c4e Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 484659ac-acc9-11e9-801e-1bd7ebfa9c4e; Mon, 22 Jul 2019 21:40:11 +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 1D022152F; Mon, 22 Jul 2019 14:40:11 -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 6A1E63F71F; Mon, 22 Jul 2019 14:40:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:29 +0100 Message-Id: <20190722213958.5761-7-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 06/35] 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk 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 distinct and for now will call each functions. Follow-ups will remove unnecessary calls and do further improvement (such as adding documentation and reshuffling). Note that the switch from using the 1:1 mapping to the runtime mapping is duplicated for each path. This is because in the future we will need to stay longer in the 1:1 mapping for the boot CPU. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Avoid infinite loop on boot CPU - Fix typoes in the commit message - s/ID/1:1/ --- xen/arch/arm/arm64/head.S | 60 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 63d63bc8ec..df797a1573 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 1:1 mapping. 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 1:1 mapping. 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 */ @@ -382,7 +413,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. * @@ -507,6 +541,10 @@ virtphys_clash: b fail 1: + ret +ENDPROC(create_page_tables) + +enable_mmu: PRINT("- Turning on paging -\r\n") /* @@ -516,16 +554,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 @@ -567,11 +605,14 @@ 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 */ - cbz x22, launch + cbz x22, 1f /* Non-boot CPUs need to move on to the proper pagetables, which were * setup in init_secondary_pagetables. */ @@ -586,7 +627,7 @@ paging: dsb sy /* Ensure completion of TLB flush */ isb -launch: +1: ldr x0, =init_data add x0, x0, #INITINFO_stack /* Find the boot-time stack */ ldr x0, [x0] @@ -601,6 +642,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") From patchwork Mon Jul 22 21:39:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169458 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013538ilk; Mon, 22 Jul 2019 14:42:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjq1CZL7xTQGpTO4emDNa3qh/6RBa2UaQpj6gU0DTbotRbVSZrfC1pMGzRIUZlseJjoYHQ X-Received: by 2002:a6b:bc42:: with SMTP id m63mr52691711iof.189.1563831694010; Mon, 22 Jul 2019 14:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831694; cv=none; d=google.com; s=arc-20160816; b=AWqDbxqsaE84zHpjzah63H/8EoNZc6WWJqpkccbWcJMvH8/qxwIDH9kD5FjjKFVcAR YOFaNEghC0aYKYg+lJfdCX+ek7+aappHwA9g+bFMGw0i6t6I2kFj2B/t0ZnnPfjpMpdw ZhaDi9zs/Go6YDwKE+7TC2LRRF+cDkr1DVTyxH/F99Wp8dT84wvI//pdiEHalxCxMOu9 2h5sRDZBYngTlb6XoR2qo4QDuYIujAdEPPCrPW4LOnLJKiCaJxYIUX2DkXP3H6r09itn kjI6bLHYTf85u60N/5l2eqUVqRO2rOzaOaIfiY1pB9Td+tMrlSdnqhHVy/1r2YJhzGKl R1sQ== 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=Y6lpgC7dWmuUJ2PROGjWlsAg+wVvCc2iX4lSbZ7AX8g=; b=XwgTZ/KqWCWfvXoHsW41ZQCMCSn/7k4ew5QztidGG/qSnm7GmD28gJFUI5FOfHO5m3 2Zxr66oY05M39aGn5Zzek342qb410INA9xwSlwqzDQayG1xhK3yjy9q9WcyJeQiqbG3n N4wLFo8d8yDuOf0Bntqy4KN0g5hj+s1PTD6TrqitT4wpYcBhzKm4e8lZwqj3dcmV+zsM 3SgdXZkByfaAjgJtZcKKUAqq78PEXr0FEO2bHvUW3xg5fZA0mistCI9EuB+SjpgEEfrp IdHXqGdBsiDaWYuG6ZevplG6FYsyxkeTiFXb5xDttdMTyrT3hG0+Baw8wQHtYCo7a0sp sjMQ== 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 c24si13544083iod.82.2019.07.22.14.41.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:34 -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 1hpg2a-0002Vq-BA; Mon, 22 Jul 2019 21:40:16 +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 1hpg2Y-0002TG-NT for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:14 +0000 X-Inumbo-ID: 48c8466a-acc9-11e9-bc40-333e19a5e78f Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 48c8466a-acc9-11e9-bc40-333e19a5e78f; Mon, 22 Jul 2019 21:40:12 +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 03D7E153B; Mon, 22 Jul 2019 14:40:12 -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 51A093F71F; Mon, 22 Jul 2019 14:40:11 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:30 +0100 Message-Id: <20190722213958.5761-8-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 07/35] xen/arm64: head: Rework and document check_cpu_mode() 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" A branch in the success case can be avoided by inverting the branch condition. At the same time, remove a pointless comment as Xen can only run at EL2. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/arm64/head.S | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index df797a1573..fbcc792ade 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -350,6 +350,13 @@ secondary_switched: b launch ENDPROC(init_secondary) +/* + * Check if the CPU has been booted in Hypervisor mode. + * This function will never return when the CPU is booted in another mode + * than Hypervisor mode. + * + * Clobbers x0 - x5 + */ check_cpu_mode: PRINT("- Current EL ") mrs x5, CurrentEL @@ -359,15 +366,13 @@ check_cpu_mode: /* Are we in EL2 */ cmp x5, #PSR_MODE_EL2t ccmp x5, #PSR_MODE_EL2h, #0x4, ne - b.eq el2 /* Yes */ - + b.ne 1f /* No */ + ret +1: /* OK, we're boned. */ PRINT("- Xen must be entered in NS EL2 mode -\r\n") PRINT("- Please update the bootloader -\r\n") b fail - -el2: PRINT("- Xen starting at EL2 -\r\n") - ret ENDPROC(check_cpu_mode) zero_bss: From patchwork Mon Jul 22 21:39:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169447 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012500ilk; Mon, 22 Jul 2019 14:41:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6pZcOPy5OwRpqO783HnfkLsy5Cny4XiqGj5s2MnO55Vq/clc8axm8X8Qg/PzhJVl9muy8 X-Received: by 2002:a6b:dd18:: with SMTP id f24mr32365185ioc.97.1563831692978; Mon, 22 Jul 2019 14:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831692; cv=none; d=google.com; s=arc-20160816; b=BmqwTFPlD43ZZSfHtkUYNZp0D+WgPnf8JY5efe/S1Ab6AxwRq2XI+LuQvFQq3TMOc3 sIMllVFp3hsfZOt/XRYQfmAVU8Iq564o2Bkb9S98+rsrHlE9rlVXaZ15XXLEpoGc3wd0 N+wZyY5sVzYyatVAygKU/zGJpr20rJQI1ObfcgXyEcV9llTC2qtDCLGyxz+CALVovqpG ZPdRQFcj/f063a/G7H34m09Fq2cInbnVguc+0S/kuBC3TA5rOQOwhJxHD4Ml/nKcNYyN nRHmlCr1/UkYu4ozHvUHDQYU1BOiQTGTJY6deEJsM3m+JZCqYgFme9delcqX/t5Gzg6G ovtg== 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=DCmIypgc7y/L6oRbAH292dF0S+4SvcEIpKHMbHEYseE=; b=gnlcQ52rqRp1d4vul7jvsS/2c21zWGr42m0tMtrAGV6Vlq6OjyEmhHDRIB8KTZLAfr 8/ZA4PTxIdOKhsFfADJmBr4YMaXJFbZHE4I6dVC1fO7XIUqmSo7U+FdmaDbt/6JLgqRf ZoW9hlKI0d5AONS4WVRAdkI2JKVTmZPffRGxHFuuNyEPaNbERoCl74bMewsdkJs/818T RNBvxY65CF8tdmfaSjYPcI2TuqS3iiukjOvWKeOEZK1YiHbtDcPmL6ntcNL1AVg4h6p9 BK+HKYxrXCoY7oWllZhoJe01kksRYyiojFR9ryXBZYFXp508xW1ZZtaBSHEya7vSGVHa 2Aow== 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 v5si53062454ioq.60.2019.07.22.14.41.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:32 -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 1hpg2Z-0002UK-D9; Mon, 22 Jul 2019 21:40:15 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2Y-0002Sg-BD for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:14 +0000 X-Inumbo-ID: 495e8108-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 495e8108-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:13 +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 E390A1595; Mon, 22 Jul 2019 14:40:12 -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 37EB73F71F; Mon, 22 Jul 2019 14:40:12 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:31 +0100 Message-Id: <20190722213958.5761-9-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 08/35] xen/arm64: head: Rework and document zero_bss() 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" On secondary CPUs, zero_bss() will be a NOP because BSS only need to be zeroed once at boot. So the call in the secondary CPUs path can be removed. It also means that x26 does not need to be set for secondary CPU. Note that we will need to keep x26 around for the boot CPU as BSS should not be reset when booting via UEFI. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Clarify the commit message - Mention x20 is used as an input --- xen/arch/arm/arm64/head.S | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index fbcc792ade..92c8338d71 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -71,7 +71,7 @@ * x23 - UART address * x24 - * x25 - identity map in place - * x26 - skip_zero_bss + * x26 - skip_zero_bss (boot cpu only) * x27 - * x28 - * x29 - @@ -313,8 +313,6 @@ GLOBAL(init_secondary) sub x20, x19, x0 /* x20 := phys-offset */ mov x22, #1 /* x22 := is_secondary_cpu */ - /* Boot CPU already zero BSS so skip it on secondary CPUs. */ - mov x26, #1 /* X26 := skip_zero_bss */ mrs x0, mpidr_el1 ldr x13, =(~MPIDR_HWID_MASK) @@ -337,7 +335,6 @@ GLOBAL(init_secondary) PRINT(" booting -\r\n") #endif bl check_cpu_mode - bl zero_bss bl cpu_init bl create_page_tables bl enable_mmu @@ -375,6 +372,15 @@ check_cpu_mode: b fail ENDPROC(check_cpu_mode) +/* + * Zero BSS + * + * Inputs: + * x20: Physical offset + * x26: Do we need to zero BSS? + * + * Clobbers x0 - x3 + */ zero_bss: /* Zero BSS only when requested */ cbnz x26, skip_bss From patchwork Mon Jul 22 21:39:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169448 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012511ilk; Mon, 22 Jul 2019 14:41:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuIBUtTG0lO8p791DYqhasUdgi0CLYLl7WHknXBRlne2b86hynuL71RgjnprZF9SyCuA/7 X-Received: by 2002:a6b:bf01:: with SMTP id p1mr37844609iof.181.1563831693497; Mon, 22 Jul 2019 14:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831693; cv=none; d=google.com; s=arc-20160816; b=ccMSWHD4B4vvrTi2cfENmk2/KjNSFlGYt0iAhfhE4iz6x6+qSMln1b7z9q/qQ6yAqO H2BCPUzk9y1rwtkEi/GTyDRpZAy3isUuIjP3yldsq4RMBZMN3JSowaHc1vCvTCRDoUFM VlywEI24LBs77WR6kgc2VuMRqWieqrx/DqkkWfLR/wSo/1y6HlV9JS/27xx4phL5dRM1 71SUueI0dJ6M9J+uMxqCAEgL3yy//9lu7eCy9I/4MGV1OJfglRoQD6jH/i6XDalfkH/N QowghRGmeehidkn6QYGSaSdm/Fy4drLU6MHAbZlZ2cMQm9yKTDLsYUActFHK3jgwr3ic PMDg== 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=Mm28yVNBTqBHobaY/sxPvDAGenf0dETbH/5oSCysQuk=; b=vxsqHZDRPRYKUbOD/gJqOyLubNLJHiQg6GwKCDFmI+pOqWItfG8WfQmktzNBNesf0u khlTZ6/PHfsjhwhu1iXwQlwVzAcSDUAtbCMAe9HkBCUH0pedMtI2DHoP0kHsJSLlUgR1 7LUiI9P5q+pMDxF1r8Nrbcq5gDv802ZnAgrB+e3rswgSgZRkbb1NH8myKimNqlHau0aQ oPaJ1Sk0pbLGviHcfrjCeoJ+BDh/CQ7DeozjxQrto/K5t8cjlqswCyJFtJGe0Q+Qekq/ VKRKMlD7ue1uhXPtYxGRgdIkl7/peeu6qLVyjMDv1GTtEdC1v4tuylO3Zkfk9fJ/U+Bi 5b3g== 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 v3si51991803iot.133.2019.07.22.14.41.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:33 -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 1hpg2Z-0002Uz-SH; Mon, 22 Jul 2019 21:40:15 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2Y-0002Sw-N2 for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:14 +0000 X-Inumbo-ID: 49db19cd-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 49db19cd-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:13 +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 C9E781509; Mon, 22 Jul 2019 14:40:13 -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 237123F71F; Mon, 22 Jul 2019 14:40:13 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:32 +0100 Message-Id: <20190722213958.5761-10-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 09/35] xen/arm64: head: Improve coding style and document cpu_init() 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" Adjust the coding style used in the comments within cpu_init(). Take the opportunity to alter the early print to match the function name. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - We don't clobber x4 so update the comment --- xen/arch/arm/arm64/head.S | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 92c8338d71..ddc5167020 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -397,19 +397,26 @@ skip_bss: ret ENDPROC(zero_bss) +/* + * Initialize the processor for turning the MMU on. + * + * Clobbers x0 - x3 + */ cpu_init: - PRINT("- Setting up control registers -\r\n") + PRINT("- Initialize CPU -\r\n") /* Set up memory attribute type tables */ ldr x0, =MAIRVAL msr mair_el2, x0 - /* Set up TCR_EL2: + /* + * Set up TCR_EL2: * PS -- Based on ID_AA64MMFR0_EL1.PARange * Top byte is used * PT walks use Inner-Shareable accesses, * PT walks are write-back, write-allocate in both cache levels, - * 48-bit virtual address space goes through this table. */ + * 48-bit virtual address space goes through this table. + */ ldr x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(64-48)) /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */ mrs x1, ID_AA64MMFR0_EL1 @@ -420,9 +427,11 @@ cpu_init: ldr x0, =SCTLR_EL2_SET msr SCTLR_EL2, x0 - /* Ensure that any exceptions encountered at EL2 + /* + * Ensure that any exceptions encountered at EL2 * are handled using the EL2 stack pointer, rather - * than SP_EL0. */ + * than SP_EL0. + */ msr spsel, #1 ret ENDPROC(cpu_init) From patchwork Mon Jul 22 21:39:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169451 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012548ilk; Mon, 22 Jul 2019 14:41:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHrR9L0Y2e4NJ0f9YwQRNf4GOJWNvoeiBG1JTZdaQCnEOLexa+EyHxwvlOmfcRjkXluYQ5 X-Received: by 2002:a5d:884d:: with SMTP id t13mr4277817ios.233.1563831695285; Mon, 22 Jul 2019 14:41:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831695; cv=none; d=google.com; s=arc-20160816; b=UNfCJZ2yTiv9nP8w/rxT7v82VAmKACrmi7FrUUeFsDoa4nC3BO3btNHHp031rY8J+t LhMgM/bz26mOmWMX+iyXdP9HSIXN9aUOuDPAhiUlmqbuRezIJxLJ8frc3WhVtXBmiM1P ozLMWphCK7QBSkVnrkPxG1ab6d7/ZpbnP7cfeTCvOZbbi6AO+tm3SIaLBLg8xywOWYcs ibz0Kt83ptds7hXYscJdNorAQlpnMld46AlE+X/YglSlqdtWtwCZYYqK+A73dlem1ugb J4GoLL9ba32Vy2Z1atgfx6Z6upWqWQo5N6ajn/kk9F5vT26RpuhgoIYuFFMNf4txXNcx 3mew== 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=eCfErP61xkg+KwgtAktEGllSgzfO9IGYobSHbErIG/w=; b=0EB9sQM5dW1QilSsu0xpqXQ/937ytj+ZOldWQQOhRAeo4aN//GpMRVSWLXYrbsUh0I KLbS38Df8mjMmYOPN6FK458CjXg/gLTg/vxxRkOLgnGedC0kY5YtZLpZ2DW/nApCuvB+ RCODNb15g5AmFtZXni7/Np6Nvarjvr31uxFfMW+7u0fPE6jHTDQ1T1J5LzIr3kNh+/jH irV3uCZDY4uZI2PHriBljX1TjlkqoW3mS9LRd9l4+qKyFGju/08fKB8pvSmJILoRVLj9 h8aHKkgJnql4+F+p8HRdqHCH6rxyrFLEJ3agHyIxUpcOpMOyNo6lLXkil35jyB9QWdtb OL3Q== 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 h16si55003758iol.156.2019.07.22.14.41.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:35 -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 1hpg2b-0002XY-9v; Mon, 22 Jul 2019 21:40:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2a-0002VI-3k for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:16 +0000 X-Inumbo-ID: 4a6588d4-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4a6588d4-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:14 +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 B071F344; Mon, 22 Jul 2019 14:40:14 -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 09D303F71F; Mon, 22 Jul 2019 14:40:13 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:33 +0100 Message-Id: <20190722213958.5761-11-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 10/35] xen/arm64: head: Improve coding style and document create_pages_tables() 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" Adjust the coding style used in the comments within create_pages_tables() Lastly, document the behavior and the main registers usage within the function. Note that x25 is now only used within the function, so it does not need to be part of the common register. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/arm64/head.S | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index ddc5167020..eddf663021 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -70,7 +70,7 @@ * x22 - is_secondary_cpu * x23 - UART address * x24 - - * x25 - identity map in place + * x25 - * x26 - skip_zero_bss (boot cpu only) * x27 - * x28 - @@ -436,16 +436,27 @@ cpu_init: ret ENDPROC(cpu_init) +/* + * Rebuild the boot pagetable's first-level entries. The structure + * is described in mm.c. + * + * After the CPU enables paging it will add the fixmap mapping + * to these page tables, however this may clash with the 1:1 + * mapping. So each CPU must rebuild the page tables here with + * the 1:1 in place. + * + * Inputs: + * x19: paddr(start) + * x20: phys offset + * + * Clobbers x0 - x4, x25 + * + * Register usage within this function: + * x25: Identity map in place + */ create_page_tables: - /* Rebuild the boot pagetable's first-level entries. The structure - * is described in mm.c. - * - * After the CPU enables paging it will add the fixmap mapping - * to these page tables, however this may clash with the 1:1 - * mapping. So each CPU must rebuild the page tables here with - * the 1:1 in place. */ - - /* If Xen is loaded at exactly XEN_VIRT_START then we don't + /* + * If Xen is loaded at exactly XEN_VIRT_START then we don't * need an additional 1:1 mapping, the virtual mapping will * suffice. */ @@ -469,7 +480,8 @@ create_page_tables: cbz x1, 1f /* It's in slot 0, map in boot_first * or boot_second later on */ - /* Level zero does not support superpage mappings, so we have + /* + * Level zero does not support superpage mappings, so we have * to use an extra first level page in which we create a 1GB mapping. */ load_paddr x2, boot_first_id From patchwork Mon Jul 22 21:39:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169460 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013623ilk; Mon, 22 Jul 2019 14:43:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzfeos3aT2Zjxd0VCjNcMA840ccI3fTzMlYVcT6WYyvwcJcdPwAtjM0ueiGiJm8iHVGtGqG X-Received: by 2002:a5d:9047:: with SMTP id v7mr42286171ioq.18.1563831696379; Mon, 22 Jul 2019 14:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831696; cv=none; d=google.com; s=arc-20160816; b=VlF5fnfeRtn8RaEb9NbXFDYTSboYhmb2bCiBDYaF5C1+MITXDEQZE1PVwzDo4ZUE8z CqO480oMYlfF1atXBps6t65rIH1Bkju7nca7OAiXNDGGl5u6OqFWuy6WPXDi/mM1KBPw SS6vNR1EckJ3v8piiSwjqg6WO9d6dpHds1AD3fJWZCpIDnu8isZtZBMvhk7b1b2H2pVS Ye0Wlwb/6An8ltaC2bBjN4CuxftRJ7ZzPQi0b1Bygcronufqiur+Cq3S28bgFptHmqNM 6S9nCFgCfUyoNchWRjIrOIR9I5dGqk5EcNc687MEIdY8YewQU1BBmi0GmSIlfaHvFZ4+ FMog== 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=8OPxW0A/IS6MGUHUFf56UwPLrf57vh6DUEOVj0lXX+U=; b=FybtCkpfAh8b2yJt5mtMks79BxRQCvWvIxx7GFgYYJYZIq0EsK4SmIYsaFlKpfNo7p EgdmP4Rm/0/2Et3nx46wry1EzbSaPa2XKjwc0ioS+UffZLLriu4+/NmQc2n/GwJ2Gw3k 8wauLkS4ZYL1ufJ0kTeOoq5UNK7BGOqsVT82Xg0q/bUi/3ES0AVZi6SgqgGqzmQxsjZy xB0pkKZ5ak7SUoRSU4zyjcRXEgvMZaPKehRpgCAvZTLCohCuU4RNmvEHZc+FM1Y8H/io zPurs3J4ZFkbCpFkN052Tj+3VzeBAZ/B1fsYrnEXv2t+tDWr5v0DN1OPqiQNBIB5S36Y yl9g== 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 h18si55248409ioj.95.2019.07.22.14.41.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:36 -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 1hpg2b-0002YF-OE; Mon, 22 Jul 2019 21:40:17 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2a-0002Vn-Br for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:16 +0000 X-Inumbo-ID: 4af6d3df-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4af6d3df-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:15 +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 974E1152F; Mon, 22 Jul 2019 14:40:15 -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 E49193F71F; Mon, 22 Jul 2019 14:40:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:34 +0100 Message-Id: <20190722213958.5761-12-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 11/35] xen/arm64: head: Document enable_mmu() 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" Document the behavior and the main registers usage within enable_mmu(). Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - x2 and x3 are also clobbers. Update the comment accordingly - s/ID/1:1/ --- xen/arch/arm/arm64/head.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index eddf663021..63563ef5e3 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -576,6 +576,13 @@ virtphys_clash: ret ENDPROC(create_page_tables) +/* + * Turn on the Data Cache and the MMU. The function will return on the 1:1 + * mapping. In other word, the caller is responsible to switch to the runtime + * mapping. + * + * Clobbers x0 - x3 + */ enable_mmu: PRINT("- Turning on paging -\r\n") From patchwork Mon Jul 22 21:39:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169459 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013558ilk; Mon, 22 Jul 2019 14:42:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqw/Vjby1X4+8RRJK/Zw57KJbKTcJpIRaKNSbpnbLhIKYzzNXcgPoTIFdvmdtEQ+F+DIPfWw X-Received: by 2002:a5d:9e48:: with SMTP id i8mr66096294ioi.51.1563831694869; Mon, 22 Jul 2019 14:41:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831694; cv=none; d=google.com; s=arc-20160816; b=je23yvsiKi63bPfpSUnnlE9rVW1kaIztzL2qYiANSzl9OKWs/fqDGkfW6dEHgHm3xd rH80qsi6Ff7k8q0MZcOD6G4DDHYKUfx/Wvu7UuC32vpXulgC8r1irtiX8xgubO+5UsEX Gjowz7RrH08Cq6xmIlRQr29Mi3xTiTc4vv3s2/QO+V/UdOkXt6L4ViHOXYp18CfHxoYb D8DzQ8nd0UM6pz1Ri83cpr10H7hE5DLYIIWJIAynaOiAu7RkQ6CRpC8suSE1WjHGYuf4 XZ7SSamjsi0wE11ZFK5AMiSYJic2pohsF+cf52X38jvUYYQX0JKZQSExwJVbmAi/L+3O DzSA== 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=Kzgd7xiUPhBTRWeugLwR+XXEPeEp1zdQoHhtO+DS2Q4=; b=AI5uOHOIYH6hYqYbgILak7xS3XvmeKJ8I+IU6AVcGzBX5bU7/AT4979veLC7Fo+Tnr YB83F3D+hHBoUBtpWAL7R+MpJSVTQx/Wgz6pn1HwujI+awhJ6gh9r2cg5vs/jtbgW00G IpDIidCRdVrwzO9PC1GunSao8oFsi97rzEhJXeFpMZ6DFihfd8jSepLRiIkfHUVCnjmH TtR3lUEb7j9vga8aKSNyfkQJVylj4FMEiLfV3Pi+pdkx8FOI3NVQEfaoIzHruDNqWayx pdR79J7/S9ftSrDInzcdyf44Y1bXec5pbFP2I5mKglv3YZJ/eDgkPno7DqZ3kWLW9OKR 9K7Q== 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 z11si61660626ioj.48.2019.07.22.14.41.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:34 -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 1hpg2d-0002bI-Eb; Mon, 22 Jul 2019 21:40:19 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2b-0002Xx-Lu for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:17 +0000 X-Inumbo-ID: 4b71e531-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4b71e531-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:16 +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 7DA151509; Mon, 22 Jul 2019 14:40:16 -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 CB7A33F71F; Mon, 22 Jul 2019 14:40:15 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:35 +0100 Message-Id: <20190722213958.5761-13-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 12/35] xen/arm64: head: Move assembly switch to the runtime PT in secondary CPUs path 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" The assembly switch to the runtime PT is only necessary for the secondary CPUs. So move the code in the secondary CPUs path. While this is definitely not compliant with the Arm Arm as we are switching between two differents set of page-tables without turning off the MMU. Turning off the MMU is impossible here as the ID map may clash with other mappings in the runtime page-tables. This will require more rework to avoid the problem. So for now add a TODO in the code. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2 - Add Stefano's acked-by --- xen/arch/arm/arm64/head.S | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 63563ef5e3..4ce4895a0d 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -344,6 +344,23 @@ GLOBAL(init_secondary) br x0 secondary_switched: bl setup_fixmap + + /* + * Non-boot CPUs need to move on to the proper pagetables, which were + * setup in init_secondary_pagetables. + * + * XXX: This is not compliant with the Arm Arm. + */ + ldr x4, =init_ttbr /* VA of TTBR0_EL2 stashed by CPU 0 */ + ldr x4, [x4] /* Actual value */ + dsb sy + msr TTBR0_EL2, x4 + dsb sy + isb + tlbi alle2 + dsb sy /* Ensure completion of TLB flush */ + isb + b launch ENDPROC(init_secondary) @@ -650,23 +667,6 @@ ENDPROC(setup_fixmap) launch: PRINT("- Ready -\r\n") - /* The boot CPU should go straight into C now */ - cbz x22, 1f - - /* Non-boot CPUs need to move on to the proper pagetables, which were - * setup in init_secondary_pagetables. */ - - ldr x4, =init_ttbr /* VA of TTBR0_EL2 stashed by CPU 0 */ - ldr x4, [x4] /* Actual value */ - dsb sy - msr TTBR0_EL2, x4 - dsb sy - isb - tlbi alle2 - dsb sy /* Ensure completion of TLB flush */ - isb - -1: ldr x0, =init_data add x0, x0, #INITINFO_stack /* Find the boot-time stack */ ldr x0, [x0] From patchwork Mon Jul 22 21:39:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169453 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012636ilk; Mon, 22 Jul 2019 14:41:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKomrvUy4UW+CwmRTTG9pnUjpWMVG/Z3yxYRy0mZKBCumWC4/GrQz7YThCMpjZwcgPhN9F X-Received: by 2002:a5d:9c46:: with SMTP id 6mr7796918iof.6.1563831701727; Mon, 22 Jul 2019 14:41:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831701; cv=none; d=google.com; s=arc-20160816; b=hr1K6KtSpKwvs91IpPb/HBqLC9q2D6ldzW1ELtvkcRwcRS717KsKBu9NB72ZouvmIW 8B2p8saY76cDo5ssBCNU6lq9exUX8jvKiJwH93cbnYYNe3Yc3r+DXAOZju2kucKNX7mj nXzsqAmnTl9wiabGMaIJDF9smFSZRwPM1zG6h7MKsXkyu0HXw+jVvLIftvXjgfavGeIi hw6dG2kx0zvcZt9Qvo4yrIl/HomKjyp6782FOp1wxGimfq3HAbFr8EO8L3XwMMSYXa0W 5/lzv7pdDZOQQtTbUJiQsvFsEF9UNaUBxQZNihYkW0rzBzEUZujgo/ENwAzJBNSN8/MW 5Obw== 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=eehCvmI7FD6bzmNDzHFAXWZ07IalZxjsvxtVD3zE2/I=; b=JaLOvTId+HJ8naJSXLkZJ1y0da0INLBn4Ym47Jw/XeWdOReZUfTX44MghaixlxeUP+ ozyBzDEnS74x0bUAtPECVne7gcSKuVJAbl2H+spSntnmnEETIEiXB/lfIUz/QrXULt37 o3tqmXqwvjWdRNrZ6bpl2UjOEH/vQEm+4LcfA1uCcs3CA1h0RVhRtcrQhCvC1nEaNU+j JJsrt3nyrqCSQjmbxG1K5hQmGneEGZihpOZi/CR3Ky1acGN4EgpxqzUqnrbrxzM35OhU i5GzjyPNhkhzWXdFiS52tSGU2QFg2fKv7M8zeco2natAv12cWMgOzkK1yCOkMSTQzOkt GGkQ== 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 r1si68198599jac.1.2019.07.22.14.41.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:41 -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 1hpg2e-0002db-Pm; Mon, 22 Jul 2019 21:40:20 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2c-0002aX-W2 for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:19 +0000 X-Inumbo-ID: 4c0bbbe4-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4c0bbbe4-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:17 +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 7F340153B; Mon, 22 Jul 2019 14:40:17 -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 B1ECC3F71F; Mon, 22 Jul 2019 14:40:16 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:36 +0100 Message-Id: <20190722213958.5761-14-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 13/35] xen/arm64: head: Don't setup the fixmap on 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk , Stefano Stabellini MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" setup_fixmap() will setup the fixmap in the boot page tables in order to use earlyprintk and also update the register x23 holding the address to the UART. However, secondary CPUs are not using earlyprintk between turning the MMU on and switching to the runtime page table. So setting up the fixmap in the boot pages table is pointless. This means most of setup_fixmap() is not necessary for the secondary CPUs. The update of UART address is now moved out of setup_fixmap() and duplicated in the CPU boot and secondary CPUs boot. Additionally, the call to setup_fixmap() is removed from secondary CPUs boot. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Fix typo - Clarify the commit message - Add Stefano's reviewed-by --- xen/arch/arm/arm64/head.S | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 4ce4895a0d..28efe9230c 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -301,6 +301,10 @@ real_start_efi: br x0 primary_switched: bl setup_fixmap +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS +#endif b launch ENDPROC(real_start) @@ -343,8 +347,6 @@ GLOBAL(init_secondary) ldr x0, =secondary_switched br x0 secondary_switched: - bl setup_fixmap - /* * Non-boot CPUs need to move on to the proper pagetables, which were * setup in init_secondary_pagetables. @@ -361,6 +363,10 @@ secondary_switched: dsb sy /* Ensure completion of TLB flush */ isb +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + ldr x23, =EARLY_UART_VIRTUAL_ADDRESS +#endif b launch ENDPROC(init_secondary) @@ -624,10 +630,6 @@ setup_fixmap: * don't need the 1:1 map any more */ dsb sy #if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ - /* Non-boot CPUs don't need to rebuild the fixmap itself, just - * the mapping from boot_second to xen_fixmap */ - cbnz x22, 1f - /* Add UART to the fixmap table */ ldr x1, =xen_fixmap /* x1 := vaddr (xen_fixmap) */ lsr x2, x23, #THIRD_SHIFT @@ -635,7 +637,6 @@ setup_fixmap: mov x3, #PT_DEV_L3 orr x2, x2, x3 /* x2 := 4K dev map including UART */ str x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */ -1: /* Map fixmap into boot_second */ ldr x4, =boot_second /* x4 := vaddr (boot_second) */ @@ -645,9 +646,6 @@ setup_fixmap: ldr x1, =FIXMAP_ADDR(0) lsr x1, x1, #(SECOND_SHIFT - 3) /* x1 := Slot for FIXMAP(0) */ str x2, [x4, x1] /* Map it in the fixmap's slot */ - - /* Use a virtual address to access the UART. */ - ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif /* From patchwork Mon Jul 22 21:39:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169430 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012220ilk; Mon, 22 Jul 2019 14:41:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVcXWx0TX0IghqolrLxmUaQD5Z/n055j4rICt4zQpR2zyLEv6fYKgYqGFLiEM16MYPc/oB X-Received: by 2002:a6b:6209:: with SMTP id f9mr20581161iog.236.1563831673499; Mon, 22 Jul 2019 14:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831673; cv=none; d=google.com; s=arc-20160816; b=D3LbCFHgyBkkxTqrC0IlSvSUgV0xic9wTemeLNd+QQ+exT3KfqZrryj3Ma2wmpjDKr jWpzGlO5SjqtDtdf9rWsszZ8c0FwLRshUTqzXqFRvxxf66P6iWYED5f+NnZlDSaMSkLs bOzuog8tEktdpfRj28qqXGEj94ZP5f7UOGRnlbZSyKu2wvW0UU8z+GZvqVXi+HP+P7sx z6noQE9NVHxFVPx9eA1aX6SHVP/wLP/tgcbDhMJmnVQe75g9jZHCiTCKYzV7MAjdcvjU AmRGBpbZ22fgOvdE2AzMxcM+XZMAOBXCR6jrqCU2iRMlB+WAySLPTMWaqaJZZhLSo5Ki r/4Q== 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=7fOcB2fgd8FvfoM+GvA+rkasHIWwyc8Ng+b4nOYhoys=; b=t1BlJxN36jbHRLST2saUeCyvRk0Gt6VMJD7q/kdt2cO7qEI1uiuo/vYUyDY01eCo5j 1uA07KaMhcT/UWFPVWgpnMyKQSwuOLltsgfqaoPV0jdy401JQRQeUy30Q6lRhiuMJLJm g/q+uD5qXOvVpX4EWkIegnVD7SpnzHQWHx4cVIUVX/8GraFxQ9gtkCE0LZ9ZnSuGj/I2 8oEWTMNsTMDWWlnO80mWB6Q8w3nq7hSK0xWzjo3uCn6EFI02HaA3c8I+7p7pXnzwSOVS QayM/67qUGMiaf8wUSbv10Qx2rxZDuvtitHwc3KQHgBDnzXmiaByUxDX5L5SWr/DIed+ Hjgg== 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 q3si52400463ioj.22.2019.07.22.14.41.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:13 -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-0002fo-7J; 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 1hpg2e-0002cl-AS for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:20 +0000 X-Inumbo-ID: 4ca084c8-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4ca084c8-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:18 +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 6568F1595; Mon, 22 Jul 2019 14:40:18 -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 B34B13F71F; Mon, 22 Jul 2019 14:40:17 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:37 +0100 Message-Id: <20190722213958.5761-15-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 14/35] xen/arm64: head: Remove 1:1 mapping as soon as it is not used 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" The 1:1 mapping may clash with other parts of the Xen virtual memory layout. At the moment, Xen is handling the clash by only creating a mapping to the runtime virtual address before enabling the MMU. The rest of the mappings (such as the fixmap) will be mapped after the MMU is enabled. However, the code doing the mapping is not safe as it replace mapping without using the Break-Before-Make sequence. As the 1:1 mapping can be anywhere in the memory, it is easier to remove all the entries added as soon as the 1:1 mapping is not used rather than adding the Break-Before-Make sequence everywhere. It is difficult to track where exactly the 1:1 mapping was created without a full rework of create_page_tables(). Instead, introduce a new function remove_identity_mapping() will look where is the top-level entry for the 1:1 mapping and remove it. The new function is only called for the boot CPU. Secondary CPUs will switch directly to the runtime page-tables so there are no need to remove the 1:1 mapping. Note that this still doesn't make the Secondary CPUs path safe but it is not making it worst. Signed-off-by: Julien Grall --- It is very likely we will need to re-introduce the 1:1 mapping to cater secondary CPUs boot and suspend/resume. For now, the attempt is to make boot CPU path fully Arm Arm compliant. Changes in v2: - s/ID map/1:1 mapping/ - Rename remove_id_map() to remove_identity_mapping() - Add missing signed-off-by --- xen/arch/arm/arm64/head.S | 86 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 15 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 28efe9230c..a607b3bdb1 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -300,6 +300,13 @@ real_start_efi: ldr x0, =primary_switched br x0 primary_switched: + /* + * The 1:1 map may clash with other parts of the Xen virtual memory + * layout. As it is not used anymore, remove it completely to + * avoid having to worry about replacing existing mapping + * afterwards. + */ + bl remove_identity_mapping bl setup_fixmap #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ @@ -625,10 +632,68 @@ enable_mmu: ret ENDPROC(enable_mmu) +/* + * Remove the 1:1 map for the page-tables. It is not easy to keep track + * where the 1:1 map was mapped, so we will look for the top-level entry + * exclusive to the 1:1 map and remove it. + * + * Inputs: + * x19: paddr(start) + * + * Clobbers x0 - x1 + */ +remove_identity_mapping: + /* + * Find the zeroeth slot used. Remove the entry from zeroeth + * table if the slot is not 0. For slot 0, the 1:1 mapping was either + * done in first or second table. + */ + lsr x1, x19, #ZEROETH_SHIFT /* x1 := zeroeth slot */ + cbz x1, 1f + /* It is not in slot 0, remove the entry */ + ldr x0, =boot_pgtable /* x0 := root table */ + str xzr, [x0, x1, lsl #3] + b identity_mapping_removed + +1: + /* + * Find the first slot used. Remove the entry for the first + * table if the slot is not 0. For slot 0, the 1:1 mapping was + * done in the second table. + */ + lsr x1, x19, #FIRST_SHIFT + and x1, x1, #LPAE_ENTRY_MASK /* x1 := first slot */ + cbz x1, 1f + /* It is not in slot 0, remove the entry */ + ldr x0, =boot_first /* x0 := first table */ + str xzr, [x0, x1, lsl #3] + b identity_mapping_removed + +1: + /* + * Find the second slot used. Remove the entry for the first + * table if the slot is not 1 (runtime Xen mapping is 2M - 4M). + * For slot 1, it means the 1:1 mapping was not created. + */ + lsr x1, x19, #SECOND_SHIFT + and x1, x1, #LPAE_ENTRY_MASK /* x1 := first slot */ + cmp x1, #1 + beq identity_mapping_removed + /* It is not in slot 1, remove the entry */ + ldr x0, =boot_second /* x0 := second table */ + str xzr, [x0, x1, lsl #3] + +identity_mapping_removed: + /* See asm-arm/arm64/flushtlb.h for the explanation of the sequence. */ + dsb nshst + tlbi alle2 + dsb nsh + isb + + ret +ENDPROC(remove_identity_mapping) + setup_fixmap: - /* Now we can install the fixmap and dtb mappings, since we - * don't need the 1:1 map any more */ - dsb sy #if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ /* Add UART to the fixmap table */ ldr x1, =xen_fixmap /* x1 := vaddr (xen_fixmap) */ @@ -646,19 +711,10 @@ setup_fixmap: ldr x1, =FIXMAP_ADDR(0) lsr x1, x1, #(SECOND_SHIFT - 3) /* x1 := Slot for FIXMAP(0) */ str x2, [x4, x1] /* Map it in the fixmap's slot */ -#endif - /* - * Flush the TLB in case the 1:1 mapping happens to clash with - * the virtual addresses used by the fixmap or DTB. - */ - dsb sy /* Ensure any page table updates made above - * have occurred. */ - - isb - tlbi alle2 - dsb sy /* Ensure completion of TLB flush */ - isb + /* Ensure any page table updates made above have occurred. */ + dsb nshst +#endif ret ENDPROC(setup_fixmap) From patchwork Mon Jul 22 21:39:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169454 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012242ilk; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzO/GumzElyB/RGyuanUoQqdXE7V9+jg4aIGgi10ShZg02Z3ABcpWP2NkoUsYPkA2B40pGu X-Received: by 2002:a5d:948f:: with SMTP id v15mr51905299ioj.93.1563831674779; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831674; cv=none; d=google.com; s=arc-20160816; b=pjiXu2o7HQP0+qA+vhjja8vfwE9NdPudgiXA/dKiVuKPHkpDOAkk3RpO8D8/5kDicj R49A9bOpH0hGsjO1/UII97leabpC7cBiFMYMvTazM17gWRmuLjD1h+crnpYad/leyJH8 Me6biuO6AJNJ19bYmH+C5soowVsnKHjXpFAfSsnxIUgtQtd/j3KlcRBTtEDEg3klDF9o YmuWNTQpd6EhKdFmqD8u0vjqmLRw3amPRDOiCck06RL/PXzU9dKVmiy6xvH28sJXqb4S CWjZPd5NL1MghgRo+luA3Hp+t8jfGEVV3gb6pjbuENpX217GV4HYmau9K0yR/TZ1sMrk yK3w== 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=SUdgnjKljTfOn2ms0FQyKn9fCxKNdfk6/roCe8b+CL0=; b=VtsrXuhihAhguoiZ/Y1hI+rcO89fGmf7fH7GiGqVojKiFtTj924xd9jBTEhUzdhQdN eU2jsRtrZ/8h9me+yjPji3sDyypIfFcYe7M2zWQMrf8tJxXbGtTfmamL6v+P7cMBz+d9 bZK+/mB0PugEN+QJGRr6pZgOVusr8T0RM6af26hFRmN0nuHO+uvZP/ns5v6bFUnxyRnd Zy2ST3ElCmmVm7Vr+zsJB3vj7EAiPfxZ2BGDp4m91205kI+I58Ck7uGQF16SpcDoArGL JGVxtWtEkjCDDFNr3RyNgrW0FHiv0NYv547ke6FnOeTOhfxXWEQGsgh2pFlG9k26VhNc n7pA== 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 r19si53641842iom.118.2019.07.22.14.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:14 -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 1hpg2i-0002ju-67; Mon, 22 Jul 2019 21:40:24 +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 1hpg2g-0002fp-9W for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:22 +0000 X-Inumbo-ID: 4d2341ec-acc9-11e9-bcc2-f3c6d6cef6ca Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 4d2341ec-acc9-11e9-bcc2-f3c6d6cef6ca; Mon, 22 Jul 2019 21:40:19 +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 4B8251509; Mon, 22 Jul 2019 14:40:19 -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 9951C3F71F; Mon, 22 Jul 2019 14:40:18 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:38 +0100 Message-Id: <20190722213958.5761-16-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 15/35] xen/arm64: head: Rework and document setup_fixmap() 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" At the moment, the fixmap table is only hooked when earlyprintk is used. This is fine today because in C land, the fixmap is not used by anyone until the the boot CPU is switching to the runtime page-tables. In the future, the boot CPU will not switch between page-tables to avoid TLB incoherency. Thus, the fixmap table will need to be always hooked beofre any use. Let's start doing it now in setup_fixmap(). Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2: - Update the comment to reflect that we clobbers x1 - x4 and not x0 - x1. - Add the list of input registers - s/ID map/1:1 mapping/ - Reword the commit message --- xen/arch/arm/arm64/head.S | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index a607b3bdb1..f165dd61ca 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -693,8 +693,21 @@ identity_mapping_removed: ret ENDPROC(remove_identity_mapping) +/* + * Map the UART in the fixmap (when earlyprintk is used) and hook the + * fixmap table in the page tables. + * + * The fixmap cannot be mapped in create_page_tables because it may + * clash with the 1:1 mapping. + * + * Inputs: + * x20: Physical offset + * x23: Early UART base physical address + * + * Clobbers x1 - x4 + */ setup_fixmap: -#if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ +#ifdef CONFIG_EARLY_PRINTK /* Add UART to the fixmap table */ ldr x1, =xen_fixmap /* x1 := vaddr (xen_fixmap) */ lsr x2, x23, #THIRD_SHIFT @@ -702,6 +715,7 @@ setup_fixmap: mov x3, #PT_DEV_L3 orr x2, x2, x3 /* x2 := 4K dev map including UART */ str x2, [x1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */ +#endif /* Map fixmap into boot_second */ ldr x4, =boot_second /* x4 := vaddr (boot_second) */ @@ -714,7 +728,7 @@ setup_fixmap: /* Ensure any page table updates made above have occurred. */ dsb nshst -#endif + ret ENDPROC(setup_fixmap) 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 */ From patchwork Mon Jul 22 21:39:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169431 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012226ilk; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwry00pS9lKZ8R95L5mrzblZi1KwV2y6AruRcb9ad1kNpXA/32luVJT6hbnMF3YnKrj7lf1 X-Received: by 2002:a5d:8702:: with SMTP id u2mr47649197iom.228.1563831673984; Mon, 22 Jul 2019 14:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831673; cv=none; d=google.com; s=arc-20160816; b=f9CwNrKMMCGXilBPYl8oFTR1GztA/YZX5zhCTwx1yEsPkv6f34O6Rlug2ooq594Gy2 ijuPe8FZXiAp4j1ad3uz6awMx39e0bCtVSlF8gK47s6eJJauww7OYcrqWD91L+RvCPYu lhW4fwaFDVoHqdQxYOAL8E0DTWlN8UrInRJwy0rwVQNHgfN+ueaEVxkWleonPiRNU017 M88+CPRSfbJaHLMrIo3VVfdZ3+3+2pF244TtoSySCd10RztarYEjTKoJc0jLjXU8c+cN cdWP7SYs57RE2GcgmugDZ3xu+b06Kn5Q3mREJ660E4H7BsBebccmxNeJ9S0QjzG3Np4i Jcwg== 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=Fq2xlel87S8Imm8bTNTicoaUUMaq/Y8HAXt1qXlwj3Y=; b=kAFKzfoCYgO/m5pCTALDzWkXWBLzA2IVpagwckfbsgJY4nXvW+Ir3zrVHonKVNpDdx MGl2+lOrgsH2PD2Z7YDeft6uq5SouoYqxX7ca4RVNmJmEHZvTOai8lwKKA2aMS7t+rU6 DbLyPjDRou0XDcFCcC3KkbnAkJsA0wcMuHRiF/e5cpcBwfPwgAltM0rQMa17wUZVEHu3 gANHzjz/f1Hv+c56EsgNPLDx3U0UGua0SDrBoKwKJ67Xn7V5dWOx6CTz3DusW/55bWY5 x/ZBbHZt+Iml87JBn1xJVSwZc1ScicMAqPk1UuC3zbvN3DJBWd7rGLqGh8USk2udqUQQ RypA== 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 l17si51676080iom.138.2019.07.22.14.41.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:13 -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 1hpg2h-0002iY-Hc; Mon, 22 Jul 2019 21:40:23 +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-0002fA-R2 for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:21 +0000 X-Inumbo-ID: 4e2d3518-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4e2d3518-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:21 +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 17CDB15A1; Mon, 22 Jul 2019 14:40:21 -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 65BE73F71F; Mon, 22 Jul 2019 14:40:20 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:40 +0100 Message-Id: <20190722213958.5761-18-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 17/35] xen/arm64: head: Setup TTBR_EL2 in enable_mmu() and add missing isb 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" At the moment, TTBR_EL2 is setup in create_page_tables(). This is fine as it is called by every CPUs. However, such assumption may not hold in the future. To make change easier, the TTBR_EL2 is not setup in enable_mmu(). Take the opportunity to add the missing isb() to ensure the TTBR_EL2 is seen before the MMU is turned on. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm64/head.S | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 7541635102..9afd89d447 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -501,9 +501,7 @@ create_page_tables: cmp x19, #XEN_VIRT_START cset x25, eq /* x25 := identity map in place, or not */ - /* Write Xen's PT's paddr into TTBR0_EL2 */ load_paddr x4, boot_pgtable - msr TTBR0_EL2, x4 /* Setup boot_pgtable: */ load_paddr x1, boot_first @@ -631,6 +629,11 @@ enable_mmu: tlbi alle2 /* Flush hypervisor TLBs */ dsb nsh + /* Write Xen's PT's paddr into TTBR0_EL2 */ + load_paddr x0, boot_pgtable + msr TTBR0_EL2, x0 + isb + mrs x0, SCTLR_EL2 orr x0, x0, #SCTLR_Axx_ELx_M /* Enable MMU */ orr x0, x0, #SCTLR_Axx_ELx_C /* Enable D-cache */ From patchwork Mon Jul 22 21:39:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169432 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012230ilk; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS3CytD58dWQuXl1WLwcWGJFSdGohMW13sPxgtJmLx6e6HY3I0q22nt//LdmEnXCeUFufI X-Received: by 2002:a02:8814:: with SMTP id r20mr78582871jai.115.1563831674322; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831674; cv=none; d=google.com; s=arc-20160816; b=evRp61slAMarBRJafD1aSmszXI+wLVAtTmZ9aiD0fszE2BjNKxBiVJW1P5eXLkVWlk N+lQ/gAZfN+rkeq+WSAgAmHRd8EFjE6vx6ROXbtBdyK4cAsC1TvwdNCI7hqGqxLgCak2 zC4hOcsAQgEOPwsD01MxMdz5nTFDzwdHMg4clFGAh5Wh9T+egaPArA5IEfbmETnNvrVR ll56uWVShZksqMYHiyAZ/rOtpOPSkA4+qOzyFtN1Ii1Er9fQEytDfHDHoztOeNZgtt7Z ISQMauuGCZiwiMQTxCAD52VCY3IEIGVN8mVfW2GJOVNhFuFzHcbvZmm3XpiiULSgUOL1 3K8Q== 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=lyf46eoSzFBwiYqEBGeGYOcn5xdUw2+pj7rBwmcMRPc=; b=xUjBv1j0hUUpwbvv9I8pOfxNcW7uMvILtpkZVA3EwEEozsNR6wnernG0h1nskGoKMU N7DuGVky2XbI7h7T+7pu5h3df8r8yg8Bl9+Nvm6ttwgai9dluaCmDDq6d2B/1s6wQBrs be+nNe9z5WTTjt6otxV2vHCHIecz1+H1I2VVUM2Kcgbmd1tB+HyFKWpJzZVt7wmgcvCK 2LaDYUk/4YT1rLIhKYC1VEPLRLx0lFWmSKogTilwenJqkXV9K3jmJRn8N3I3oqyxbKZS IxsKw4UqwTOpn6p5HEH3kOy15V8mxqWDAk5iAZTjZzmXEWCFPemqJkX7Td20br86xnc0 DAPg== 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 n26si374643ioh.135.2019.07.22.14.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:14 -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 1hpg2i-0002l9-Qt; Mon, 22 Jul 2019 21:40:24 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2h-0002he-5u for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:23 +0000 X-Inumbo-ID: 4edd0f0b-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4edd0f0b-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:22 +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 18CA7344; Mon, 22 Jul 2019 14:40:22 -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 4BCDC3F71F; Mon, 22 Jul 2019 14:40:21 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:41 +0100 Message-Id: <20190722213958.5761-19-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 18/35] xen/arm64: head: Introduce a macro to get a PC-relative address of a symbol 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" Arm64 provides instructions to load a PC-relative address, but with some limitations: - adr is enable to cope with +/-1MB - adrp is enale to cope with +/-4GB but relative to a 4KB page address Because of that, the code requires to use 2 instructions to load any Xen symbol. To make the code more obvious, introducing a new macro adr_l is introduced. The new macro is used to replace a couple of open-coded use in efi_xen_start. The macro is copied from Linux 5.2-rc4. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm64/head.S | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 9afd89d447..2287f3ce48 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -111,6 +111,18 @@ #endif /* !CONFIG_EARLY_PRINTK */ +/* + * Pseudo-op for PC relative adr , where is + * within the range +/- 4GB of the PC. + * + * @dst: destination register (64 bit wide) + * @sym: name of the symbol + */ +.macro adr_l, dst, sym + adrp \dst, \sym + add \dst, \dst, :lo12:\sym +.endm + /* Load the physical address of a symbol into xb */ .macro load_paddr xb, sym ldr \xb, =\sym @@ -886,11 +898,9 @@ ENTRY(efi_xen_start) * Flush dcache covering current runtime addresses * of xen text/data. Then flush all of icache. */ - adrp x1, _start - add x1, x1, #:lo12:_start + adr_l x1, _start mov x0, x1 - adrp x2, _end - add x2, x2, #:lo12:_end + adr_l x2, _end sub x1, x2, x1 bl __flush_dcache_area From patchwork Mon Jul 22 21:39:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169434 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012266ilk; Mon, 22 Jul 2019 14:41:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWhFyUBycVmVh7vSW1A/f0p4BHsJmntfUfXaqiXAGPAClR5/g+3kh1Jwi3t5qPxhcKBiQe X-Received: by 2002:a6b:cf17:: with SMTP id o23mr38120375ioa.176.1563831676260; Mon, 22 Jul 2019 14:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831676; cv=none; d=google.com; s=arc-20160816; b=FDMToj7JKynRO5d0ocuupufnryabUndm0LzRRigdkFAiVZ/Oz4MW+ioHQKmCoHQtl0 6SHMZAQV7WAnImvCcYcV0CMFxy74Nudw/5ZTZ8A0IEhqt9tntEzT7pCUmLqortKSRf/0 fiFEDyetOhShFZbth0TFxF1agIwfx3dY6r3ZDXJK24ra3enrRoLk/OqmzzsBiZpX1Ui+ Huj/b5iMh3ecC4KSdgJ4myYqBMnzE5H2lJsujwCa9U/3GoCioaLKq2rTAtaiA3Z+88HZ yQYMAuScnji231vKD9rXAx4FMByHHKtCKytfxAHp9HfO5jdjDFH30sdkKL/DTfgA06jH TZfA== 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=N/mkECePx+dyIk5o6eTTqhk6Px2Y11dr+ZLL9RcjMsc=; b=we29OqjVge5WDI8rChAjDexc8dvaySMzlkPRa/a1ux7OkEawOpmUi+8vmUthZyyqJ+ RVpmfKaytIZ70VKYnwSKNUWYX6i3W3zbT6yx8OHBVszEE0Z33xng+O2xMqsnq6WDMLnA Xw4YIN9PjRCXzDynmal+7KAPGekJx2yf5dkBk9wmXbNzXbOCwNhPbGXqYyFHY/NV+HJm qMe98qaWVA/NfZ46AMrMIfBohNb+yaMso8UkoWpzEr/oCbkaNqX+Sjgc+dJEYYWsfgjM hufxeInhya5Cg0hZtehbS8pIKXGKVTVvZdmtm2r5KkMZCNVQqhTS3+WjR5AlTBhrfR7u afTg== 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 h23si58323038jam.120.2019.07.22.14.41.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:16 -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 1hpg2j-0002nT-S6; Mon, 22 Jul 2019 21:40:25 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2i-0002jm-5e for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:24 +0000 X-Inumbo-ID: 4f58cf37-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 4f58cf37-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:23 +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 F3E3A152F; Mon, 22 Jul 2019 14:40:22 -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 4CC763F71F; Mon, 22 Jul 2019 14:40:22 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:42 +0100 Message-Id: <20190722213958.5761-20-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 19/35] xen/arm32: head: Add a macro to move an immediate constant into a 32-bit register 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" The current boot code is using the pattern ldr rX, =... to move an immediate constant into a 32-bit register. This pattern implies to load the immediate constant from a literal pool, meaning a memory access will be performed. The memory access can be avoided by using movw/movt instructions. A new macro is introduced to move an immediate constant into a 32-bit register without a memory load. Follow-up patches will make use of it. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 18ded49a04..99f4af18d8 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -37,6 +37,15 @@ #endif /* + * Move an immediate constant into a 32-bit register using movw/movt + * instructions. + */ +.macro mov_w reg, word + movw \reg, #:lower16:\word + movt \reg, #:upper16:\word +.endm + +/* * Common register usage in this file: * r0 - * r1 - From patchwork Mon Jul 22 21:39:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169455 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012245ilk; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFL+iA8MALMnvorHzQ2UHXEyK5Yc04JqU2jywToIVMi2CaCHZ2PlAdZ25k3FFSKFPaVNJn X-Received: by 2002:a6b:6e01:: with SMTP id d1mr19080969ioh.156.1563831674943; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831674; cv=none; d=google.com; s=arc-20160816; b=s/L7cafUkjoGoZL3gLe00bEnhiOqbUbcl5Jc6sQ7YKL50P5/Xd3P8mQ2jX449Lcd6u YaFuXK6LWi8i3Ia06i6r8mcELqBoxTIwEFXsA1DGEw49QHjH49lipf/KNaTtsxacdT9G AmBOlVJK/pw6v0SA2qnIA4fYYrz7dULxPknqDlnlWbDQRAVf7GvZ/VXSeg6NGeut/WWY qnaE677puZQc2STLx5B6m60kXUnjQ4S6t+CoDhwYfgkEtBqhYeiEvyrxNrFriVaZ5T5U 2VmJU9xRW26OQyFhVMP0R46NULohYrUe7SY5GARvYqKLEFZnEMsb44wT7L7kfvEkl1xK Tz6g== 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=uE0U4tIPa/wl76MUVMVIbp0DjOL0X4F7azW2iE4VePA=; b=QGrud45U5xEtlleL4K0VmE29kvLax43HQWXIw4H9uH9ZyqT+jRQps8lRmdbiynLVV+ 5Q3Ca7TUrNM4bx/D7YwyFDBKol0jITKfVFda7vNl6A6w6ymqye5vppmZci98YeUWcE1p RC2NNzOEgD/YhU/c+b6kZJ1OkHIj96G+EoLeGmr8y6Ht1TDQ3+sLx+ufdgox3jclMNy3 fMk2oC65eS+YICoWLoiLf5A/0ro77Oil9URN639PuI/ZTQcS19OzVud4v/3M0NibO8yJ hPcx6rvI03LNh1+fhqkHQFC8Y9QLqbAwwwJZbDk9EQx4xBB/EM3TsAnNvR6MuWO952V3 O4fg== 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 190si64345448jau.63.2019.07.22.14.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:14 -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 1hpg2l-0002rY-KB; Mon, 22 Jul 2019 21:40:27 +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 1hpg2k-0002ox-Hh for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:26 +0000 X-Inumbo-ID: 4ff350d8-acc9-11e9-ab9d-9ba8a994a9dd Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 4ff350d8-acc9-11e9-ab9d-9ba8a994a9dd; Mon, 22 Jul 2019 21:40:24 +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 D901F1509; Mon, 22 Jul 2019 14:40:23 -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 32BBC3F71F; Mon, 22 Jul 2019 14:40:23 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:43 +0100 Message-Id: <20190722213958.5761-21-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 20/35] xen/arm32: head: Mark the end of subroutines with ENDPROC 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" putn() and puts() are two subroutines. Add ENDPROC for the benefits of static analysis tools and the reader. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 99f4af18d8..8b4c8a4714 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -518,6 +518,7 @@ puts: moveq pc, lr early_uart_transmit r11, r1 b puts +ENDPROC(puts) /* * Print a 32-bit number in hex. Specific to the PL011 UART. @@ -537,6 +538,7 @@ putn: subs r3, r3, #1 bne 1b mov pc, lr +ENDPROC(putn) hex: .ascii "0123456789abcdef" .align 2 From patchwork Mon Jul 22 21:39:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169456 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012249ilk; Mon, 22 Jul 2019 14:41:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOC5JhR45CkSZ2ECG4QL+TuBmIm9auzsZzA859EF2Gc2iMZ4zg65PE8VBRZ0EdlrhRRWdv X-Received: by 2002:a05:6602:2183:: with SMTP id b3mr55321626iob.249.1563831675197; Mon, 22 Jul 2019 14:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831675; cv=none; d=google.com; s=arc-20160816; b=vJ/lRM2nnyAag3ijBHsWVxcmLGbnQZxNzD52wllBH3V6kXX5FkCmgrgeJvQcyA86aO Cv15+4VmQK9K3FRZQqW8NOCY9y4mpF15bp7Dja3BJtglrPWjerKYzCp3G2EOc2R9mTGD peNTaHz9P5rnHPndBY5/fC75VUVZsFWoCSt2Xl14FBCs7G+5Y6E4BYIxs/S9RghbR9oq v4QGqIN90YeMGHcuMRB4lvCuM4OLRiweaiDGnb1xmOPmSP+q0nr/LTPu7Sp3Mwcz5bxi b2A8dQGaNIfAwEbT5R6RF3xY6njla1H4gZPWLZM8NBmGHENG0VBJBhO0NbuR6Iqe/4kz PhFQ== 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=UUevUdp6663+V64p5ViS4lTYYpQ/2TG2qVa8paPbxOo=; b=OPVmKQ2oli0GgMe9sHBnDbfs9F7eQbUuvsT+4TtBoIGtV0ycxDM+GZb8b5RCWTrFYe fc7Rec+fzwwxw85ehosFXlFxeuIrBAl4J3hLHjGOn+5BqXlZYqNdl29DuXP910EqX63V yoVcRSMSxuwIp79tTPbm4DVVZiwhaDNQj7iYiG9hbg3wd09CWArN6JMchqAaZqR7j/nY mRxoi5jdg6rHEGUHy0MBvgeLZLogUhrYrmQ6g7pnqAEp54aRy7l2LWLEtx6zwIqHP4WS OERK3gk9CKt1LT34tC/fZ5YEAanWtnW1DIIkNc2bxcJVwD5FTxZk5vXNDHZ0E5Uu7AV1 VcRQ== 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 c23si52708150iob.102.2019.07.22.14.41.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:15 -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 1hpg2o-0002x2-6q; Mon, 22 Jul 2019 21:40:30 +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 1hpg2k-0002pV-Pe for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:26 +0000 X-Inumbo-ID: 50767792-acc9-11e9-8a0f-579bf927f4ca Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 50767792-acc9-11e9-8a0f-579bf927f4ca; Mon, 22 Jul 2019 21:40:25 +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 BEDBC153B; Mon, 22 Jul 2019 14:40:24 -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 18C523F71F; Mon, 22 Jul 2019 14:40:23 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:44 +0100 Message-Id: <20190722213958.5761-22-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 21/35] xen/arm32: head: Don't clobber r14/lr in the macro PRINT 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" The current implementation of the macro PRINT will clobber r14/lr. This means the user should save r14 if it cares about it. Follow-up patches will introduce more use of PRINT in places where lr should be preserved. Rather than requiring all the user to preserve lr, the macro PRINT is modified to save and restore it. While the comment state r3 will be clobbered, this is not the case. So PRINT will use r3 to preserve lr. Lastly, take the opportunity to move the comment on top of PRINT and use PRINT in init_uart. Both changes will be helpful in a follow-up patch. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 8b4c8a4714..b54331c19d 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -64,15 +64,20 @@ * r14 - LR * r15 - PC */ -/* Macro to print a string to the UART, if there is one. - * Clobbers r0-r3. */ #ifdef CONFIG_EARLY_PRINTK -#define PRINT(_s) \ - adr r0, 98f ; \ - bl puts ; \ - b 99f ; \ -98: .asciz _s ; \ - .align 2 ; \ +/* + * Macro to print a string to the UART, if there is one. + * + * Clobbers r0 - r3 + */ +#define PRINT(_s) \ + mov r3, lr ;\ + adr r0, 98f ;\ + bl puts ;\ + mov lr, r3 ;\ + b 99f ;\ +98: .asciz _s ;\ + .align 2 ;\ 99: #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) @@ -500,10 +505,8 @@ init_uart: #ifdef EARLY_PRINTK_INIT_UART early_uart_init r11, r1, r2 #endif - adr r0, 1f - b puts /* Jump to puts */ -1: .asciz "- UART enabled -\r\n" - .align 4 + PRINT("- UART enabled -\r\n") + mov pc, lr /* * Print early debug messages. From patchwork Mon Jul 22 21:39:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169433 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012236ilk; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/79JGyP1nQni1IuOF47+sbdyhKEsGWlxUADWYasdWsktMO9IpcaEiek0aupOzQoGpLWeL X-Received: by 2002:a6b:8f0d:: with SMTP id r13mr2889136iod.121.1563831674545; Mon, 22 Jul 2019 14:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831674; cv=none; d=google.com; s=arc-20160816; b=UA4VMZ3SIGSTDNv4+CdNQirW1XM0eYrF4Nu5NqXGh46xjj/waoeIvK/9hkCtrjf11k dbzzrJYa4M+8pnrRsmWzO2hRopb6JYOK+70OTREcY17AuPWvmKyrEaYF7MqBPv4YZYZ+ 3Q7XwunCq1pKe/dGFiiXqMRhGmeMIIM7iF8EhaN83TfYk46ddEIsVagXmeAV5Wmag6t2 XhSlQA01nCNAc+/zTELA0fEAdalgIixIlwWECrIDzbW6tvXVU4rQW1dZ09Pf4cQrlW0C 318PTgg1H1z4WdnVISPAff9+x8fPKwo6BCSyjURlQCQz1SZtaGKfuEaaFMmB0YWydubq zjNA== 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=+mYp/B4PHuoR0JK4WtVjv2Khlo9tsNUdNdQ7UqIu3ug=; b=0aY3lYoBKluESWfdo0a9FSir3OHXTSwqnitir0tuny1OFUHrFQt3f/pdn1K9VGJQ+j a8SX0N9E2zmtai9A1HdiTjIEPS5gJr/Bz5AYKMMLnIjypdYlOzzxummR0m/43FvjWR2B tF162NRNeJRtm6U9m++fKD1fHVLgxnc7Tr9fH9AHrupEpK6pKhgWgyNRmo0YsVUm9d45 rqdjVClfHrz6/93di/hZVwYuihxB7jDQ0R8X03TBh02DteBV/Q8N3DQtT/B1yHGMQ/L5 gJAJ58EOSieR4l15KxL/a7FnVbAS7IORwqlJyT/n7wJGDu32zc/K/L9xxichfBEexU9v cwqw== 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 r62si31907205iod.101.2019.07.22.14.41.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:14 -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 1hpg2n-0002uZ-4n; Mon, 22 Jul 2019 21:40:29 +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 1hpg2k-0002pW-Pm for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:26 +0000 X-Inumbo-ID: 50f054ea-acc9-11e9-b168-0f6cf5046257 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 50f054ea-acc9-11e9-b168-0f6cf5046257; Mon, 22 Jul 2019 21:40:25 +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 A5F91344; Mon, 22 Jul 2019 14:40:25 -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 F33553F71F; Mon, 22 Jul 2019 14:40:24 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:45 +0100 Message-Id: <20190722213958.5761-23-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 22/35] xen/arm32: 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. Lastly, take the opportunity to replace load from literal pool with the new macro mov_w. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index b54331c19d..134c3dda92 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -54,7 +54,7 @@ * r4 - * r5 - * r6 - identity map in place - * r7 - CPUID + * r7 - * r8 - DTB address (boot CPU only) * r9 - paddr(start) * r10 - phys offset @@ -123,6 +123,12 @@ past_zImage: add r8, r10 /* r8 := paddr(DTB) */ #endif + /* Initialize the UART if earlyprintk has been enabled. */ +#ifdef CONFIG_EARLY_PRINTK + bl init_uart +#endif + PRINT("- Boot CPU booting -\r\n") + mov r12, #0 /* r12 := is_secondary_cpu */ b common_start @@ -137,14 +143,9 @@ GLOBAL(init_secondary) mov r12, #1 /* r12 := is_secondary_cpu */ -common_start: mrc CP32(r1, MPIDR) bic r7, r1, #(~MPIDR_HWID_MASK) /* Mask out flags to get CPU ID */ - /* Non-boot CPUs wait here until __cpu_up is ready for them */ - teq r12, #0 - beq 1f - ldr r0, =smp_up_cpu add r0, r0, r10 /* Apply physical offset */ dsb @@ -156,15 +157,14 @@ common_start: 1: #ifdef CONFIG_EARLY_PRINTK - ldr r11, =EARLY_UART_BASE_ADDRESS /* r11 := UART base address */ - teq r12, #0 /* Boot CPU sets up the UART too */ - bleq init_uart + mov_w r11, EARLY_UART_BASE_ADDRESS /* r11 := UART base address */ PRINT("- CPU ") mov r0, r7 bl putn PRINT(" booting -\r\n") #endif +common_start: /* Check that this CPU has Hyp mode */ mrc CP32(r0, ID_PFR1) and r0, r0, #0xf000 /* Bits 12-15 define virt extensions */ @@ -497,11 +497,15 @@ ENTRY(switch_ttbr) #ifdef CONFIG_EARLY_PRINTK /* - * Bring up the UART. - * r11: Early UART base address - * Clobbers r0-r2 + * Initialize the UART. Should only be called on the boot CPU. + * + * Ouput: + * r11: Early UART base physical address + * + * Clobbers r0 - r3 */ init_uart: + mov_w r11, EARLY_UART_BASE_ADDRESS #ifdef EARLY_PRINTK_INIT_UART early_uart_init r11, r1, r2 #endif From patchwork Mon Jul 22 21:39:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169436 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012303ilk; Mon, 22 Jul 2019 14:41:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrYiKeyuM4SOab1r6Pf+oNH8bCYmTS9njDPy0tpTE89k1I9NAihWEk/uwkU7K4AENHK/xG X-Received: by 2002:a6b:3102:: with SMTP id j2mr1731573ioa.5.1563831678132; Mon, 22 Jul 2019 14:41:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831678; cv=none; d=google.com; s=arc-20160816; b=IgJvxwpJG4MNJKXH41H3xnls1rBC2V2iWVUmYNJrD9+LVFMSewRU7EdPJTPe29pOz4 TkZyMgiHbGiXMcE8vLEWL3V3WXSF+6a6JYK/PKLgJhLOwASeNoeLVcTGVvA+JH6TFFR5 zfda5AVFNnMNx1uEiYqZEOvNU0zjA+USuSmp3k06G7l+pO2n6AZcG2JwvK3cqx4EMqwg abQTbZYImhbMaR6vvE4aZUUdSZno+d8yvrVWpoyrA5l7IYzdKernNCd4KAbha5Jj5hum fJaHl9C7HHRbsIzHZ1Yo9CZCxkWFhePu3vnxDw+uAXwQzpUVKcJAUV78J1wVoFz3hZQj weOg== 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=baSz94P9FUOeEHtkubYt+kYMB9Q45mk+Gv5OfgRc/zE=; b=SLr+x5e7nVg8JbpPomHk92hBu+zacNWI4QKzXNl8zDRCavdU+la12Kn7Uok8l04x2e 4HR4fLM/4IGpdIFtdNIMB6TKF3pH2zHuJGjoVFgBXhtEN3edbeh5Ga0via4doqKwmbnS cT+0fobxupnOm2UXFHAZLV4RHQVwrQHHPWAuuUAprfcJ98wlNICyRhFA3LOlgOiUr0vd Wps7W7gQriEcpjc800bDKbVeOUqdJtgaRdWrVJn1G6wlyBkgMAZpaaPnoDrTOJJcEflH 2LXGGC0xykeNi/fGZY/URi4Czi2ji58b0fzITqtgWwIh93eOn/Nl7Wb6uetV70Xiv+Ab LzAw== 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 e124si53612700jab.5.2019.07.22.14.41.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:18 -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 1hpg2p-00031G-Qv; Mon, 22 Jul 2019 21:40:31 +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 1hpg2n-0002vD-Fb for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:29 +0000 X-Inumbo-ID: 517e79aa-acc9-11e9-b45d-cf2cd706ffcc Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 517e79aa-acc9-11e9-b45d-cf2cd706ffcc; Mon, 22 Jul 2019 21:40: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 8C8B6152F; Mon, 22 Jul 2019 14:40: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 DA7923F71F; Mon, 22 Jul 2019 14:40:25 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:46 +0100 Message-Id: <20190722213958.5761-24-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 23/35] xen/arm32: head: Introduce print_reg 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" At the moment, the user should save r14/lr if it cares about it. Follow-up patches will introduce more use of putn in place where lr should be preserved. Furthermore, any user of putn should also move the value to register r0 if it was stored in a different register. For convenience, a new macro is introduced to print a given register. The macro will take care for us to move the value to r0 and also preserve lr. Lastly the new macro is used to replace all the callsite of putn. This will simplify rework/review later on. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 134c3dda92..bbcfdcd351 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -79,8 +79,25 @@ 98: .asciz _s ;\ .align 2 ;\ 99: + +/* + * Macro to print the value of register \rb + * + * Clobbers r0 - r4 + */ +.macro print_reg rb + mov r0, \rb + mov r4, lr + bl putn + mov lr, r4 +.endm + #else /* CONFIG_EARLY_PRINTK */ #define PRINT(s) + +.macro print_reg rb +.endm + #endif /* !CONFIG_EARLY_PRINTK */ .arm @@ -159,8 +176,7 @@ GLOBAL(init_secondary) #ifdef CONFIG_EARLY_PRINTK mov_w r11, EARLY_UART_BASE_ADDRESS /* r11 := UART base address */ PRINT("- CPU ") - mov r0, r7 - bl putn + print_reg r7 PRINT(" booting -\r\n") #endif @@ -211,8 +227,7 @@ skip_bss: bne 1f mov r4, r0 PRINT("- Missing processor info: ") - mov r0, r4 - bl putn + print_reg r4 PRINT(" -\r\n") b fail 1: From patchwork Mon Jul 22 21:39:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169437 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012320ilk; Mon, 22 Jul 2019 14:41:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqybLIfsiFqImU2bCCbrF7KuOaIpdSWJfp3yh7M9H2hcMNIOBdS2O5vMyRJJZGjelFl8OE94 X-Received: by 2002:a05:6602:2413:: with SMTP id s19mr21366789ioa.161.1563831679191; Mon, 22 Jul 2019 14:41:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831679; cv=none; d=google.com; s=arc-20160816; b=Id0pLyZ9g5Q3vWzZxHwEHcBA23I1DBP5AsgxcnUld2vda/KgI/S/JSHj4nqzsBw2mo uc+OWlPeJwd70C3xRlzlaHZkfI7M20xND+J5X3ewuRlvU6RXhm6nrzMmPpc2jSmZpo6a qV7aHw+V9t/yZkhJYSYdWdBNKfuAhI+deZWh6+GUrB7shYurmgN5Tta5BzWDksYq/ZIF Sm1yyt/kXcX/o6+XjXbU8UwcA/pEEBz4wizIQNPWr0AEImculHZz8jcvgf81liIfGjL3 fseJX0q+d6MZTLw1dy6a2tMQ62r0oSys4zWgHFzK9C1lFudoteAAffjKHeOSP5nNx18E 1vQA== 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=+jN/I8VpLmhCR3pD3IiwosgtljxqUOPisTX1AtSTmgk=; b=Z15uQwaHuuvSYmRcjHihctpIYCpHYjWB8am2x+tjCzBVWhSv2Yc+Oy+6xA4gvSsWfg FNqvSzgxA9Xt9Xi0zYMZ9uyX5j1zYq2VRyFiJQsQ0mZmK9ujYyVijpcKW2i55lpkiv/7 9hhCuwnVJMGUCPNgNxi7xlubnYs0N78TLAK8KOl/vcCAAo/cUTS+VArAqaNQZo/uRIxI +ugIYjZsIhzjf/G6sEoikDqq0gj9vaBZ2hrbokhB701LLT3FLAEuzX8iTGq6NDJD4Wj2 8ceUr9pTfnPTJuQv15jnxMTtUitmoLBM5dFpv4hqCL8zDDjCpxOYD00/5lHXQw4Pp7pp NXvg== 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 l10si37477756ion.114.2019.07.22.14.41.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:19 -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 1hpg2p-0002zY-2R; Mon, 22 Jul 2019 21:40:31 +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 1hpg2n-0002v8-DW for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:29 +0000 X-Inumbo-ID: 5205c1d0-acc9-11e9-8e49-6f0dfec89258 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 5205c1d0-acc9-11e9-8e49-6f0dfec89258; Mon, 22 Jul 2019 21:40:27 +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 7257B1509; Mon, 22 Jul 2019 14:40:27 -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 C08C13F71F; Mon, 22 Jul 2019 14:40:26 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:47 +0100 Message-Id: <20190722213958.5761-25-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 24/35] xen/arm32: 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk 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 distinct and for now will call each functions. Follow-ups will remove unnecessary 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. Lastly, it is now required to save lr in cpu_init() becauswe the function will call other functions and therefore clobber lr. Signed-off-by: Julien Grall --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 64 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index bbcfdcd351..13793e85d8 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -148,7 +148,19 @@ past_zImage: mov r12, #0 /* r12 := 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 r0, =primary_switched + mov pc, r0 +primary_switched: + bl setup_fixmap + b launch +ENDPROC(start) GLOBAL(init_secondary) cpsid aif /* Disable all interrupts */ @@ -179,8 +191,21 @@ GLOBAL(init_secondary) print_reg r7 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 r0, =secondary_switched + mov pc, r0 +secondary_switched: + bl setup_fixmap + b launch +ENDPROC(init_secondary) + +check_cpu_mode: /* Check that this CPU has Hyp mode */ mrc CP32(r0, ID_PFR1) and r0, r0, #0xf000 /* Bits 12-15 define virt extensions */ @@ -202,7 +227,10 @@ common_start: b fail hyp: PRINT("- Xen starting in Hyp mode -\r\n") + mov pc, lr +ENDPROC(check_cpu_mode) +zero_bss: /* Zero BSS On the boot CPU to avoid nasty surprises */ teq r12, #0 bne skip_bss @@ -219,8 +247,14 @@ hyp: PRINT("- Xen starting in Hyp mode -\r\n") blo 1b skip_bss: + mov pc, lr +ENDPROC(zero_bss) + +cpu_init: PRINT("- Setting up control registers -\r\n") + mov r5, lr /* r5 := return address */ + /* Get processor specific proc info into r1 */ bl __lookup_processor_type teq r1, #0 @@ -231,7 +265,6 @@ skip_bss: PRINT(" -\r\n") b fail 1: - /* Jump to cpu_init */ ldr r1, [r1, #PROCINFO_cpu_init] /* r1 := vaddr(init func) */ adr lr, cpu_init_done /* Save return address */ @@ -256,6 +289,10 @@ cpu_init_done: ldr r0, =HSCTLR_SET mcr CP32(r0, HSCTLR) + mov pc, r5 /* Return address is in r5 */ +ENDPROC(cpu_init) + +create_page_tables: /* * Rebuild the boot pagetable's first-level entries. The structure * is described in mm.c. @@ -359,15 +396,16 @@ cpu_init_done: /* boot pagetable setup complete */ cmp r6, #1 /* Did we manage to create an identity mapping ? */ - beq 1f + moveq pc, lr PRINT("Unable to build boot page tables - Failed to identity map Xen.\r\n") b fail virtphys_clash: /* Identity map clashes with boot_third, which we cannot handle yet */ PRINT("- Unable to build boot page tables - virt and phys addresses clash. -\r\n") b fail +ENDPROC(create_page_tables) -1: +enable_mmu: PRINT("- Turning on paging -\r\n") /* @@ -377,16 +415,16 @@ virtphys_clash: mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLBs */ dsb nsh - ldr r1, =paging /* Explicit vaddr, not RIP-relative */ mrc CP32(r0, HSCTLR) /* Enable MMU and D-cache */ orr r0, r0, #(SCTLR_Axx_ELx_M|SCTLR_Axx_ELx_C) dsb /* Flush PTE writes and finish reads */ mcr CP32(r0, HSCTLR) /* now paging is enabled */ isb /* Now, flush the icache */ - mov pc, r1 /* Get a proper vaddr into PC */ -paging: + mov pc, lr +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 @@ -436,12 +474,15 @@ paging: mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ dsb /* Ensure completion of TLB flush */ isb + mov pc, lr +ENDPROC(setup_fixmap) +launch: PRINT("- Ready -\r\n") /* The boot CPU should go straight into C now */ teq r12, #0 - beq launch + beq 1f /* * Non-boot CPUs need to move on to the proper pagetables, which were @@ -460,7 +501,7 @@ paging: dsb /* Ensure completion of TLB+BP flush */ isb -launch: +1: ldr r0, =init_data add r0, #INITINFO_stack /* Find the boot-time stack */ ldr sp, [r0] @@ -471,6 +512,7 @@ launch: moveq r1, r8 /* - DTB address */ beq start_xen /* and disappear into the land of C */ b start_secondary /* (to the appropriate entry point) */ +ENDPROC(launch) /* Fail-stop */ fail: PRINT("- Boot failed -\r\n") From patchwork Mon Jul 22 21:39:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169435 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012276ilk; Mon, 22 Jul 2019 14:41:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzH1Wf0GqBDo1JgvBRkJNCkfJ59qdsjZF8skAv3+I/FIf1YECSug6EgejNMTXat7Mb5xpjN X-Received: by 2002:a02:cc6c:: with SMTP id j12mr32765775jaq.102.1563831676706; Mon, 22 Jul 2019 14:41:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831676; cv=none; d=google.com; s=arc-20160816; b=QTzPzPeRja2cb1+5kkV248y4+9af/UtbAn9o3qrX4uTAueYiRRN/GU+cErL9XOk9+u XCBJlzAMao88ET9xixZKj6El9muOAni1xCAgMtZwT5/FJ3DqFyeoQvqv0LlAl6t7UiDW 8IMIWiJv4pFNxmfC+mmREnxVpHGh97w9ZS5IhjRz9Lz7w+aO4g5qyBfIH+ZR/p1pNIaf Bo+Q26ah1bsS82kyUXcdHict/o0BmjzMxEFplaI/U9xiC8USVd5Ca0QmebONi5h2YBe0 YXNIvUGD1DCTzjbUTP35TaRxW17xn3VKl0bgLLC9jvkS83QTSX5i9ahfQ0umQcYoQWl/ VWug== 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=qabRMnCZNnT/C98bR8vgyonKlMdToMxJx0KwlVo85AE=; b=J+YNpCT4AtVp8Dkbfkc+9AReOmNcAv3sqwxPg5s2b7UyS/W1nOFHN98iGXbAYQkBR3 Wn1nCVWgNlBXAKVjMJRacrqWaU7ytuVZDstLx0MrH3I0oMCVRVINaqahXlb5qdn5wsIl A8qYXZM+1hP5s3Zn4jiaUGqMKG6ykGN1qnqfXIHXbgvctHsvatWsmlUhulJeiIAFW5/Q Bxw++Y/v/gkp4hi7MuSOurkFP/39imJQjJZI/LRFnTxvCib+7w7YNEGt6qlMnK8s+ejR QwjwxWdaN0Gm5D4nW4yJLbtaRMo3o9zi+1hHFgEC6NdmWgmXqU6OPWK9FzbWyf1jpOyt YS1w== 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 g21si819888ion.115.2019.07.22.14.41.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:16 -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 1hpg2q-00033N-My; Mon, 22 Jul 2019 21:40:32 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2n-0002w5-Su for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:29 +0000 X-Inumbo-ID: 5281e7ca-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 5281e7ca-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:28 +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 589FF344; Mon, 22 Jul 2019 14:40:28 -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 A67F13F71F; Mon, 22 Jul 2019 14:40:27 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:48 +0100 Message-Id: <20190722213958.5761-26-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 25/35] xen/arm32: head: Rework and document check_cpu_mode() 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" A branch in the success case can be avoided by inverting the branch condition. At the same time, remove a pointless comment as Xen can only run at Hypervisor Mode. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 13793e85d8..0959c4f044 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -205,6 +205,16 @@ secondary_switched: b launch ENDPROC(init_secondary) +/* + * Check if the CPU supports virtualization extensions and has been booted + * in Hypervisor mode. + * + * This function will never return when the CPU doesn't support + * virtualization extensions or is booted in another mode than + * Hypervisor mode. + * + * Clobbers r0 - r3 + */ check_cpu_mode: /* Check that this CPU has Hyp mode */ mrc CP32(r0, ID_PFR1) @@ -219,15 +229,12 @@ check_cpu_mode: mrs r0, cpsr and r0, r0, #0x1f /* Mode is in the low 5 bits of CPSR */ teq r0, #0x1a /* Hyp Mode? */ - beq hyp + moveq pc, lr /* Yes, return */ /* OK, we're boned. */ PRINT("- Xen must be entered in NS Hyp mode -\r\n") PRINT("- Please update the bootloader -\r\n") b fail - -hyp: PRINT("- Xen starting in Hyp mode -\r\n") - mov pc, lr ENDPROC(check_cpu_mode) zero_bss: From patchwork Mon Jul 22 21:39:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169441 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012407ilk; Mon, 22 Jul 2019 14:41:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzaGJMIz9oJoQd6kM1cbqxUxRlpQqg4SBnHg8FGa7TIbmsp7J2AyxI65/vwzoI39LKsT+im X-Received: by 2002:a5e:d618:: with SMTP id w24mr32647151iom.73.1563831685800; Mon, 22 Jul 2019 14:41:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831685; cv=none; d=google.com; s=arc-20160816; b=rE81MDuSIBnLUlzm/Q59pKG8f+iBQ+tkufx5neEGX1T1EdJwNrfNSz6Z0YNVbItJ8U FPZ7+T8Bu4jYSVKNe/fAb+BqMLVEAxNIWfAB9gwp/sPAYr5aSrawNVLVld94/wTGLPS7 sX3/RM9YOV8Gyt4yfkeCVPdfrecl3MT23AcmYIe6rL0g76H1Cqw+GNIZwQ3JdRf22Pob 4CKCS2qUmLZgG+Vej4mExHp2/+kwSsmL+6RglmVPnLJfMdX+h36xtxhgg+6EsJovwZs0 Knxq81w1Y1P6GLb2m1RBByEMzFgcBV7heZWU2ulyQ9mx0avJvZSHOWHf6DwDj4UZRhjL o1Mw== 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=dQZoslaYH0KO5kTkzETWpn4LLBmT8iTAY4UxYCEbW+s=; b=F/U3QVmA9GxDM6c5dxXgszoWUq1fbUl1NTpIg6fjI5f5JnMERguq11Q7Q4lwe09+N6 q1JpguYHQ4PwhQrfa84nnKXvkzhPe47/g1x8mI45XINM8HBV3gDbKi9gOK+HBBww1llC j/GrLWLC7VRzhUTk3ywKUsedf4X0FxOlzpmhIbIR02vRDoh3pgAKrzu2Ub2xh+yawtUM wwQ63Bg9Ss2Wg+VHpcot0Br7O7sI2oJwJwUpgQOpMnkMCUuaiCJe0CMEqBuTaa2dAQLd T/zwDDTEks1ltWIyDPDdjn5K5hW5yQz150zDZKOcAC0g5ScQMd/aXBHZvNq/P4XaEiRi Qxog== 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 n26si55099201iob.66.2019.07.22.14.41.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:25 -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 1hpg2u-0003CH-9k; Mon, 22 Jul 2019 21:40:36 +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 1hpg2p-00031D-RG for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:31 +0000 X-Inumbo-ID: 53162772-acc9-11e9-85bd-17aa413bce38 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 53162772-acc9-11e9-85bd-17aa413bce38; Mon, 22 Jul 2019 21:40:29 +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 3E903153B; Mon, 22 Jul 2019 14:40:29 -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 8C80B3F71F; Mon, 22 Jul 2019 14:40:28 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:49 +0100 Message-Id: <20190722213958.5761-27-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 26/35] xen/arm32: head: Rework and document zero_bss() 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" On secondary CPUs, zero_bss() will be a NOP because BSS only need to be zeroed once at boot. So the call in the secondary CPUs path can be removed. Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 0959c4f044..119d2a0df8 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -192,7 +192,6 @@ GLOBAL(init_secondary) PRINT(" booting -\r\n") #endif bl check_cpu_mode - bl zero_bss bl cpu_init bl create_page_tables bl enable_mmu @@ -237,11 +236,15 @@ check_cpu_mode: b fail ENDPROC(check_cpu_mode) +/* + * Zero BSS + * + * Inputs: + * r10: Physical offset + * + * Clobbers r0 - r3 + */ zero_bss: - /* Zero BSS On the boot CPU to avoid nasty surprises */ - teq r12, #0 - bne skip_bss - PRINT("- Zero BSS -\r\n") ldr r0, =__bss_start /* Load start & end of bss */ ldr r1, =__bss_end @@ -253,7 +256,6 @@ zero_bss: cmp r0, r1 blo 1b -skip_bss: mov pc, lr ENDPROC(zero_bss) From patchwork Mon Jul 22 21:39:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169438 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012374ilk; Mon, 22 Jul 2019 14:41:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3viYkHdb8NsE68JC9+h7rpdzN9v9mGZEerCGd3k1Vz9I9huDbStiO6n8wkWofqmYtR2Yh X-Received: by 2002:a6b:b497:: with SMTP id d145mr43914343iof.17.1563831683425; Mon, 22 Jul 2019 14:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831683; cv=none; d=google.com; s=arc-20160816; b=YqdOMMXmfw0A/Y9TAmT1HiaXi4VJFQ/qMsAPxlbrxVnyAFvD0s1yTkVifg55Dagrsv G8nHfd8lcNZHxd9ZsMzU/PSjLkg+Uk5u+8iy43OF8IzVHFa9/3dlzo442ObwxoQMtTp8 EKS6MwxEQXI2S/3H9do4ZSZoYqC6fZLWWXlbE06RfpaOgl2+7Zj+GP6+RRV43Nx3nyMD NLe+gGPYvPyD6gGNmsRfAxSICjtO8ITwld+jJnqkQWwmVisLWlAhGtumYe5fSSLvH1NW Qejaerd9PQaw8ZM863+btBkfY29U0060Vzy1mzeM5riacggYlH2PB4LOpV/pYcWeXC1s /r+w== 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=67QZHh0smnzbyzTnWJczGMY516WvhqgE1egeE+vZAEw=; b=QJ+qdP4tJQasycfYr57QEfHMfg1YAWAcQRJFHLvm1Ep4PA+pxzWWCtuxZS6LSQ4aLC pEAt29ptdI89qFFeF9XrcD2S1P4W3/tbidxnSZWwSE7cC18iSpD2Xss/rhsETj4VqF6S NAzNh0djI4zRI+sExfcaEiPtWY52M59fIrf+0Ra5y7cVY06iC9u6fBK5gCDVvVoKXHyo GcQEri5zH6IoVT5M4YtddAF8fR5PzgueEnLbQePEWmOADgSu6teQQcLgxYHrfNOxh4F0 hGs0cxDT3UYwEIhlznw3zCYJtDTqD0z0Q1+5iXDkZHdSMmD87wZMzjqwVGqASMDJXVDz hC5g== 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 i5si34246471jan.51.2019.07.22.14.41.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:23 -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 1hpg2s-00038Y-Tg; Mon, 22 Jul 2019 21:40:34 +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 1hpg2p-00031C-Qd for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:31 +0000 X-Inumbo-ID: 539a022c-acc9-11e9-91e4-e3ebf45ca47e Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 539a022c-acc9-11e9-91e4-e3ebf45ca47e; Mon, 22 Jul 2019 21:40:30 +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 251911509; Mon, 22 Jul 2019 14:40: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 729C93F71F; Mon, 22 Jul 2019 14:40:29 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:50 +0100 Message-Id: <20190722213958.5761-28-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 27/35] xen/arm32: head: Document create_pages_tables() 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" Document the behavior and the main registers usage within the function. Note that r6 is now only used within the function, so it does not need to be part of the common register. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 119d2a0df8..ef8979959b 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -53,7 +53,7 @@ * r3 - * r4 - * r5 - - * r6 - identity map in place + * r6 - * r7 - * r8 - DTB address (boot CPU only) * r9 - paddr(start) @@ -301,18 +301,26 @@ cpu_init_done: mov pc, r5 /* Return address is in r5 */ ENDPROC(cpu_init) +/* + * Rebuild the boot pagetable's first-level entries. The structure + * is described in mm.c. + * + * After the CPU enables paging it will add the fixmap mapping + * to these page tables, however this may clash with the 1:1 + * mapping. So each CPU must rebuild the page tables here with + * the 1:1 in place. + * + * Inputs: + * r9 : paddr(start) + * r10: phys offset + * + * Clobbers r0 - r6 + * + * Register usage within this function: + * r6 : Identity map in place + */ create_page_tables: /* - * Rebuild the boot pagetable's first-level entries. The structure - * is described in mm.c. - * - * After the CPU enables paging it will add the fixmap mapping - * to these page tables, however this may clash with the 1:1 - * mapping. So each CPU must rebuild the page tables here with - * the 1:1 in place. - */ - - /* * If Xen is loaded at exactly XEN_VIRT_START then we don't * need an additional 1:1 mapping, the virtual mapping will * suffice. From patchwork Mon Jul 22 21:39:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169439 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012391ilk; Mon, 22 Jul 2019 14:41:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH0HBSyGNAGO5osjWws7zJFQt/4jNtecMaObugcMPFLz4lwEfU7jAmDTDhesywbwFeYafA X-Received: by 2002:a02:4e05:: with SMTP id r5mr78857664jaa.27.1563831684777; Mon, 22 Jul 2019 14:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831684; cv=none; d=google.com; s=arc-20160816; b=Bb2sEGceFBaUCMQE4CR9D3gecaqCQqsvpGnzri5c3SxS8DfnTwdrjS/30y9N1x1OZo wRbrRIA0f/Yma50ROguLWPRtn66ikwRoaUpMOCSzDQyN0KJ8d/SLMszRqEQYISYUBO+6 mD8CkXhDYROjXoZP51PVt1M4JEG+yvHOZcSZnUeUGYdCWGSp1uJTbArF0Z/rp/sbtBmE VdsmBqesKZ1rI/sFNCyG3GALan5wJC5h9mOqOE9GLbudSdBoSdvzAzs3fsiUiPfW7DYS RKI/PYdKVO5n6mMoIMFZHUGr7YLsaNlOVNoMis1x7ne5pnoCugiudh/4CnZtsLRDRowW U9mg== 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=X6WGEKVfZynBBxSg2IphLwIFSB2ZFvffeaSxZHbhbbI=; b=pFUbe3hBtbDgdzzfwQNgzV2I9KSFRluzOPNXPZF7Zn2ueJcgPXXCmXBlQ8pCBl6cdU NGJnPVv8Lx9o9rguw3He3WwfviBEwp902MHli9FE2KaXxvDFQ0UrG2qEFSlzlXzByQV5 lii/CDOsuqTCqp2ANe4SLJ66DI87Nw4QiFwzVBaUhJjfA/dN7oci8wjghfM35f0P5r6P 2CNulGB00W6urtXXOkCQABjYFTh6glVHt95LdQrLhl4JlyEN2HoIAG5IocimDaWOTXT6 JVRShLuH6zJroNFPit63Uh37Z7KBrz8sdxfkrdSpVPhwGjcngSJ7B41kZUYUSUGSX3g+ OVZA== 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 q12si67471847jac.13.2019.07.22.14.41.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:24 -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 1hpg2v-0003Eb-BV; Mon, 22 Jul 2019 21:40:37 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2q-00032G-9J for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:32 +0000 X-Inumbo-ID: 542428e5-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 542428e5-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40: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 0B0F0344; Mon, 22 Jul 2019 14:40:31 -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 593493F71F; Mon, 22 Jul 2019 14:40:30 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:51 +0100 Message-Id: <20190722213958.5761-29-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 28/35] xen/arm32: head: Document enable_mmu() 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" Document the behavior and the main registers usage within enable_mmu(). Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index ef8979959b..4081a52dfa 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -422,6 +422,13 @@ virtphys_clash: b fail ENDPROC(create_page_tables) +/* + * Turn on the Data Cache and the MMU. The function will return on the 1:1 + * mapping. In other word, the caller is responsible to switch to the runtime + * mapping. + * + * Clobbers r0 - r3 + */ enable_mmu: PRINT("- Turning on paging -\r\n") From patchwork Mon Jul 22 21:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169442 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012415ilk; Mon, 22 Jul 2019 14:41:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyLJUeRA+WNDhd+Tiy5LydYtoeDx/ppoMBPVc7X6jhWPJOuMiLkofyqn+u7lt4Dq8VVRkGs X-Received: by 2002:a5d:9291:: with SMTP id s17mr66456053iom.10.1563831686202; Mon, 22 Jul 2019 14:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831686; cv=none; d=google.com; s=arc-20160816; b=XmcwoFxKnwkkOqQA9CVDbmY0lhOOKQV8tpX8Ow8XAYTX0Y7G+Khky1fnB9xc9XxnmP KVwIEo8PsZ3MeDzXtyaucCaTrYvwb8WKJz3w1cyMQPeH+6vDe6ayUC4UTqZGRDNn6/Ks /r1716XNq/dcuG3wgMgHnHsnCOAlnzakHublor1iO+XNEzD8y8jxEqYtqAuA2/VfpCUG GNlBKZlBBuKgeN3cAkR74d6wsBnHF2b1Srfz5wL6ukoEOgWR5SD3gbmDghAIFKl1K28B Sd1JdEmYo/kEVadUHOyZXR4Jl9Rr9Me1uypLqkwPasAaVG+V7N4gMJpUDCrR2mbGQCQv BM1A== 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=kpFaSmj4IvKUZo5HJUvFkFwAQotFbpEWRO3yuTiKSzM=; b=dKBgAAwsraOArGNI/3cxUIss3LGnexgUWkZe6dUXZ6ovwhSAzTAFMEpIehX18Sz627 jCsDny0NyaurZ1P710dlZIi9fnIBegmkRYjzg70GmzWqyw4DzytKR3egoYZQfjNrj1u4 l7QZnXtPFEz4Dr52pK7XtompX8DBlZ5GU9oO972gzc+NBaK/e4C2O1llF+fQGY9B1UjI +XzAu6Bl3YaGgpKk7X/QHjcjJgUnf9Y6Pgx5ibuWStMLJ5Qe2R53hSQmBLqI6+Pn1OVn ANJtaKL1aMayxefqyoBH8HQmo4Qq8DmnBFSSnWxtnk+yhgjt5U0HOAG0JqKx4Pag9M9e H/5A== 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 p24si52850761iol.54.2019.07.22.14.41.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:26 -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 1hpg2x-0003IY-19; Mon, 22 Jul 2019 21:40:39 +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 1hpg2r-00036D-Rw for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:33 +0000 X-Inumbo-ID: 54aa3c72-acc9-11e9-998a-a3848bc5c860 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 54aa3c72-acc9-11e9-998a-a3848bc5c860; Mon, 22 Jul 2019 21:40:32 +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 E563E152F; Mon, 22 Jul 2019 14:40:31 -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 3F5893F71F; Mon, 22 Jul 2019 14:40:31 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:52 +0100 Message-Id: <20190722213958.5761-30-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 29/35] xen/arm32: head: Move assembly switch to the runtime PT in secondary CPUs path 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" The assembly switch to the runtime PT is only necessary for the secondary CPUs. So move the code in the secondary CPUs path. While this is definitely not compliant with the Arm Arm as we are switching between two differents set of page-tables without turning off the MMU. Turning off the MMU is impossible here as the ID map may clash with other mappings in the runtime page-tables. This will require more rework to avoid the problem. So for now add a TODO in the code. Finally, the code is currently assume that r5 will be properly set to 0 before hand. This is done by create_page_tables() which is called quite early in the boot process. There are a risk this may be oversight in the future and therefore breaking secondary CPUs boot. Instead, set r5 to 0 just before using it. Signed-off-by: Julien Grall --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 4081a52dfa..6dc6032498 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -201,6 +201,26 @@ GLOBAL(init_secondary) mov pc, r0 secondary_switched: bl setup_fixmap + + /* + * Non-boot CPUs need to move on to the proper pagetables, which were + * setup in init_secondary_pagetables. + * + * XXX: This is not compliant with the Arm Arm. + */ + ldr r4, =init_ttbr /* VA of HTTBR value stashed by CPU 0 */ + mov r5, #0 + ldrd r4, r5, [r4] /* Actual value */ + dsb + mcrr CP64(r4, r5, HTTBR) + dsb + isb + mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ + mcr CP32(r0, ICIALLU) /* Flush I-cache */ + mcr CP32(r0, BPIALL) /* Flush branch predictor */ + dsb /* Ensure completion of TLB+BP flush */ + isb + b launch ENDPROC(init_secondary) @@ -504,28 +524,6 @@ ENDPROC(setup_fixmap) launch: PRINT("- Ready -\r\n") - /* The boot CPU should go straight into C now */ - teq r12, #0 - beq 1f - - /* - * Non-boot CPUs need to move on to the proper pagetables, which were - * setup in init_secondary_pagetables. - */ - - ldr r4, =init_ttbr /* VA of HTTBR value stashed by CPU 0 */ - ldrd r4, r5, [r4] /* Actual value */ - dsb - mcrr CP64(r4, r5, HTTBR) - dsb - isb - mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ - mcr CP32(r0, ICIALLU) /* Flush I-cache */ - mcr CP32(r0, BPIALL) /* Flush branch predictor */ - dsb /* Ensure completion of TLB+BP flush */ - isb - -1: ldr r0, =init_data add r0, #INITINFO_stack /* Find the boot-time stack */ ldr sp, [r0] From patchwork Mon Jul 22 21:39:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169443 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012419ilk; Mon, 22 Jul 2019 14:41:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyzCqPymjat63t+5uBZcnFwNO24mHsIHyyyUFgoMK3qRtOLvEUWjjbzEifhQVc8aK4Sdvf5 X-Received: by 2002:a02:716e:: with SMTP id n46mr77063497jaf.137.1563831686763; Mon, 22 Jul 2019 14:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831686; cv=none; d=google.com; s=arc-20160816; b=LYw93WnvmdKekMJ2ZGyb9ttkzvQamdahoQDdR9MrsW2QB90e8Mp8fvBNLQZ0Rf+XDW 9Z0kxESMQ7PWotHSPFvd52GLrht21dGb+SmsA+0PDXl4rbbCUn8tdV3PhQe02eKr6H1T fsbHdYVAuGULpe86Iig8O5nk5kbeGeUwL0NbwnIrvLCzOnKd3f7kKhLbwHF1GPJ7FYgy QbalGnJQe0iEQPeDHKtGGkdskz+YaUCDRyyrScv/e+8SImOxHhqIkgklRge3NMZzp82p Z/hg+1muC5TIC0ovP2z4QfWGvzEeSKLar1EI+8dibGRgS6zU8oLdLQR68YMVfeDXXaMD FkGg== 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=O7LIKDLREBBAhuirKQaIkVzSkaUZvVao+Sbh0xF8Chc=; b=uWUq4T/u4ZK2+XM8O4BcejUenEAPrB4l00Z8JmtzcDf8wXRbexNld3qkLGDxiNQjfW Ia4ulpNNhqfg9mgUDEMapac+YzUO8k1PBzrw2QjZcXvzBTcf5pdaLz+aepigqEnqs99f Me+QhI7UiAmV+u7LfY4bV68xYiz2AImAfZpYefRejLc4ShJ6ZxXPI5MWrSFGZqVb2bvE Y2rhp2xsXHpO8lUQuvETh55vcBCzu1hbwtJTqL0Y33h9nvTH/Qej74jPjWHmq5lJdX1n w/mjFYoHOOH5q/rGGaf/CaW55c4UUGEJ68LMbhp6rzE/rL0RxJSFcSdG9r8Ztubkgcml NNEA== 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 e9si54345330iom.123.2019.07.22.14.41.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:26 -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-0003M5-CG; Mon, 22 Jul 2019 21:40: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 1hpg2r-00035e-KO for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:33 +0000 X-Inumbo-ID: 552bfa33-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 552bfa33-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:32 +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 CB68D1595; Mon, 22 Jul 2019 14:40:32 -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 2546F3F71F; Mon, 22 Jul 2019 14:40:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:53 +0100 Message-Id: <20190722213958.5761-31-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 30/35] xen/arm32: head: Don't setup the fixmap on 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: Julien Grall , Stefano Stabellini , Volodymyr Babchuk MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" setup_fixmap() will setup the fixmap in the boot page tables in order to use earlyprintk and also update the register r11 holding the address to the UART. However, secondary CPUs are not using earlyprintk between turning the MMU on and switching to the runtime page table. So setting up the fixmap in the boot pages table is pointless. This means most of setup_fixmap() is not necessary for the secondary CPUs. The update of UART address is now moved out of setup_fixmap() and duplicated in the CPU boot and secondary CPUs boot. Additionally, the call to setup_fixmap() is removed from secondary CPUs boot. Lastly, take the opportunity to replace load from literal pool with the new macro mov_w. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 6dc6032498..0a5c3a8525 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -159,6 +159,10 @@ past_zImage: mov pc, r0 primary_switched: bl setup_fixmap +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + mov_w r11, EARLY_UART_VIRTUAL_ADDRESS +#endif b launch ENDPROC(start) @@ -200,8 +204,6 @@ GLOBAL(init_secondary) ldr r0, =secondary_switched mov pc, r0 secondary_switched: - bl setup_fixmap - /* * Non-boot CPUs need to move on to the proper pagetables, which were * setup in init_secondary_pagetables. @@ -221,6 +223,10 @@ secondary_switched: dsb /* Ensure completion of TLB+BP flush */ isb +#ifdef CONFIG_EARLY_PRINTK + /* Use a virtual address to access the UART. */ + mov_w r11, EARLY_UART_VIRTUAL_ADDRESS +#endif b launch ENDPROC(init_secondary) @@ -475,13 +481,6 @@ setup_fixmap: */ dsb #if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ - /* - * Non-boot CPUs don't need to rebuild the fixmap itself, just - * the mapping from boot_second to xen_fixmap - */ - teq r12, #0 - bne 1f - /* Add UART to the fixmap table */ ldr r1, =xen_fixmap /* r1 := vaddr (xen_fixmap) */ lsr r2, r11, #THIRD_SHIFT @@ -502,9 +501,6 @@ setup_fixmap: mov r4, r4, lsr #(SECOND_SHIFT - 3) /* r4 := Slot for FIXMAP(0) */ mov r3, #0x0 strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ - - /* Use a virtual address to access the UART. */ - ldr r11, =EARLY_UART_VIRTUAL_ADDRESS #endif /* From patchwork Mon Jul 22 21:39:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169445 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8012438ilk; Mon, 22 Jul 2019 14:41:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDebV1G8w+nrGjt7WYBSo0HO5uV9y/K1cEdUppbj+7wwFCFUW3sEc/XpEemso26DGo9eRq X-Received: by 2002:a02:29ce:: with SMTP id p197mr13912186jap.139.1563831688324; Mon, 22 Jul 2019 14:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831688; cv=none; d=google.com; s=arc-20160816; b=VRWSInU99oW6nLBCw2NpriYvDOwxHiEjDNqo4mHtas7X0BFWtqK+PMplRxdcY0er// 6t6QHnNV0A8WeRVJp1MUN8M5WeF0fu2Mr6L7lTl0p179oLND/2WWp1DP9VxCjY2r8dZP hD5cTQGmdxTsZfnY+pUCsBuU9yuuIlaEYMIwE9cYsUu8JyH+1opeH2pYqv9/mXLgIjJV S7ssWeWoVx/bMjKnH9dI8enKBrbUhLZXoOmsbaM0zAut/kFm27J92/Jv/F70tOLW7OKJ D7Jye28Kh5KebV0pLxcx4zQZUkpZXGCy49ddcHSj0aQcpxUI1SxQvGHTRzXCAY6HJoUn GigQ== 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=DXWoLIMtj2vesa2NqqIn95cRLjcx+FzkCwsvjqrnKPI=; b=HhErVe9EigAzJl4qMtjm0OqUu0O80JF3i2GH5Kpc3bolWCmh+uXAuBKzVGGbrK6Vli rIKHFO92m04klKXDlHQ03piz+J/BSG7hzxh1WrrKXH3DtqhSBwHWEcXvhhJHDhys6nD3 RL+ZBlzVcsNt4H1iNvGONypvAXfnPfg9rFgWWgJ4tCJj1thbQHBfRpdsRo5GiDV4daI5 Kq+NYygFiyX2m2F+W8b+7F2fWU5e1W+1utYGpW2GN+eRGRFxg5nfuulPW37PR08FLy9N FxhyD9f0b6rb1VpVQdozAMcSvh/cr9VP2aHbdtTrvV2l18FIPq5XFbD5eK+hLmm5Q0lF kutg== 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 e14si52702663ios.20.2019.07.22.14.41.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:41:28 -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 1hpg2z-0003Pn-TG; Mon, 22 Jul 2019 21:40:41 +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 1hpg2t-00039S-6a for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:35 +0000 X-Inumbo-ID: 55bf2820-acc9-11e9-af58-9762408ddb70 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 55bf2820-acc9-11e9-af58-9762408ddb70; Mon, 22 Jul 2019 21:40:33 +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 B15491509; Mon, 22 Jul 2019 14:40:33 -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 0B51A3F71F; Mon, 22 Jul 2019 14:40:32 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:54 +0100 Message-Id: <20190722213958.5761-32-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 31/35] xen/arm32: head: Remove 1:1 mapping as soon as it is not used 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" The 1:1 mapping may clash with other parts of the Xen virtual memory layout. At the moment, Xen is handling the clash by only creating a mapping to the runtime virtual address before enabling the MMU. The rest of the mappings (such as the fixmap) will be mapped after the MMU is enabled. However, the code doing the mapping is not safe as it replace mapping without using the Break-Before-Make sequence. As the 1:1 mapping can be anywhere in the memory, it is easier to remove all the entries added as soon as the 1:1 mapping is not used rather than adding the Break-Before-Make sequence everywhere. It is difficult to track where exactly the 1:1 mapping was created without a full rework of create_page_tables(). Instead, introduce a new function remove_identity_mapping() will look where is the top-level entry for the 1:1 mapping and remove it. The new function is only called for the boot CPU. Secondary CPUs will switch directly to the runtime page-tables so there are no need to remove the 1:1 mapping. Note that this still doesn't make the Secondary CPUs path safe but it is not making it worst. Signed-off-by: Julien Grall --- It is very likely we will need to re-introduce the 1:1 mapping to cater secondary CPUs boot and suspend/resume. For now, the attempt is to make boot CPU path fully Arm Arm compliant. Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 80 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 16 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 0a5c3a8525..56e2d09ed4 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -158,6 +158,13 @@ past_zImage: ldr r0, =primary_switched mov pc, r0 primary_switched: + /* + * The 1:1 map may clash with other parts of the Xen virtual memory + * layout. As it is not used anymore, remove it completely to + * avoid having to worry about replacing existing mapping + * afterwards. + */ + bl remove_identity_mapping bl setup_fixmap #ifdef CONFIG_EARLY_PRINTK /* Use a virtual address to access the UART. */ @@ -474,12 +481,62 @@ enable_mmu: mov pc, lr ENDPROC(enable_mmu) -setup_fixmap: +/* + * Remove the 1:1 map for the page-tables. It is not easy to keep track + * where the 1:1 map was mapped, so we will look for the top-level entry + * exclusive to the 1:1 map and remove it. + * + * Inputs: + * r9 : paddr(start) + * + * Clobbers r0 - r3 + */ +remove_identity_mapping: + /* r2:r3 := invalid page-table entry */ + mov r2, #0x0 + mov r3, #0x0 /* - * Now we can install the fixmap and dtb mappings, since we - * don't need the 1:1 map any more + * Find the first slot used. Remove the entry for the first + * table if the slot is not 0. For slot 0, the 1:1 mapping was + * done in the second table. */ - dsb + lsr r1, r9, #FIRST_SHIFT + mov_w r0, LPAE_ENTRY_MASK + ands r1, r1, r0 /* r1 := first slot */ + beq 1f + /* It is not in slot 0, remove the entry */ + ldr r0, =boot_pgtable /* r0 := root table */ + lsl r1, r1, #3 /* r1 := Slot offset */ + strd r2, r3, [r0, r1] + b identity_mapping_removed + +1: + /* + * Find the second slot used. Remove the entry for the first + * table if the slot is not 1 (runtime Xen mapping is 2M - 4M). + * For slot 1, it means the 1:1 mapping was not created. + */ + lsr r1, r9, #SECOND_SHIFT + mov_w r0, LPAE_ENTRY_MASK + and r1, r1, r0 /* r1 := second slot */ + cmp r1, #1 + beq identity_mapping_removed + /* It is not in slot 1, remove the entry */ + ldr r0, =boot_second /* r0 := second table */ + lsl r1, r1, #3 /* r1 := Slot offset */ + strd r2, r3, [r0, r1] + +identity_mapping_removed: + /* See asm-arm/arm32/flushtlb.h for the explanation of the sequence. */ + dsb nshst + mcr CP32(r0, TLBIALLH) + dsb nsh + isb + + mov pc, lr +ENDPROC(remove_identity_mapping) + +setup_fixmap: #if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ /* Add UART to the fixmap table */ ldr r1, =xen_fixmap /* r1 := vaddr (xen_fixmap) */ @@ -501,19 +558,10 @@ setup_fixmap: mov r4, r4, lsr #(SECOND_SHIFT - 3) /* r4 := Slot for FIXMAP(0) */ mov r3, #0x0 strd r2, r3, [r1, r4] /* Map it in the fixmap's slot */ -#endif - - /* - * Flush the TLB in case the 1:1 mapping happens to clash with - * the virtual addresses used by the fixmap or DTB. - */ - dsb /* Ensure any page table updates made above - * have occurred. */ - isb - mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLB */ - dsb /* Ensure completion of TLB flush */ - isb + /* Ensure any page table updates made above have occurred. */ + dsb nshst +#endif mov pc, lr ENDPROC(setup_fixmap) From patchwork Mon Jul 22 21:39: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: 169464 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013802ilk; Mon, 22 Jul 2019 14:43:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfQBrABjmzmqC0bjsmlTXhYSOO6HU8deucfmx1CxOOfe0DPSf7GF+yeH/xtJEup4plTOrP X-Received: by 2002:a5d:9690:: with SMTP id m16mr65406759ion.180.1563831795238; Mon, 22 Jul 2019 14:43:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831795; cv=none; d=google.com; s=arc-20160816; b=T8tCpOqsNFievOx9H4MkW31fVwZf+JeaJIOrzitxzUYT4cBHXEo105auGAesScehN7 yWDkcSeIlUFkZwpF24eOFpqzoka6Xtdyr0PMW9Zcyx6vzr3b7y+D21IezhzgBnsDYEjQ NoIcaRlm7IKammP4oSSRmh4KZ0zgsqIH3FDfrlfF0hd936utB5isuOy9A2w9jqMIcSdz rLhZ/oh7AaKCE8/8U8XEeeanqolpxr1Rye2FKh/fxjN2gTnHCi+wvrfO8OwxhM0bJ3xM QMdxAm4v5APbftWzA2uLGJdhscmK1GPplVV7GyWp5k/3ZeOy/c+GQIxc1cKXeZzMOYBY 5iaQ== 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=r9pyIZWuzdG5YzfEaeWPmu54CzQpvvqP4bt3g12QN1A=; b=u7BTxDdbJokpVmCSJyUXJzILpyYlz1iDlxZGNegDSdp2swE+bLveatR1LkA+aUo8Gh lSkIjqpagML+xvbrdsg7ZPYJb+IW+e4hqnclVuRMiDUKhBOCJ6N3lET9E2iQ9qmH0S7C ZjaMDJZL3RqcYvJqgO9JiFgCPNxv4K4EUQ4G4yUCM7zY0G9qk0j5ggrqs/Y3dIykaU5O YrBa8lxcW3OMM74dkkTF8Ej0/ByaFadGZG608oQJsAJPlqQadZ6SMgOK+CKNi8j7lnc1 Y9rZ9k6KMwM054jOvrwZxqo66fmC60MJXTVpwLXnzx7HkOzUHTf7NbgvVAi2EEffW8Pd aLKQ== 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 y7si64604107jai.31.2019.07.22.14.43.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:43:15 -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 1hpg30-0003Sc-SF; Mon, 22 Jul 2019 21:40:42 +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 1hpg2u-0003CT-CQ for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:36 +0000 X-Inumbo-ID: 5642fb6e-acc9-11e9-b4fb-3fed55cc5072 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 5642fb6e-acc9-11e9-b4fb-3fed55cc5072; Mon, 22 Jul 2019 21:40:34 +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 97362153B; Mon, 22 Jul 2019 14:40:34 -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 E56193F71F; Mon, 22 Jul 2019 14:40:33 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:55 +0100 Message-Id: <20190722213958.5761-33-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 32/35] xen/arm32: head: Rework and document setup_fixmap() 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" At the moment, the fixmap table is only hooked when earlyprintk is used. This is fine today because in C land, the fixmap is not used by anyone until the the boot CPU is switching to the runtime page-tables. In the future, the boot CPU will not switch between page-tables to avoid TLB incoherency. Thus, the fixmap table will need to be always hooked beofre any use. Let's start doing it now in setup_fixmap(). Lastly, document the behavior and the main registers usage within the function. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 56e2d09ed4..e0f8c2e0cb 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -536,8 +536,21 @@ identity_mapping_removed: mov pc, lr ENDPROC(remove_identity_mapping) +/* + * Map the UART in the fixmap (when earlyprintk is used) and hook the + * fixmap table in the page tables. + * + * The fixmap cannot be mapped in create_page_tables because it may + * clash with the 1:1 mapping. + * + * Inputs: + * r10: Physical offset + * r11: Early UART base physical address + * + * Clobbers r1 - r4 + */ setup_fixmap: -#if defined(CONFIG_EARLY_PRINTK) /* Fixmap is only used by early printk */ +#if defined(CONFIG_EARLY_PRINTK) /* Add UART to the fixmap table */ ldr r1, =xen_fixmap /* r1 := vaddr (xen_fixmap) */ lsr r2, r11, #THIRD_SHIFT @@ -546,7 +559,7 @@ setup_fixmap: orr r2, r2, #PT_LOWER(DEV_L3) /* r2:r3 := 4K dev map including UART */ mov r3, #0x0 strd r2, r3, [r1, #(FIXMAP_CONSOLE*8)] /* Map it in the first fixmap's slot */ -1: +#endif /* Map fixmap into boot_second */ ldr r1, =boot_second /* r1 := vaddr (boot_second) */ @@ -561,7 +574,7 @@ setup_fixmap: /* Ensure any page table updates made above have occurred. */ dsb nshst -#endif + mov pc, lr ENDPROC(setup_fixmap) From patchwork Mon Jul 22 21:39:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169461 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013699ilk; Mon, 22 Jul 2019 14:43:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSqzaZClkeYl1H/CwrHWBi4ZF4tXbCG+N0QZlk4SpXojtPsDiMkz5W9BLfYi5D0mjwbwS/ X-Received: by 2002:a5e:9e42:: with SMTP id j2mr70953212ioq.133.1563831786705; Mon, 22 Jul 2019 14:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831786; cv=none; d=google.com; s=arc-20160816; b=hIJNAsXvvAQp+csrX45yT5wgpINuQ+ycsf6/rHGPmg+lK9Na9sl0/59hWMcRl61CVF pNqTfnb9QKBwf7dLy/RU6o3FXDi91fW3GoNgrZWeWDP+6rrxnVPhxHs9eXuArJXHNUHU NhxP8NsxArwId/Ej6Ofa0/qhMg+JQaET56b+19RZ0plvY2QEGzpI79O5KHWxeeBznjfa vm8StYJbtPyRL7vMtxxsLNy0KYiisOpR1peE6/qLyQv0iNKqUoNA2ZFeXrahiepE5YGq u8Wa1YvqU2DIrNIo0YPhxlZtD8sFC8v9r7qFkyYvqUKEzGz1DMvZ76hyLVBTZDTaLF1v /7eQ== 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=Geqm5qW5jXfHQLBeqqIa43haMdeJ2G24/7A6JRTCq7g=; b=B0lu6Dn4R3Mh6GdIRHIxIpfSgJXmbQG0sghHLqGa0aYeZJzjs5LjILoZZ4RL6w1U4+ Dk5eZ2GZbSObRtru/a9R4XR1LWdUYJIkGQbchuwGKHSb7zCqqQT3px0nMfkylgiMk2Vw DNb9MF276IyuZ6Egv/+jNGwZbPJIjhpBczq13UTqaybnwNOFQSCERfCiAGnVSqLrzRKf l94r8Bi5HO0pnJAN3GcPo5+uofmBh4sdQEXwfQkT2Wwzw7oAcNIZPu6dUAv1W8XnLUjk +BjDEzFEwCKWjf3B/C02LaPJnTEroDXJY3Yd0qcaw4zLH6hehVgKJUuZ55mnub4jKUHx mBfg== 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 i9si56265765jam.38.2019.07.22.14.43.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:43:06 -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 1hpg34-0003bm-OX; Mon, 22 Jul 2019 21:40:46 +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 1hpg2v-0003FY-KM for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:37 +0000 X-Inumbo-ID: 56e18d9c-acc9-11e9-a3cc-5319c96131f2 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 56e18d9c-acc9-11e9-a3cc-5319c96131f2; Mon, 22 Jul 2019 21:40:35 +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 7D1291597; Mon, 22 Jul 2019 14:40:35 -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 CB1EA3F71F; Mon, 22 Jul 2019 14:40:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:56 +0100 Message-Id: <20190722213958.5761-34-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 33/35] xen/arm32: 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 using conditional instruction and make the call 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: - Patch added --- xen/arch/arm/arm32/head.S | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index e0f8c2e0cb..6d55a2119a 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -170,6 +170,11 @@ primary_switched: /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS #endif + PRINT("- Ready -\r\n") + /* Setup the arguments for start_xen and jump to C world */ + mov r0, r10 /* r0 := Physical offset */ + mov r1, r8 /* r1 := paddr(FDT) */ + ldr r2, =start_xen b launch ENDPROC(start) @@ -234,6 +239,9 @@ secondary_switched: /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS #endif + PRINT("- Ready -\r\n") + /* Jump to C world */ + ldr r2, =start_secondary b launch ENDPROC(init_secondary) @@ -578,19 +586,25 @@ setup_fixmap: mov pc, lr ENDPROC(setup_fixmap) +/* + * Setup the initial stack and jump to the C world + * + * Inputs: + * r0 : Argument 0 of the C function to call + * r1 : Argument 1 of the C function to call + * r2 : C entry point + * + * Clobbers r3 + */ launch: - PRINT("- Ready -\r\n") - - ldr r0, =init_data - add r0, #INITINFO_stack /* Find the boot-time stack */ - ldr sp, [r0] + ldr r3, =init_data + add r3, #INITINFO_stack /* Find the boot-time stack */ + ldr sp, [r3] add sp, #STACK_SIZE /* (which grows down from the top). */ sub sp, #CPUINFO_sizeof /* Make room for CPU save record */ - teq r12, #0 - moveq r0, r10 /* Marshal args: - phys_offset */ - moveq r1, r8 /* - DTB address */ - beq start_xen /* and disappear into the land of C */ - b start_secondary /* (to the appropriate entry point) */ + + /* Jump to C world */ + bx r2 ENDPROC(launch) /* Fail-stop */ From patchwork Mon Jul 22 21:39:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169462 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013745ilk; Mon, 22 Jul 2019 14:43:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNvrqDApxhGygjSw6amNoLRas0PkcXVmCIUK0vtB37pbpkOmm7NiHKANJ/ulCE3f8T/GNh X-Received: by 2002:a02:a703:: with SMTP id k3mr7854815jam.12.1563831790729; Mon, 22 Jul 2019 14:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831790; cv=none; d=google.com; s=arc-20160816; b=rS7hzl/D0332dYULJ1dVStkEm5Zylfneio0mEWP9/xDE4BGSSd4zI8k0bhB6iaVncd oRZ1vzH1cetaPTlzP1aGnIe8A9G8jZhUFmfaZibmy/ffXSHDVmpkK1i+CRb7jordMHCr hZ0sgw1FNbmSEXGr5mWYjAU/UTKZElxd+B6sOE9Mbm0unYEvwDsi4Ko0/P/M3LqfwPDh rp4hHiCKwmWuk5iu1PO1BtTSd4To8nqoim848DXCJOi52aWqXsi3cUgVQ2dC8e0Fd355 Cu+jsLymFUJFD0xC52sJn1QTr+SQOXT4NpIMG1uou/nqCz4rGQ1xA/g9zZr4FEbkc6r1 kf8w== 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=hmWIz5ogPPLs5qmaPa4ILWUhKz6a6BMsjOdCn/hWddY=; b=aMtDOdD95AJaRh4sXUsyuhhRh6XfO8qfeMAkLjzG92WxgRdLGwzeBtyFJltBtA7blr ctS6Uhhu1vom7hzn1zITRY9f1Mb/E9ceiuCLfFltc4D9UVNzQMoSeyNI0V0k8uelVuNo FwNioL+ELT0nft0MKDxPcdj/P3re2OL0tcqwK1L7X8AhBZ9a5pEeMr7LT4VHOUZvCtPe U2NsaRQgrK12ehf7Ni7MeRhSkmNPya7s/Q2uF8AENGOIT5LgHsu4HAnYwYCQ/cfsa58O I3ZA3SV8fibAb2uGKsznmXTAsEcKdSI2nvUtt3zlZC8DX7HN5iLMmqsolsx6JVN2Iajk KpzA== 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 e8si63452114jaj.110.2019.07.22.14.43.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:43:10 -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 1hpg33-0003Y1-63; Mon, 22 Jul 2019 21:40:45 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hpg2v-0003Fv-QZ for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:37 +0000 X-Inumbo-ID: 574d476e-acc9-11e9-8980-bc764e045a96 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTP id 574d476e-acc9-11e9-8980-bc764e045a96; Mon, 22 Jul 2019 21:40:36 +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 634521595; Mon, 22 Jul 2019 14:40:36 -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 B15533F71F; Mon, 22 Jul 2019 14:40:35 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:57 +0100 Message-Id: <20190722213958.5761-35-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 34/35] xen/arm32: head: Setup HTTBR in enable_mmu() and add missing isb 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" At the moment, HTTBR is setup in create_page_tables(). This is fine as it is called by every CPUs. However, such assumption may not hold in the future. To make change easier, the HTTBR is not setup in enable_mmu(). Take the opportunity to add the missing isb() to ensure the HTTBR is seen before the MMU is turned on. Signed-off-by: Julien Grall --- Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 6d55a2119a..8a1e272aab 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -373,8 +373,6 @@ create_page_tables: /* Write Xen's PT's paddr into the HTTBR */ ldr r4, =boot_pgtable add r4, r4, r10 /* r4 := paddr (boot_pagetable) */ - mov r5, #0 /* r4:r5 is paddr (boot_pagetable) */ - mcrr CP64(r4, r5, HTTBR) /* Setup boot_pgtable: */ ldr r1, =boot_second @@ -480,6 +478,12 @@ enable_mmu: mcr CP32(r0, TLBIALLH) /* Flush hypervisor TLBs */ dsb nsh + ldr r0, =boot_pgtable + add r0, r0, r10 /* r0 := paddr (boot_pagetable) */ + mov r1, #0 /* r0:r1 is paddr (boot_pagetable) */ + mcrr CP64(r0, r1, HTTBR) + isb + mrc CP32(r0, HSCTLR) /* Enable MMU and D-cache */ orr r0, r0, #(SCTLR_Axx_ELx_M|SCTLR_Axx_ELx_C) From patchwork Mon Jul 22 21:39:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 169463 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8013786ilk; Mon, 22 Jul 2019 14:43:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfJbaerhh2ugkTePB4hViX6jEkZqXnWEQgUI21TFWi+I7cib/DAawumxUdaFCIPHhSUN9g X-Received: by 2002:a6b:f114:: with SMTP id e20mr65961372iog.169.1563831793578; Mon, 22 Jul 2019 14:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563831793; cv=none; d=google.com; s=arc-20160816; b=Z7Wiy/FBGsKL6kyx1J5lOjHmRaJtn6wAquRkBeCteHczrZ4P7oA6ZKO0q7Xjqop6s+ MeZXhKJ4tdtir89bojnvUNs3b3ovJva1JKKp+g0aRZBUjb1k6g4K5LLMDc8Mf4gPt/d0 LBYEWP9sNexGcQpwkNIwENWW9mKqYd7Cr/6ziKzsZ4dPZJvLOZOZkFRcB3gZGdPHL0pB bC80t8erBzPcfQAiZiOIOPOCsyT9F8Lk9XVWNJeXTfhOcVJOjwGqNlnxLIVFaLqwIHGr jKt4K2LchVdMa1bcWn3af7lFUZkP+JdQ4hz2xCZq1fEF565hnVxmbfkMzJ9Y3DhYcUa1 uhEA== 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=KtQc7tHN5UmjaDs716P4zEWpO1gE6jZxS/NZMglV3do=; b=Ay0cZ9l+X5uPUmfNBlwA2cxuis5Yvliya/SxlCD+/gp48UQunqTm2gGp/I9nx+ypSw AbMUI4eQJRrclzdyZQGon2n6C4CaSgthPxI8bS8C7Coc1RLTu7uc9wybIlnwzJi1k2C9 Sv8jsEL/WBF4RB5qymWsKI66l7FFKZzpEzbWpqNaFxkdmQIPo7cS+m5Gag0WJ77xZO/j cn5N3N4VmBSW8ns6pnyAFzSmOxL+llw2bIz4EdT7AlzCOURJFlb5pQQ9UCMxFem/EHPN 0IvIkgI9J2N79MQNvLgGZJ7LLbv4ljTSgXttQM2xCQDbzRbo+pdA9IBiRrE5YHWRfMQ9 U3Iw== 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 b25si662417jap.97.2019.07.22.14.43.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2019 14:43:13 -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 1hpg36-0003gb-MO; Mon, 22 Jul 2019 21:40:48 +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 1hpg2x-0003L7-Rw for xen-devel@lists.xenproject.org; Mon, 22 Jul 2019 21:40:39 +0000 X-Inumbo-ID: 57dc0934-acc9-11e9-854b-cf3f7e8ca122 Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 57dc0934-acc9-11e9-854b-cf3f7e8ca122; Mon, 22 Jul 2019 21:40:37 +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 4931F1509; Mon, 22 Jul 2019 14:40: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 9740D3F71F; Mon, 22 Jul 2019 14:40:36 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 22 Jul 2019 22:39:58 +0100 Message-Id: <20190722213958.5761-36-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 35/35] xen/arm: Zero BSS after the MMU and D-cache is turned on 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" At the moment BSS is zeroed before the MMU and D-Cache is turned on. In other words, the cache will be bypassed when zeroing the BSS section. On Arm64, per the Image protocol [1], the state of the cache for BSS region is not known because it is not part of the "loaded kernel image". On Arm32, the boot protocol [2] does not mention anything about the state of the cache. Therefore, it should be assumed that it is not known for BSS region. This means that the cache will need to be invalidated twice for the BSS region: 1) Before zeroing to remove any dirty cache line. Otherwise they may get evicted while zeroing and therefore overriding the value. 2) After zeroing to remove any cache line that may have been speculated. Otherwise when turning on MMU and D-Cache, the CPU may see old values. At the moment, the only reason to have BSS zeroed early is because the boot page tables are part of it. To avoid the two cache invalidations, it would be better if the boot page tables are part of the "loaded kernel image" and therefore be zeroed when loading the image into memory. A good candidate is the section .data.page_aligned. A new macro DEFINE_BOOT_PAGE_TABLE is introduced to create and mark page-tables used before BSS is zeroed. This includes all boot_* but also xen_fixmap as zero_bss() will print a message when earlyprintk is enabled. [1] linux/Documentation/arm64/booting.txt [2] linux/Documentation/arm/Booting Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add missing signed-off - Clarify commit message - Add arm32 parts --- xen/arch/arm/arm32/head.S | 11 +++-------- xen/arch/arm/arm64/head.S | 7 +++---- xen/arch/arm/mm.c | 23 +++++++++++++++++------ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index 8a1e272aab..48cad6103f 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -149,7 +149,6 @@ past_zImage: mov r12, #0 /* r12 := is_secondary_cpu */ bl check_cpu_mode - bl zero_bss bl cpu_init bl create_page_tables bl enable_mmu @@ -170,6 +169,7 @@ primary_switched: /* Use a virtual address to access the UART. */ mov_w r11, EARLY_UART_VIRTUAL_ADDRESS #endif + bl zero_bss PRINT("- Ready -\r\n") /* Setup the arguments for start_xen and jump to C world */ mov r0, r10 /* r0 := Physical offset */ @@ -280,17 +280,12 @@ ENDPROC(check_cpu_mode) /* * Zero BSS * - * Inputs: - * r10: Physical offset - * * Clobbers r0 - r3 */ zero_bss: PRINT("- Zero BSS -\r\n") - ldr r0, =__bss_start /* Load start & end of bss */ - ldr r1, =__bss_end - add r0, r0, r10 /* Apply physical offset */ - add r1, r1, r10 + ldr r0, =__bss_start /* r0 := vaddr(__bss_start) */ + ldr r1, =__bss_end /* r1 := vaddr(__bss_start) */ mov r2, #0 1: str r2, [r0], #4 diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S index 2287f3ce48..b671e0e59f 100644 --- a/xen/arch/arm/arm64/head.S +++ b/xen/arch/arm/arm64/head.S @@ -303,7 +303,6 @@ real_start_efi: mov x22, #0 /* x22 := is_secondary_cpu */ bl check_cpu_mode - bl zero_bss bl cpu_init bl create_page_tables bl enable_mmu @@ -324,6 +323,7 @@ primary_switched: /* Use a virtual address to access the UART. */ ldr x23, =EARLY_UART_VIRTUAL_ADDRESS #endif + bl zero_bss PRINT("- Ready -\r\n") /* Setup the arguments for start_xen and jump to C world */ mov x0, x20 /* x0 := Physical offset */ @@ -426,7 +426,6 @@ ENDPROC(check_cpu_mode) * Zero BSS * * Inputs: - * x20: Physical offset * x26: Do we need to zero BSS? * * Clobbers x0 - x3 @@ -436,8 +435,8 @@ zero_bss: cbnz x26, skip_bss PRINT("- Zero BSS -\r\n") - load_paddr x0, __bss_start /* Load paddr of start & end of bss */ - load_paddr x1, __bss_end + ldr x0, =__bss_start /* x0 := vaddr(__bss_start) */ + ldr x1, =__bss_end /* x1 := vaddr(__bss_start) */ 1: str xzr, [x0], #8 cmp x0, x1 diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 44258ad89c..670a3089ea 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -62,6 +62,17 @@ mm_printk(const char *fmt, ...) {} } while (0); #endif +/* + * Macros to define page-tables: + * - DEFINE_BOOT_PAGE_TABLE is used to define page-table that are used + * in assembly code before BSS is zeroed. + * - DEFINE_PAGE_TABLE{,S} are used to define one or multiple + * page-tables to be used after BSS is zeroed (typically they are only used + * in C). + */ +#define DEFINE_BOOT_PAGE_TABLE(name) \ +lpae_t __aligned(PAGE_SIZE) __section(".data.page_aligned") name[LPAE_ENTRIES] + #define DEFINE_PAGE_TABLES(name, nr) \ lpae_t __aligned(PAGE_SIZE) name[LPAE_ENTRIES * (nr)] @@ -90,13 +101,13 @@ lpae_t __aligned(PAGE_SIZE) name[LPAE_ENTRIES * (nr)] * Finally, if EARLY_PRINTK is enabled then xen_fixmap will be mapped * by the CPU once it has moved off the 1:1 mapping. */ -DEFINE_PAGE_TABLE(boot_pgtable); +DEFINE_BOOT_PAGE_TABLE(boot_pgtable); #ifdef CONFIG_ARM_64 -DEFINE_PAGE_TABLE(boot_first); -DEFINE_PAGE_TABLE(boot_first_id); +DEFINE_BOOT_PAGE_TABLE(boot_first); +DEFINE_BOOT_PAGE_TABLE(boot_first_id); #endif -DEFINE_PAGE_TABLE(boot_second); -DEFINE_PAGE_TABLE(boot_third); +DEFINE_BOOT_PAGE_TABLE(boot_second); +DEFINE_BOOT_PAGE_TABLE(boot_third); /* Main runtime page tables */ @@ -149,7 +160,7 @@ static __initdata int xenheap_first_first_slot = -1; */ static DEFINE_PAGE_TABLES(xen_second, 2); /* First level page table used for fixmap */ -DEFINE_PAGE_TABLE(xen_fixmap); +DEFINE_BOOT_PAGE_TABLE(xen_fixmap); /* First level page table used to map Xen itself with the XN bit set * as appropriate. */ static DEFINE_PAGE_TABLE(xen_xenmap);