From patchwork Thu Jul 28 14:20:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72964 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp880731qga; Thu, 28 Jul 2016 07:25:02 -0700 (PDT) X-Received: by 10.107.140.205 with SMTP id o196mr43082920iod.42.1469715898910; Thu, 28 Jul 2016 07:24:58 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e5si33474912ith.80.2016.07.28.07.24.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 07:24:58 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmB2-0007MB-Iq; Thu, 28 Jul 2016 14:20:44 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bSmB1-0007JT-0u for xen-devel@lists.xen.org; Thu, 28 Jul 2016 14:20:43 +0000 Received: from [85.158.137.68] by server-2.bemta-3.messagelabs.com id 43/30-01945-AB41A975; Thu, 28 Jul 2016 14:20:42 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTXenyKx wg5WHdCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyXP/4zFnzhrbizJaiB8TZXFyMXh5DAJkaJ W2e/skM4pxkl1n67y9LFyMnBJqApcefzJyYQW0RAWuLa58uMIEXMAu1ARf29zCAJYYE0idbO3 6wgNouAqsS9viVgNq+Ai8STlwfZQWwJATmJk8cmg8U5geL32r6D2UICzhKn725nn8DIvYCRYR WjRnFqUVlqka6hqV5SUWZ6RkluYmaOrqGBsV5uanFxYnpqTmJSsV5yfu4mRqCHGYBgB+Oa7Z6 HGCU5mJREecNCZ4YL8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuB1E54VLiRYlJqeWpGWmQMMNZi0 BAePkghvJEiat7ggMbc4Mx0idYpRUUqcNxckIQCSyCjNg2uDhfclRlkpYV5GoEOEeApSi3IzS 1DlXzGKczAqCfNuBJnCk5lXAjf9FdBiJqDFxbEzQBaXJCKkpBoY+3Nz5pnu3rbMPZJvrkzKl4 3e/3dYuF/+5aKhxSrSf/3F5DzW5Al/P+86/nDdsfoN6Qox7yTcd1w1F41b+PzdE6UFexv4H0x Um/z7btwUezuV/W4Gdns3/K23aJ4i95ptxiGOdKmnAT/3qr04dGnyYg7tXy5LNn9jOXIxyUDO LHZm3ob8O/GnapVYijMSDbWYi4oTAT+YXFNqAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1469715635!26646407!5 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44881 invoked from network); 28 Jul 2016 14:20:41 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-31.messagelabs.com with SMTP; 28 Jul 2016 14:20:41 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6AA32BBB; Thu, 28 Jul 2016 07:21:58 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.218.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3A3813F21A; Thu, 28 Jul 2016 07:20:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 28 Jul 2016 15:20:16 +0100 Message-Id: <1469715620-4670-12-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469715620-4670-1-git-send-email-julien.grall@arm.com> References: <1469715620-4670-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [PATCH v2 11/15] xen/arm: p2m: Rework the context switch to another VTTBR in flush_tlb_domain X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" The current implementation of flush_tlb_domain is relying on the domain to have a single p2m. With the upcoming feature altp2m, a single domain may have different p2m. So we would need to switch to the correct p2m in order to flush the TLBs. Rather than checking whether the domain is not the current domain, check whether the VTTBR is different. The resulting assembly code is much smaller: from 38 instructions (+ 2 functions call) to 22 instructions. Signed-off-by: Julien Grall --- xen/arch/arm/p2m.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index aff5906..7ee0171 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -151,24 +151,28 @@ void p2m_restore_state(struct vcpu *n) void flush_tlb_domain(struct domain *d) { + struct p2m_domain *p2m = &d->arch.p2m; unsigned long flags = 0; + uint64_t ovttbr; /* - * Update the VTTBR if necessary with the domain d. In this case, - * it's only necessary to flush TLBs on every CPUs with the current VMID - * (our domain). + * ARM only provides an instruction to flush TLBs for the current + * VMID. So switch to the VTTBR of a given P2M if different. */ - if ( d != current->domain ) + ovttbr = READ_SYSREG64(VTTBR_EL2); + if ( ovttbr != p2m->vttbr ) { local_irq_save(flags); - p2m_load_VTTBR(d); + WRITE_SYSREG64(p2m->vttbr, VTTBR_EL2); + isb(); } flush_tlb(); - if ( d != current->domain ) + if ( ovttbr != READ_SYSREG64(VTTBR_EL2) ) { - p2m_load_VTTBR(current->domain); + WRITE_SYSREG64(ovttbr, VTTBR_EL2); + isb(); local_irq_restore(flags); } }