From patchwork Wed Jul 20 16:11:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 72442 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp66412qga; Wed, 20 Jul 2016 09:14:08 -0700 (PDT) X-Received: by 10.36.139.68 with SMTP id g65mr52334783ite.0.1469031243371; Wed, 20 Jul 2016 09:14:03 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e5si17936960ith.80.2016.07.20.09.14.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jul 2016 09:14:03 -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 1bPu6A-0007t4-On; Wed, 20 Jul 2016 16:11:50 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bPu68-0007pN-LH for xen-devel@lists.xen.org; Wed, 20 Jul 2016 16:11:48 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id EC/84-21406-4C2AF875; Wed, 20 Jul 2016 16:11:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRWlGSWpSXmKPExsVysyfVTffwov5 wg9bLohZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aL5c8YC77wVtyadoWtgfE2VxcjF4eQwCZG icnT97FCOKcZJdb3z2buYuTkYBPQlLjz+RMTiC0iIC1x7fNlRpAiZoF2RonlG/+xgCSEBZIld h/7xgpiswioSpxaPAMszivgKrGuaQ07iC0hICdx8thksBpOoPj5kz8ZQWwhAReJTW+/MU9g5F 7AyLCKUb04tagstUjXUC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9DDDECwg3H nc6dDjJIcTEqivKqiveFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgXL+wPFxIsSk1PrUjLzAGG GkxagoNHSYT3OEiat7ggMbc4Mx0idYpRUUqcdxtIQgAkkVGaB9cGC+9LjLJSwryMQIcI8RSkF uVmlqDKv2IU52BUEuZtBZnCk5lXAjf9FdBiJqDFcwTAFpckIqSkGhinsoTdOMrTcdjqdr60xy Ozp4Wbtmks1WO5uL1YVHjjWiVRi7iv30SVi129lvp4zNvQJWVoP/l7hXXNgY2L5/L5WPPYqVe cP/GK15fp/xvW5qmbrqXs0XXk45h0uPuIftkf/QwWu0WLvau4XKMvifS7tK5I+SYSOyNO4dCB JgFPDc7jyUHftyixFGckGmoxFxUnAgDsG9UqagIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1469031106!18748555!1 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 61323 invoked from network); 20 Jul 2016 16:11:47 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-21.messagelabs.com with SMTP; 20 Jul 2016 16:11:47 -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 3C33EBFE; Wed, 20 Jul 2016 09:12:57 -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 911C83F387; Wed, 20 Jul 2016 09:11:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 20 Jul 2016 17:11:00 +0100 Message-Id: <1469031064-23344-19-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1469031064-23344-1-git-send-email-julien.grall@arm.com> References: <1469031064-23344-1-git-send-email-julien.grall@arm.com> Cc: proskurin@sec.in.tum.de, Julien Grall , sstabellini@kernel.org, wei.chen@linaro.org, steve.capper@arm.com Subject: [Xen-devel] [PATCH 18/22] 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 d1b6009..015c1e8 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); } }