From patchwork Tue Dec 12 19:02:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 121643 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4508715qgn; Tue, 12 Dec 2017 11:04:45 -0800 (PST) X-Google-Smtp-Source: ACJfBosmZxY6U+5i+Wx5ovBc3t7CZhb3hHrlGib1Cu6+Lebz7MlpsTdffTVAh+Te4/iEXbTt+88W X-Received: by 10.36.216.138 with SMTP id b132mr762423itg.121.1513105485176; Tue, 12 Dec 2017 11:04:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513105485; cv=none; d=google.com; s=arc-20160816; b=ZJcPgVG6TPcYmWzUDlca1M12DB/jbxUkNo/+x1IlRomTFBWFAAd6aupGwxRs/tDG6P /VCHOuXeUvtIQYpBCRCJZwWs8LHaxyT6gnpIxK8yhDA6JAic6dD1beOdJG/20DE9nXsN MzPAqb7nAFmTz9427yoq4LgB3jAEJ8oTfrBgjmLDyENOJjGo7EvCzjTT3W1aOOnqK8YR lGXNMrJMpah5m6vpEj6agzJ8PY2TIfAl/qqadtAqKgkTfyuI+l5azPsgAE5L3G/iAKpN fbH5fJ/bxFfUDU+yjcGkCSZsrDTdbZWvrqagcSc0Entxm9lwq6ofTL477x+sABwSt8rL I9Og== 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=uasytb7Xs0xBIT5punk+/1NW+6ipsNt95YpOqNZ+uuM=; b=TNSxE0RsXAkzpEQIFjyzuKWdj0lwQuTXdAD038R9/ll3FcPLejMFlya51ezsyMDWGb iM4VvYB7kTOEsqSKfYAVl1X9fyX9adZ8Da4rb9jyOQMRerXwJm9PDu0jUU8Bn9Pt3teq jtKMPL9qwBJB97V3OFZ4+NeYJJ+HyAW3sqXh3br1DUQAq7yIjdWGF5XLRsybF6ujUoEm 8k3VzQeeiZP8iwDoPqtL/33u2kq0X2HvaXaZW/ZXrwByNHvRn+3TTOaR6+ij/0r/3Zsq ai0XcNqLGbiNaNuXyLOKKXJXRhKgsOO0WTOciUYUFVzQiJxf12gdyDj2XYl+WD8VvEWI hTcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EmptYypL; 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 g20si10116091ioe.182.2017.12.12.11.04.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:04:45 -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=EmptYypL; 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 1eOppD-0002ij-On; Tue, 12 Dec 2017 19:02:43 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOppC-0002hU-IH for xen-devel@lists.xen.org; Tue, 12 Dec 2017 19:02:42 +0000 X-Inumbo-ID: f3790f2d-df6e-11e7-b4a6-bc764e045a96 Received: from mail-wm0-x242.google.com (unknown [2a00:1450:400c:c09::242]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id f3790f2d-df6e-11e7-b4a6-bc764e045a96; Tue, 12 Dec 2017 20:02:08 +0100 (CET) Received: by mail-wm0-x242.google.com with SMTP id i11so690303wmf.4 for ; Tue, 12 Dec 2017 11:02:40 -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=0bFGviCHyRMKr+LG6sn7FWHbTHVabqNxDjGNxpuc/LU=; b=EmptYypLeMBHcDhQWrlu926CabfGdET/gAUdH0IBF40uBYB25ylmzI+Q2TaDdgBK2z Sj6ZSqQNzropA+M5AvFAzaW/MaIzxhja3smXFVfEgjQ2BJsmD8wfo6ur/jMQRtNcTjVx K+TZny4jOx6Tp1CzVFeGHPcrPfHJbAeNAhmYY= 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=0bFGviCHyRMKr+LG6sn7FWHbTHVabqNxDjGNxpuc/LU=; b=Li78BuLnnv7QjmeCMgHkHa47Vi2Fy+idd+yfh58D7CVvG7tg3GCVPGo1PKa6YI8veA jL/VeX2Az1TyemqoDfScUayfIfvWAaocARm8B8hbCEOlfFdGoJlsq9n5FnOElYKFpmt/ 8AhTZU+QJDaDOw9z7YQi/TuvYmjeVXtbJjfndyEpjsp2Rzgj/R3HqrYryFRoYAzhAJOW WWjAXWyQdG5MduFpC0be3skrwnfBpSQvOL6GT/Ejh8sEemIljdZVTO3vtcvqXMLQLhhA aTtc6u96uxZMs5sd6NJoWgHnKWsaPo0JH2I+NJpZNJnHSO1piKwFMbzc09xMcovIr7Da kQ2Q== X-Gm-Message-State: AKGB3mJjsj3u0Qq75cdiqHdLOxDghJmXM4mx+46g6JEnwQjuj8+ClN1S sMdMZ2/JUBwlRcAwqFKM92P7bePBx8w= X-Received: by 10.28.226.214 with SMTP id z205mr2684111wmg.149.1513105359427; Tue, 12 Dec 2017 11:02:39 -0800 (PST) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id n14sm207508wmh.37.2017.12.12.11.02.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:02:38 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Dec 2017 19:02:08 +0000 Message-Id: <20171212190212.5535-13-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171212190212.5535-1-julien.grall@linaro.org> References: <20171212190212.5535-1-julien.grall@linaro.org> Cc: sstabellini@kernel.org, Julien Grall , andre.przywara@linaro.org Subject: [Xen-devel] [v2 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 only 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 --- Changes in v2: - Add Stefano's reviewed-by - Fix typo in the commit message --- 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 95090874c3..15711a4c80 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -51,21 +51,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); } @@ -177,6 +171,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. @@ -673,8 +673,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);