From patchwork Mon Aug 12 17:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 171152 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp511490ily; Mon, 12 Aug 2019 23:54:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV++gU5n28WOKutmbbloKjKNWqMd5mc5dOTbmdNeb0EKOT7zF5sdjYKiekAJxjUH5kwYZd X-Received: by 2002:a05:6638:627:: with SMTP id h7mr1188716jar.33.1565679265316; Mon, 12 Aug 2019 23:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565679265; cv=none; d=google.com; s=arc-20160816; b=ELDoumW+2USZuSlpya36idPTU0D7jh3Tn43mQ389JP3umb6wINvUuboxMKrL8jkYx4 B8/kTznqKQzeyxatMnThjk989gXt4Wt0kvtnfoYyrO1gwqFw/M+t3Rv4q4rnWP5rgHOU bcbAgfFYbZe00G53GpDftMZSfAspdk9RZxd1MycqlVjROA2EWi7mHBJfB/2k7gCp25rS pgIXe0Ddgexv+p806a/MlujrypwFtDjHdXDaAnZ4nIXB2fTP23sj7TrhGISz0olVc+W4 60tLwjrkldg6V/ICunYcEnDem/bzS+me0G+MJuMozmRg7e/HKeZEJ/GEjX9UOvb4REu+ 5v1w== 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=ARvSkFI7OOOjpaPsrN+aZQd0Z5VfNtsngXzzBvrE56I=; b=dbd2dpqoXTKl5VRK0D7gqVaS5oxCg5MkCPhfabUyR6UBnphRuZ3TEN7scz0ybBv9Z4 qLIoBSJ+puKyj9ZwF153ph8b25ANwsrINI1WuD/T+cptBLstFFjp5FeCcnoJYMvPTqQY H90Z8Pfq/sFBmvq2YEGiVqDAEcWect4MH0X6SimxvX5gipVGxH4GP8lcm8gTa05h0Owe FcjBNdCERmkBBV7LfMvTkEHUKJ4qKqymyNS4aepMez8+8SVN0M7SZgMUR4CjW9oZFUK8 fb4blBp2n+1n9EMRta0z1JGGgKK2ddm0RMrsEHMxAg6Rlos3kWdptadnoZ/uNEemO+5W YKdg== 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 t130si69719125jaa.66.2019.08.12.23.54.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Aug 2019 23:54: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 1hxQgh-00029T-5W; Tue, 13 Aug 2019 06:53:43 +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 1hxQgf-00027A-BI for xen-devel@lists.xenproject.org; Tue, 13 Aug 2019 06:53:41 +0000 X-Inumbo-ID: e993ecda-bd26-11e9-8db2-43c97a43d94f Received: from foss.arm.com (unknown [217.140.110.172]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id e993ecda-bd26-11e9-8db2-43c97a43d94f; Mon, 12 Aug 2019 17:30:43 +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 88AEA1715; Mon, 12 Aug 2019 10:30:43 -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 D71353F706; Mon, 12 Aug 2019 10:30:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 12 Aug 2019 18:30:09 +0100 Message-Id: <20190812173019.11956-19-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812173019.11956-1-julien.grall@arm.com> References: <20190812173019.11956-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v3 18/28] 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 Reviewed-by: Stefano Stabellini --- Changes in v3: - There is no need to zero r5 Changes in v2: - Patch added --- xen/arch/arm/arm32/head.S | 41 +++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S index f8603051e4..0c95d1c432 100644 --- a/xen/arch/arm/arm32/head.S +++ b/xen/arch/arm/arm32/head.S @@ -202,6 +202,25 @@ 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 */ + 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) @@ -505,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]