From patchwork Tue Dec 12 19:02:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 121642 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4508700qgn; Tue, 12 Dec 2017 11:04:44 -0800 (PST) X-Google-Smtp-Source: ACJfBouXavykNCjdIwLFglFxye4n486rpZbFXTDvsz6j+KadZ/9uacxMVLrFFlsSM0QE/SiHCRdR X-Received: by 10.107.27.195 with SMTP id b186mr6065595iob.277.1513105484360; Tue, 12 Dec 2017 11:04:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513105484; cv=none; d=google.com; s=arc-20160816; b=RyiydEXmHZaM93krHsN4i82A2jkflB1JPP/CNzf1KQbHrQRgKTc6oZSY0AIfXKKoIa s4cN3BmFsqhxoKe/w88K/cES2/upnZadq/gzff+3pKzGsGqGnIAsf0ZRZFND2ZauGOqi kcVxkzEo5xSzLLvaFivYdVLsJ5V1lZ8kmjcEjLVJYc/wo4ndnItZrrge7Q6JfwVyE25H mtWpDQXO2RheZNjfsD2WkRjgjx2hoWJHberFuetxLQxlnAdYxHXcSaVzdorP6DtsNMWp kEhumcqCAf3EdyVWsw9GPU/q8UcWBcyxo60gl2qi4GhZapcwPYs5Fa7dSC5jxIYQxjCg 7Faw== 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=EOmIyVfSW+Dj+WddoLINtxZ6lsFbembqzCe1mTszIG4=; b=nOkuA/LHQUYUNXI4cK/ZIkdounWdMBuUHBk46yNaTi0n7aUkzwGsI6iLwH7xysjF3O 7OFPES3N8nfVamVpN/lSf8D+yOHuijAA9WjFmTla2MnnFB4guWImxn79P37ofUo58JYA pM6WDQdo1wKAQYVtFv3+KLLlZzd9bOh+c+ED6dbzcmkaN/tyZgWnp9NquwhS46b5K3Jx YVd881FHFl+7TDre4Q8mnWhpU9rVHOY+6I50YLXWz25dlW+zITooSXfl8t8pcL5H3Wf0 WNtwP8t2D+Ianmssg9RQMLn2Ln+3mQ3s9DVSpUQt8PHkHLYKtFBx/AvS4CCSk6OsZZe/ wo6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=j4PhFPjU; 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 66si11930210ios.150.2017.12.12.11.04.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:04:44 -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=j4PhFPjU; 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 1eOppG-0002mG-3K; Tue, 12 Dec 2017 19:02:46 +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 1eOppE-0002kB-Uf for xen-devel@lists.xen.org; Tue, 12 Dec 2017 19:02:44 +0000 X-Inumbo-ID: f50ed967-df6e-11e7-b4a6-bc764e045a96 Received: from mail-wm0-x243.google.com (unknown [2a00:1450:400c:c09::243]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id f50ed967-df6e-11e7-b4a6-bc764e045a96; Tue, 12 Dec 2017 20:02:11 +0100 (CET) Received: by mail-wm0-x243.google.com with SMTP id t8so683388wmc.3 for ; Tue, 12 Dec 2017 11:02:43 -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=4ahZ8uEy02X+uawVFiv+SZLHVmwQh6VKOEFS0hlxlgg=; b=j4PhFPjUdwVJUXrKTYTBzN1DVHW9EctVrhfcXNQUNxqx3Kuz2IiVQ6RrCPoZakvg/E qH7LDmrj4jV2e+8puNSA3kTkFcuLoxBz+mTF645asYy26m1MTXX31wGmtNrJljKcBQOa 5wdcfOZUBNyUSFgEHRs0cHoRlwkBrpxJSLa5g= 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=4ahZ8uEy02X+uawVFiv+SZLHVmwQh6VKOEFS0hlxlgg=; b=mdQdZ++is2kejPHpNEiId9+Ahu/IkjrAn/L5TUrm9HVWtVgvSJBxEtj/SnauHNSoNo qMdKR3rciZGPoxZym4uXPnBZ+mNPbx1G/QiNlrTMYktcCaYr/VOKeSvzidvazazvFC9v zHMCglAcis0v3omj6NdtfVtxAgOkdxbzNZPrBIfWo5StSqqArDCngOeNqPnIvHLP4n0q hMTYYCMeagFNhPrERHrXLTDnAaIiO63UrH+AN0PIfSOqjh+KWwgxGkvC0eAPxbrTgi5g J43m5f6jNvT6fXafsXbPocxTWakWVvJGOoUXdhHj8HuiOVNO1AmWY8LXEy95XwShdGLS cVDQ== X-Gm-Message-State: AKGB3mK/8XacRdFycj3mb0Gx4lEuK0KwoEi3ZvEWZkd2vGBOW/wbHXkO LT0Abset69GXH52n5TSuGGswg/+GLso= X-Received: by 10.28.210.72 with SMTP id j69mr2716066wmg.51.1513105362132; Tue, 12 Dec 2017 11:02:42 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Dec 2017 11:02:40 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Tue, 12 Dec 2017 19:02:09 +0000 Message-Id: <20171212190212.5535-14-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 13/16] xen/arm: p2m: Fold p2m_tlb_flush into p2m_force_tlb_flush_sync 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" p2m_tlb_flush is called in 2 places: p2m_alloc_table and p2m_force_tlb_flush_sync. p2m_alloc_table is called when the domain is initialized and could be replace by a call to p2m_force_tlb_flush_sync with the P2M write locked. This seems a bit pointless but would allow to have a single API for flushing and avoid misusage in the P2M code. So update p2m_alloc_table to use p2m_force_tlb_flush_sync and fold p2m_tlb_flush in p2m_force_tlb_flush_sync. Signed-off-by: Julien Grall Reviewed-by: Stefano Stabellini --- Changes in v2: - Add Stefano's reviewed-by --- xen/arch/arm/p2m.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 15711a4c80..22165ae376 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -131,11 +131,18 @@ void p2m_restore_state(struct vcpu *n) *last_vcpu_ran = n->vcpu_id; } -static void p2m_tlb_flush(struct p2m_domain *p2m) +/* + * Force a synchronous P2M TLB flush. + * + * Must be called with the p2m lock held. + */ +static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) { unsigned long flags = 0; uint64_t ovttbr; + ASSERT(p2m_is_write_locked(p2m)); + /* * ARM only provides an instruction to flush TLBs for the current * VMID. So switch to the VTTBR of a given P2M if different. @@ -156,18 +163,7 @@ static void p2m_tlb_flush(struct p2m_domain *p2m) isb(); local_irq_restore(flags); } -} - -/* - * Force a synchronous P2M TLB flush. - * - * Must be called with the p2m lock held. - */ -static void p2m_force_tlb_flush_sync(struct p2m_domain *p2m) -{ - ASSERT(p2m_is_write_locked(p2m)); - p2m_tlb_flush(p2m); p2m->need_flush = false; } @@ -1142,7 +1138,9 @@ static int p2m_alloc_table(struct domain *d) * Make sure that all TLBs corresponding to the new VMID are flushed * before using it */ - p2m_tlb_flush(p2m); + p2m_write_lock(p2m); + p2m_force_tlb_flush_sync(p2m); + p2m_write_unlock(p2m); return 0; }