From patchwork Thu Nov 23 18:32:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119540 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173166edl; Thu, 23 Nov 2017 10:34:24 -0800 (PST) X-Google-Smtp-Source: AGs4zMaX3BHQNuud560hMVfHf5UxBT4VGUCePo/XDHKmSME5rsqFmR4HK/dRb3W92NifdtY6OqzN X-Received: by 10.107.152.137 with SMTP id a131mr6058565ioe.168.1511462064817; Thu, 23 Nov 2017 10:34:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462064; cv=none; d=google.com; s=arc-20160816; b=NYvuWbHvp+HYSGv6UWqNVBHONawtPy/IY7lfVlP3xKH/O8po31Sz9IMctY3L3Ir8cs 6NJA6wW7qACvWrElmCGs9jxk5tAPKkfV2ldvi9w3zMRHhNWd+3TVm6iSj2UhLxcnMMPp 38yAvfDODAHUiFFzO37U4YyeHJcHoepeIvtQ2K0cjIOGvsi1w9TSU14TfsqP67X2e7Mx WkJ9CvOBU4E/ZT/+I/J9beFmtU3b8etQ86dxvpl9ms+ZLfzkLvhs0I+ssA+v9CDGUtOX Uq0OSPt0cNgm3K8HVrzioCqRlSkOUlEQGnbcCPfS8vnpq3TiaSO2p80w+dImw56DT8pF KA4g== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=Ta7MMkvR11k6A4cA7ntwCNg1hN1FtK8DARNo1HPnUIM=; b=jUxwO3EHR1l7nojCGZsz6WD0YLzUV+m+3Q4JCJOw+YeYFunuYtnXDuiNP3SkKR4smq 4XNXYtbhovDLHW4BsG1bvke7jkFkKmfeJKrT34m2ntfCPIqDIGXJ2Odm+nE6JfTik8pi hBPSfJtBhrVoQy6vDe7MEr1kWuTWubrU+5snZXzDZTjRCViAQp/AhqdvNQOnYIVbxits vOrG91JOJOKlOFSWfFu/Ygxr21p3GmNiBaZS8qHxYur9MIvYJoTwyjEisIuJhVHTM0tM BGAekogF1peopOBbmmJEEq5liDjuC1TSwZcWXJ9VPrZEra5QWSfMKrKAJ+ifcpTXyeog D4Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AxQ9K4FN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 188si15488351ioy.340.2017.11.23.10.34.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:24 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=AxQ9K4FN; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.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 1eHwIX-0005LH-2K; Thu, 23 Nov 2017 18:32:29 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHwIV-0005GM-Iv for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:27 +0000 Received: from [193.109.254.147] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id E1/4D-26583-B34171A5; Thu, 23 Nov 2017 18:32:27 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRWlGSWpSXmKPExsVyMbThoK6ViHi UwZV5+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bbr9eMBftFKjauusXewLhMoIuRi0NIYBKj xNpff5hAHBaBecwSx76sZgRxJAT6WSV6ptwHynAAOXkSsy7pdzFyAplpEsc2drFC2NUS1+bOZ AUpERJQk1jzJgpiaB+TxKGVJ1hA4mwCOhLrZtSClIsISEtc+3yZEcRmFoiXeDz1OhuILSyQIN Gw6BTYSBYBVYnD7/ewg7TyCthK3PgoArFJXmJX20WwEk6g8NEDH5ghttpIfP6sOIFRcAEjwyp GjeLUorLUIl1DE72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMBQYwCCHYzXNwYc YpTkYFIS5ZX5JRYlxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXV1g8SkiwKDU9tSItMwcY9DBpC Q4eJRHeNJA0b3FBYm5xZjpE6hSjPceFO5f+MHEc2HMLSD6b+bqBmWPa1dYmZiGWvPy8VClxXk +QNgGQtozSPLihsCi9xCgrJczLCHSmEE9BalFuZgmq/CtGcQ5GJWHet0JAU3gy80rgdr8COos J6Kyfx4VBzipJREhJNTAGJlcGzI9ZMffr9PBN8VFd35oYI5uvlCXkG+bPSObefqe03bOsQnrK vJeM10q9nPPbza+ar2K7Vyr57MmvqdftXaIVkst8DrJWfC5IFntwv6/9s5dd1acp077naN0pf 6c4xZtpJg9PgdmjwvjF9vW2d3Zy31+6NcWIk838hjJf5MniCV42JUosxRmJhlrMRcWJANgxlI LNAgAA X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1511461946!86077051!1 X-Originating-IP: [209.85.128.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 60502 invoked from network); 23 Nov 2017 18:32:26 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:26 -0000 Received: by mail-wr0-f193.google.com with SMTP id r2so11880555wra.13 for ; Thu, 23 Nov 2017 10:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OALbocxEW05El2yhHyd/LYeU+h70nklR+nhp/ggr13o=; b=AxQ9K4FNOZYQPeGsyxS56UHUuiIPCi1tfk15CXYjUEiXuNoBV6pwcCb0BgModVJtlE HTxrRwf9qq9vC3RUvchfQJPGszdJRDCajhcPZYZ4as+cCMwUEp6CKwAKszyumzzEGfDr JII+9epsL4adRFDw+vVHHHrXCo8la0GyakFWY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OALbocxEW05El2yhHyd/LYeU+h70nklR+nhp/ggr13o=; b=nMRxzwtYi3J1D2YweYKOMqsAMJMiunE3OdOCurwmHOSXe+1cDA/bv2pSwsYdXw6xJJ RBL8QGGHDg1D27aH80vNfiZW6GTbyOrzu/drPLoDC3irAFVEoIFbnT6FG4rWZ0Ok2x8g 1niJ8tUa0EgTjA3ohKTeA5r3A1/ETMZVowP2bwejOQOPrRuqRPVe/QUA79Mj9bGAGapw qnVJ9/DxIjHp14Ycwr7zyTTTKxw0ljYBfyfAEkUaVxr8k+SEh2qfPY3tZQuci3aFhsik uj/OFuSSjIvTvJZZMPPlYLRR4ayeZJH//EkLM6+6pQ3v+lszoPeebj453W6Zcq6mYmxM ioXA== X-Gm-Message-State: AJaThX5BhChdzZ5XQR/jA0U9QWxTyjhkyuu66QArbzMTE23JAIfM0AVp HgpSSrKo8qctZ3qYqnGWJMTjS8SUY4A= X-Received: by 10.223.178.130 with SMTP id g2mr21122968wrd.129.1511461946181; Thu, 23 Nov 2017 10:32:26 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n32sm41412950wrb.62.2017.11.23.10.32.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:25 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:06 +0000 Message-Id: <20171123183210.12045-13-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171123183210.12045-1-julien.grall@linaro.org> References: <20171123183210.12045-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [PATCH for-next 12/16] xen/arm: p2m: Introduce p2m_tlb_flush_sync, export it and use it X-BeenThere: xen-devel@lists.xenproject.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.xenproject.org Sender: "Xen-devel" Multiple places in the code requires to flush the TLBs wonly when p2m->need_flush is set. Rather than open-coding it, introduce a new helper p2m_tlb_flush_sync to do it. Note that p2m_tlb_flush_sync is exported as it might be used by other part of Xen. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- xen/arch/arm/p2m.c | 27 +++++++++++++-------------- xen/include/asm-arm/p2m.h | 2 ++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index d466a5bc43..37498d8ff1 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -52,21 +52,15 @@ static const paddr_t level_masks[] = static const uint8_t level_orders[] = { ZEROETH_ORDER, FIRST_ORDER, SECOND_ORDER, THIRD_ORDER }; -static void p2m_tlb_flush(struct p2m_domain *p2m); - /* Unlock the flush and do a P2M TLB flush if necessary */ void p2m_write_unlock(struct p2m_domain *p2m) { - if ( p2m->need_flush ) - { - p2m->need_flush = false; - /* - * The final flush is done with the P2M write lock taken to - * to avoid someone else modify the P2M before the TLB - * invalidation has completed. - */ - p2m_tlb_flush(p2m); - } + /* + * The final flush is done with the P2M write lock taken to avoid + * someone else modifying the P2M wbefore the TLB invalidation has + * completed. + */ + p2m_tlb_flush_sync(p2m); write_unlock(&p2m->lock); } @@ -178,6 +172,12 @@ static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) p2m->need_flush = false; } +void p2m_tlb_flush_sync(struct p2m_domain *p2m) +{ + if ( p2m->need_flush ) + p2m_force_tlb_flush_sync(p2m); +} + /* * Find and map the root page table. The caller is responsible for * unmapping the table. @@ -674,8 +674,7 @@ static void p2m_free_entry(struct p2m_domain *p2m, * XXX: Should we defer the free of the page table to avoid the * flush? */ - if ( p2m->need_flush ) - p2m_force_tlb_flush_sync(p2m); + p2m_tlb_flush_sync(p2m); mfn = _mfn(entry.p2m.base); ASSERT(mfn_valid(mfn)); diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index faadcfe8fe..a0abc84ed8 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -204,6 +204,8 @@ static inline int p2m_is_write_locked(struct p2m_domain *p2m) return rw_is_write_locked(&p2m->lock); } +void p2m_tlb_flush_sync(struct p2m_domain *p2m); + /* Look up the MFN corresponding to a domain's GFN. */ mfn_t p2m_lookup(struct domain *d, gfn_t gfn, p2m_type_t *t);