From patchwork Thu Jul 7 10:33:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 71570 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1330290qgy; Thu, 7 Jul 2016 03:36:02 -0700 (PDT) X-Received: by 10.36.149.69 with SMTP id m66mr1956930itd.85.1467887762065; Thu, 07 Jul 2016 03:36:02 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id u82si2990823itb.50.2016.07.07.03.36.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jul 2016 03:36:02 -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 1bL6cr-0002Cn-34; Thu, 07 Jul 2016 10:33:45 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bL6cp-0002Cg-PH for xen-devel@lists.xen.org; Thu, 07 Jul 2016 10:33:43 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 15/95-08132-7003E775; Thu, 07 Jul 2016 10:33:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrALMWRWlGSWpSXmKPExsVysyfVTZfNoC7 c4HKngsWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmjFlznemgh2CFb9/fWFsYHzM28XIxSEksJFR 4lV3EzuEc5pR4mXDMtYuRk4ONgFNiTufPzGB2CIC0hLXPl9mBCliFmhjlFg7eyojSEJYIFxi3 bUpYDaLgKpEy+ljYM28As4Ss7+0sIPYEgJyEiePTWadwMi5gJFhFaNGcWpRWWqRrrGBXlJRZn pGSW5iZo6uoaGJXm5qcXFiempOYlKxXnJ+7iZGoM/qGRgYdzDuv+R3iFGSg0lJlHfP3dpwIb6 k/JTKjMTijPii0pzU4kOMMhwcShK8E/TqwoUEi1LTUyvSMnOAwQOTluDgURLhXQ+S5i0uSMwt zkyHSJ1iVJQS5w0GSQiAJDJK8+DaYAF7iVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5IwbyPIF J7MvBK46a+AFjMBLf7pUg2yuCQRISXVwHiEx+LRonVOb3blXtHbH1/W35d7f+oEsZ9mS3x/ps 6vyl2QZatX9YP/ht18RY7Nc15rHI4O/HFo187Gd5P/GDGeNEwKecqrtOFzfur/yxbXXO5N+5y 5l5Gz+cqmN5P/G/2y2lZXVbMmJTKiSnLeDO6Jmr08rgzyK5YwlE+atevU5nV1Wff4DEKVWIoz Eg21mIuKEwFVWICeUwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1467887621!52101459!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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 62378 invoked from network); 7 Jul 2016 10:33:42 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-27.messagelabs.com with SMTP; 7 Jul 2016 10:33:42 -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 EC96728; Thu, 7 Jul 2016 03:34:40 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.215.28]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 431C43F41F; Thu, 7 Jul 2016 03:33:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 7 Jul 2016 11:33:35 +0100 Message-Id: <1467887615-9824-1-git-send-email-julien.grall@arm.com> X-Mailer: git-send-email 1.9.1 Cc: andre.przywara@arm.com, Julien Grall , sstabellini@kernel.org, steve.capper@arm.com, wei.chen@linaro.org Subject: [Xen-devel] [PATCH] xen/arm64: Use the correct TLBs flush instruction to nuke stage-2 TLBs 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 function flush_tlb is called to invalidate the TLBs for the current domain when the stage-2 page tables are modified. On ARMv8, the instruction "tlbi vmalle1is" (resp. "tlbi vmalle1") will invalidate stage 1 entries associated to the current VMID (see D4-1811 in ARM DDI 0487A.j). Given that an implementation is allowed to cache separately stage 1 and stage 2 translation (see D4.7.1), the instructions will not remove stage 2 entries when the translation is not combined in a single entry. This will result the TLBs to hold invalid entries and possibly multiple entries using the same VA. Use "tlbi vmall12e1is" (resp. "tlbi vmall12e1"), to flush both stage 1 and stage 2 entries when the domain p2m is changed. Also modify flush_tlb_local to invalidate stage 1 and 2 for the local TLBs. Note that this function is used in the instruction abort path before translating a GVA to a IPA. As far as I understand is to avoid a guest poisoning the DTLB when memacces is in use. We might be able to only invalidate stage 1 entries. However, I choose the safest way for now (i.e invalidating stage 1 and 2 entries). We would need to introduce a new set of helpers when we will want to restrict it. Signed-off-by: Julien Grall --- This would need to be backported on any version of Xen currently supported (IIRC think up to Xen 4.5). Without this patch, stage 2 TLBs won't be flushed if the TLBs cache intermediate translations entries (IPA -> PA). --- xen/include/asm-arm/arm64/flushtlb.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/include/asm-arm/arm64/flushtlb.h b/xen/include/asm-arm/arm64/flushtlb.h index a73df92..942f2d3 100644 --- a/xen/include/asm-arm/arm64/flushtlb.h +++ b/xen/include/asm-arm/arm64/flushtlb.h @@ -6,7 +6,7 @@ static inline void flush_tlb_local(void) { asm volatile( "dsb sy;" - "tlbi vmalle1;" + "tlbi vmalls12e1;" "dsb sy;" "isb;" : : : "memory"); @@ -17,7 +17,7 @@ static inline void flush_tlb(void) { asm volatile( "dsb sy;" - "tlbi vmalle1is;" + "tlbi vmalls12e1is;" "dsb sy;" "isb;" : : : "memory");