From patchwork Thu Nov 23 18:32:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 119542 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp1173260edl; Thu, 23 Nov 2017 10:34:31 -0800 (PST) X-Google-Smtp-Source: AGs4zMYbWKDpwpwREWWPh5QcKPeskeRbNkKVWLJAulpjeFqyTYMqEpqb5FFQxkfTeQ8pywBdYuJN X-Received: by 10.36.111.194 with SMTP id x185mr12505292itb.54.1511462070971; Thu, 23 Nov 2017 10:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511462070; cv=none; d=google.com; s=arc-20160816; b=TOJ7sxvclo/WTje4ql6qBAjU9OD5AqDwjmcQHuXMEvz1UpwLs0UHAPdkZHafCv57FB 00AF4HkFvMFTu2i8GHg7LhSYoWSlD3xcJ/P9JAfvNLSavOjcSs9GlBNapsiIsZKVKD2F p2LowbE/H4WBNnFuZJ+Ma8Hgdd0lbBdbMy1E3fr6kYxuEMslSaAv4H2N7XK3RlCiQjJl GMjYVZdtNdXBbPnlBtyObzc9+nPvOX6UlrjEv9rWYFQzWLMoQBEr+i6DGP8Blt2k/zEm uTkR3wuAclI29YQyUSJKwT8S6aiCEKqXDQG9UtkRtZo7os2qdBIJXfBnHino0P1PnCrx uisQ== 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=A/Rau7nX0m5hgOOwTQu7L0XhgfogeVHLI8xFsAzRB1s=; b=xWrYeMaS+za8g1uidbLIYj+Cjse1z1ZXYqMQGqicUhkyZLxsp3ZP2cjVYdVFTGJeNp Ch7gN7U4/4t88pn/sUE4h000nNz40uHEPaFwmqQT58JvWbBuMR16rW4ttv3ITyeay6jV wutN+9z/irgy143k8CvZJyz4rSY5EXcJdU0W1zh6GqcuDeIrHuijvy+kDNYbBFVskn52 bhqWNytc9BUf4psqkEak8SUEmxWjc3Uzqst9xc7aDd9N63pk17g+8hVuiY7HQHyoDQ9F qnMj+kzAfWnI0fPG/xA1hybdQYVtomT4zTxCzzlzxIEaYNrEXhyQX/N407rJ0Z8m6CbT s3Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bS0XT+oo; 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 y93si15417811ioi.157.2017.11.23.10.34.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:34:30 -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=bS0XT+oo; 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-0005MP-EP; 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 1eHwIW-0005KI-Rg for xen-devel@lists.xen.org; Thu, 23 Nov 2017 18:32:28 +0000 Received: from [193.109.254.147] by server-6.bemta-6.messagelabs.com id 5A/99-05156-C34171A5; Thu, 23 Nov 2017 18:32:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsXiVRvkrGstIh5 lsO6mksWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmvHzyRG2gsf8Ff8P/GJpYLzD08XIxSEkMIlR 4kz/ZhYQh0VgHrPEt96NYI6EQD+rxMlX3exdjBxATp5E8824LkZOIDNN4mbDKSYIu0Li98r/r CAlQgJqEmveREEM7WOSeP/sJlicTUBHYt2MWpByEQFpiWufLzOC2MwC8RKPp15nA7GFBeIkLv /9DmazCKhKzN+7lR3E5hWwlThxZCo7xCp5iV1tF1lBbE6g+NEDH5gh1tpIfP6sOIFRcAEjwyp GjeLUorLUIl1DU72kosz0jJLcxMwcXUMDM73c1OLixPTUnMSkYr3k/NxNjMBgYwCCHYzflgUc YpTkYFIS5ZX5JRYlxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXUlg8SkiwKDU9tSItMwcY9jBpC Q4eJRHe7UJAad7igsTc4sx0iNQpRkuOfXtu/WHieDbzdQMzx7SrrU3MQix5+XmpUuK8m0EaBE AaMkrz4MbBYvMSo6yUMC8j0IFCPAWpRbmZJajyrxjFORiVhHnfgkzhycwrgdv6CuggJqCDfh4 XBjmoJBEhJdXAaLRpdufT2qZlu0VXrEuZ2tR+5Izn9cqpHXNc+CXWxRvkhkj4+qxw2ZWn7SWs 4cGU1Pro96w3rHzbXJWepE1bOPXi9xUWjh0aeVuWpLIx7uDx+/pTJml9zKdKrdK63nkv875yy B0sEZLW3JHwVUvk+EdlyzOfsvt+sO0I9D53Rkbk9lKDxa/llFiKMxINtZiLihMBWOB5h8gCAA A= X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-13.tower-27.messagelabs.com!1511461947!108371538!1 X-Originating-IP: [74.125.82.67] 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 43345 invoked from network); 23 Nov 2017 18:32:27 -0000 Received: from mail-wm0-f67.google.com (HELO mail-wm0-f67.google.com) (74.125.82.67) by server-13.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 23 Nov 2017 18:32:27 -0000 Received: by mail-wm0-f67.google.com with SMTP id b189so18300972wmd.5 for ; Thu, 23 Nov 2017 10:32:27 -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=vt43YlirSpRxAzszWynNZEwmBlzw2ATzrU5DYNCb3Ps=; b=bS0XT+oowaobs7MqfzShdW0urD/ow5YvBXWimBn5CA7H9sfXjJLp7r/BVu/8FOYi2Y HYsgjoN4uvk++hH+Tov+dHrejzE+Or8T3tOHOCWKnmIUd2Cs/wE9UxVw8vmQ1PL0CvkP HgyzsN+iqJSl3afqUqfbLAjecskJSPLGCusIU= 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=vt43YlirSpRxAzszWynNZEwmBlzw2ATzrU5DYNCb3Ps=; b=Kquc5y7LQ8kOMf1KcWTrbIxQMIMiuNwudt/JtJmzqSSemIowwVdJmdt1clZZNWYDCT FlqCLcpkhEgZOumxIoTjZqMXAdg6l5yxgMX/UvPkUEkKGUh/2x1JoYlbaZpBpX/Yug1Y u40wrmWwQzEgL0h+DkxdJ/i5dQZCjKqEj/Vcqp0PBRqvybw2N/9WgnVPnn0T69dh2mNk Kd097H0Hx2kVRA9EQ9Tj9Ya1Q+9gar3oHrKVOdvO71ByOLriC9rh51JfrGd8o6NyAR3E ZWg21JMVzHwvyj+udXbA3DQWSXWh6ajJrKdQIC9I5f3MVb/Y2TN1obGs9JXMMAyaqyyq oKLA== X-Gm-Message-State: AJaThX5yF2wSaJM/PnCkb8ZhdbDbbMfPZIi9Ckl3WVFs1lpKXrpFkohr nnapqsrbYM78wtBI1+1PqHB0ET+qc20= X-Received: by 10.28.156.67 with SMTP id f64mr7427972wme.42.1511461947022; Thu, 23 Nov 2017 10:32:27 -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.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 10:32:26 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 23 Nov 2017 18:32:07 +0000 Message-Id: <20171123183210.12045-14-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 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 --- 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 37498d8ff1..5294113afe 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -132,11 +132,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. @@ -157,18 +164,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; } @@ -1143,7 +1139,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; }