From patchwork Mon Oct 2 12:59:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114598 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653614qgn; Mon, 2 Oct 2017 06:02:00 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDS+ZSdrGs7OcgZKemop7/s2nbKypsRUUiJvHzVQkDkJsS1Ixvl+gr8Q5D82lak2asNn/Sk X-Received: by 10.107.164.28 with SMTP id n28mr22980406ioe.175.1506949320491; Mon, 02 Oct 2017 06:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949320; cv=none; d=google.com; s=arc-20160816; b=gzQWfOf9UHDr3RBNgYXOXhQeEYFA2/T1a+ys+1HrbibIvMlEN1kgPKH0us7NtIo3SW KzHV+pMdgveVncQSV1OXKpUc6DZg54tr0Vq2rw/v+RUc0dmpH1NKilCw6Y1sC1vVO5zD i1cDbh7l5Dyos4Y6oC/lmsOafni7Kwg87EOdqsKmNEd4uNkhYUkrDc7yX9M8RePZoMRm +fgHyWCXOv5KViV+FJDDn/JPN69674U4YpveyzWAsSi5VVMcRjztt7EMK6NkGfd2MWc5 M4Su6flIXKcUShCdv/k/BxCzSUOe5ZLGFlDoCMDIPcXjm2IsiIaioUPirpiP5EjCQTmQ 33Lg== 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:arc-authentication-results; bh=vPX5Y3xeH7MrJwGFTmDdVI+rXZHozMpKyxWCmqDYGZo=; b=yDWdV3CtHLNa2Oz5g7r3y2B9NXFlfiOL68vUSWsSukf9Uw3FFvxQCUuyJCfWaaBRD5 G4ylKhi8T9w3pWSgTfPBFzYWOFald70mCZ5Wq7rT46FJnh2dCh1+l2wTK7efBfh6MKeN PM/5A03gN+2cJbKgfA3l/wVVXU9AYEQFBMdfJy82v2NxcdX1k+YEoRt9/P3TzJnhsFUA I+Mpf7E/RIiVVK5jtAqj7DkqH1Ar7Xql+fg1gEcWrIuyqWycroM+jWHTFpQn+wsRvIdq lpIZtoxZJn7nLXkm7gaFdrlfLfHUh3ecNXGIPqZ25zk0FcPtBtsOEH75wip5KeQeU/xs 36tQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w67si8857953itc.129.2017.10.02.06.01.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:00 -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 1dz0KA-0003bj-PF; Mon, 02 Oct 2017 12:59:54 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0K9-0003bX-Kb for xen-devel@lists.xen.org; Mon, 02 Oct 2017 12:59:53 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id F8/6A-01778-84832D95; Mon, 02 Oct 2017 12:59:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTdfd4lK kwdKzQhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bluyeYCj5xVfy/cIOtgXEdZxcjF4eQwGZG ie0tZ5khnNOMEp23DwE5nBxsApoSdz5/YgKxRQSkJa59vswIUsQssJhR4vP+XrAiYQFbiRtPt rF0MXJwsAioSmy4UAcS5hWwlJhz5RI7iC0hIC+xq+0iK4jNKWAl8f74RzBbCKjmePckpgmM3A sYGVYxahSnFpWlFukaGeslFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgR6uJ6BgXE HY99ev0OMkhxMSqK8zIaXIoX4kvJTKjMSizPii0pzUosPMcpwcChJ8GqYA+UEi1LTUyvSMnOA oQaTluDgURLhNQVJ8xYXJOYWZ6ZDpE4xGnMcmHDlDxNHx827f5iEWPLy81KlxHn/mwGVCoCUZ pTmwQ2CxcAlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8XCALeTLzSuD2vQI6hQnolDldF0 BOKUlESEk1MBrmTus+871UyNVHQmnzarN6E85J0i1781dx5xYqONn7Tmfn9224yz735Oft+XZ bZz7+OP3ihpXVghHGx+u/pvx8b1Zx/dfv4EsnE9LnfTD1dX4iwNUcdmaRZEp+0WPWaw+LsyvP K32NqzjjWZyvyebyyqBq/bVD8i9+Rll8NQqa8j88ZYb8GiWW4oxEQy3mouJEALZF/VN8AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1506949190!116801758!1 X-Originating-IP: [217.140.101.70] 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 7034 invoked from network); 2 Oct 2017 12:59:51 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-31.messagelabs.com with SMTP; 2 Oct 2017 12:59:51 -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 7E6521596; Mon, 2 Oct 2017 05:59:50 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6E33F3F53D; Mon, 2 Oct 2017 05:59:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:27 +0100 Message-Id: <20171002125941.11274-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 01/15] xen/x86: p2m-pod: Clean-up includes 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" A lot of the headers are not necessary. At the same time, order them in the alphabetical order. Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Acked-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Wei's reviewed-by - Add George's acked-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 4085b7f752..fec87e5224 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -19,18 +19,13 @@ * along with this program; If not, see . */ -#include -#include #include -#include -#include +#include +#include +#include #include #include #include -#include /* ept_p2m_init() */ -#include -#include -#include #include "mm-locks.h" From patchwork Mon Oct 2 12:59:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114600 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653619qgn; Mon, 2 Oct 2017 06:02:01 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCKv+LtvvIcqskpKpHcj3TjKtBEEZGehtY5VjhpOv5URvtAaX8yf9Y/c3SXd2yEHiErpl1k X-Received: by 10.36.117.79 with SMTP id y76mr18190217itc.16.1506949320858; Mon, 02 Oct 2017 06:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949320; cv=none; d=google.com; s=arc-20160816; b=DoYPOvwbBVDZ3DUwJDFVYSqNAIc185tn2+LNqLhlLEcueimSgIF8xJNTjGY3UppjvB i+OsBOarKXPN0QWLLlfrlYb0MH8iRDOr/ARbHEM36iTIhpKQ73yuTw8ehR2NmguaUqHi RZT5AtcJIK42l2OaxCjV3lyPgbqDBKCSPqAV5WpHxSD6qGh1461Xcg42xW/eqHmljczO +E/XlqOxRCW1IdPcH0cORTsMSoFXzUsLJGRUzzmticHg6EhwlgmvMGXnRWOCCcelS+9x Sz0p8FNbKqW6TZNR78zME+NIo8NOLqVHy6Ezp7KWi8ovH0qrZgf+hTEvpEgZfaDjndTH UODQ== 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:arc-authentication-results; bh=uizgJnW2irPAiXDwSH+XDhgAj0yhQrEmDoEmWfchh/s=; b=HnLhgbCWZ8tdcxA7ZTqet6MhrJTqC92WH1EeYdwMhliaa4kY8oGoPuAdxOiVuI+ERS Kj+Tpr/xXvfPk1hMvKOJ0WhPdnmnzui5o0sStdr2xBCrPw5a7kCYmyA5hsHUa0u3nkfs oG9vU9ks+lHPZobWRMKVGCR8Bm4qlhuZBSgFtTA25v/+DDp3p3RBAiEt6pzkA6/HMGxj oQE+uY+9daXrmuJ780TXXCqcKBJipqZ0xUtOqGb0rUec8IT9h1K7cg8pq+u6/Gxs2HkI cqnuWV3fKfOYZGiYwUgXo4lqmqI4aiiWOb3khoa6fAA1zkJnOFi4fGn4KtaVVm8KviJD ZSzA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id n73si9033197ioe.331.2017.10.02.06.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:00 -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 1dz0KG-0003dV-2e; Mon, 02 Oct 2017 13:00:00 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KE-0003cS-9Q for xen-devel@lists.xen.org; Mon, 02 Oct 2017 12:59:58 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id B7/C8-25121-D4832D95; Mon, 02 Oct 2017 12:59:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdfD4lK kQfNpXYslHxezODB6HN39mymAMYo1My8pvyKBNeP/f5OCFxYV/zZ/Z2lgfKzZxcjFISSwmVHi 1KKDjBDOaUaJRYf2s3UxcnKwCWhK3Pn8iQnEFhGQlrj2+TJYEbPAYkaJz/t7mUESwgLuEi9Ob 2cHsVkEVCV2ndwGFucVsJRo3v6VBcSWEJCX2NV2kRXE5hSwknh//COYLQRUc7x7EtMERu4FjA yrGNWLU4vKUot0zfSSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQL9W8/AwLiD8Uq b8yFGSQ4mJVFeZsNLkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeDXMgXKCRanpqRVpmTnAQINJ S3DwKInwmoKkeYsLEnOLM9MhUqcYdTk6bt79wyTEkpeflyolzvvfDKhIAKQoozQPbgQs6C8xy koJ8zIyMDAI8RSkFuVmlqDKv2IU52BUEublAlnFk5lXArfpFdARTEBHzOm6AHJESSJCSqqB8a ZU0zS13ZmXloa5nTZ3+G9UdlyAvWPGjNY7t/+UB7MZvPx1RmVRms2lCQ9ubtqSK7bxi/7GubX Tnb3UAtqs/H9u2Xn083zHCessLOsVUyJlukWtxP6c28R8Zsnlaq2Tz+vONrkuu39H9T1vWZNl CE/i1rk2RvckN/3qXb/XQaD7l43yJIW+LiWW4oxEQy3mouJEACy8hL51AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1506949192!105812660!1 X-Originating-IP: [217.140.101.70] 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 23311 invoked from network); 2 Oct 2017 12:59:52 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-2.tower-31.messagelabs.com with SMTP; 2 Oct 2017 12:59:52 -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 CA8FE15A2; Mon, 2 Oct 2017 05:59:51 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB9D63F53D; Mon, 2 Oct 2017 05:59:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:28 +0100 Message-Id: <20171002125941.11274-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 02/15] xen/x86: p2m-pod: Remove trailing whitespaces 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add George's and Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index fec87e5224..1f07441259 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1,7 +1,7 @@ /****************************************************************************** * arch/x86/mm/p2m-pod.c * - * Populate-on-demand p2m entries. + * Populate-on-demand p2m entries. * * Copyright (c) 2009-2011 Citrix Systems, Inc. * @@ -76,7 +76,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m, __func__, mfn_x(mfn), order, ((1UL << order) - 1)); return -1; } - + for(i=0; i < 1 << order ; i++) { struct domain * od; @@ -223,8 +223,8 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int p /* If we can't allocate a superpage, try singleton pages */ order = PAGE_ORDER_4K; goto retry; - } - + } + printk("%s: Unable to allocate page for PoD cache (target=%lu cache=%ld)\n", __func__, pod_target, p2m->pod.count); ret = -ENOMEM; @@ -272,7 +272,7 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int p if ( test_and_clear_bit(_PGT_pinned, &(page+i)->u.inuse.type_info) ) put_page_and_type(page+i); - + if ( test_and_clear_bit(_PGC_allocated, &(page+i)->count_info) ) put_page(page+i); @@ -296,7 +296,7 @@ out: * definitions: * + M: static_max * + B: number of pages the balloon driver has ballooned down to. - * + P: Number of populated pages. + * + P: Number of populated pages. * + T: Old target * + T': New target * @@ -311,10 +311,10 @@ out: * the remainder of the ram to the guest OS. * T default_access); - + out: gfn_unlock(p2m, gfn, SUPERPAGE_ORDER); return ret; @@ -836,8 +836,8 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) /* If this is ram, and not a pagetable or from the xen heap, and probably not mapped elsewhere, map it; otherwise, skip. */ if ( p2m_is_ram(types[i]) - && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 ) - && ( (mfn_to_page(mfns[i])->count_info & (PGC_page_table|PGC_xen_heap)) == 0 ) + && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 ) + && ( (mfn_to_page(mfns[i])->count_info & (PGC_page_table|PGC_xen_heap)) == 0 ) && ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) <= max_ref ) ) map[i] = map_domain_page(mfns[i]); else @@ -915,7 +915,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) t.mfn = mfn_x(mfns[i]); t.d = d->domain_id; t.order = 0; - + __trace_var(TRC_MEM_POD_ZERO_RECLAIM, 0, sizeof(t), &t); } @@ -924,7 +924,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) p2m->pod.entry_count++; } } - + } #define POD_SWEEP_LIMIT 1024 @@ -1046,12 +1046,12 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, pod_lock(p2m); /* This check is done with the pod lock held. This will make sure that - * even if d->is_dying changes under our feet, p2m_pod_empty_cache() + * even if d->is_dying changes under our feet, p2m_pod_empty_cache() * won't start until we're done. */ if ( unlikely(d->is_dying) ) goto out_fail; - + /* Because PoD does not have cache list for 1GB pages, it has to remap * 1GB region to 2MB chunks for a retry. */ if ( order == PAGE_ORDER_1G ) @@ -1107,7 +1107,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_aligned + i); paging_mark_dirty(d, mfn_add(mfn, i)); } - + p2m->pod.entry_count -= (1 << order); BUG_ON(p2m->pod.entry_count < 0); @@ -1124,7 +1124,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, t.mfn = mfn_x(mfn); t.d = d->domain_id; t.order = order; - + __trace_var(TRC_MEM_POD_POPULATE, 0, sizeof(t), &t); } @@ -1161,7 +1161,7 @@ remap_and_retry: t.gfn = gfn; t.d = d->domain_id; - + __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), &t); } From patchwork Mon Oct 2 12:59:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114603 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653709qgn; Mon, 2 Oct 2017 06:02:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDTTyqYHE16CceJxAvFZL+FZF7iC2Gw33fqw4PKzAsBDLsv4Xz2VSAs8MQC5SsuYO+WLlVk X-Received: by 10.107.147.196 with SMTP id v187mr24244404iod.92.1506949324827; Mon, 02 Oct 2017 06:02:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949324; cv=none; d=google.com; s=arc-20160816; b=BarpR2+LN5btjEO3LiNS2ie9+/lhwFNPWl8GUQsrTJkuPINw+DFKtCG7LglUnosSvc nDYNe7spcVEaa6edOS+S9vUWP6ke7SDRHmTq/0+dA30I7MkWwbwa+QKkh/Ov1gYzgbKq XT/kSPMTWFQmS53yN/ewMltlOL8K6JSj3quE9XZUjYfZr/f5cz6Hi5eF7YaW9DYUKvut 7I7VcPNXMKXWyxeWE2LYyKqsJA7IUUZFGabYXFAhysdnjGuQk4iKVAQU1xEFXpxxj0KP wE1dyGmOVcxlET6X0H0ogQWUvd+zAkQfXNvByUA4dUNWqpBLSLMpNeGPr2a2p8AnasPm EzoQ== 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:arc-authentication-results; bh=0Ompb1bzMJ+B14dDDRH9gQU12bm0CYVT6VO+aFOW/Ps=; b=dn2fhPPxVbwrJmJ9akQFAhjvaiPcWt32BHMwU8JkEK06rCWUVxxnwaDO8Z4ggzOu4K bp7brQ9ay1Bd5BQqfvmRmicef+G5KZ+EIZEFFo5TsqeYbMu3zFXTNYn9i404oxkjXOZc uh1VGdZbhpiUTvVeXvd6ipvgSdWNsCIEVulapdp2fPLIItPakPV8uvGnKpufq8bI4yWz xB80rv8SSdGEuEGKqZwMqrD/fB6rNeEZvCv50TL9O0m+TQ8HcUASO3E5LNrwO7b8aNvQ Tr1aOjj9+oTDdpQ0UHZe/xRAeIm/kjmmSIhbD0c/TYDgMpu2h6EOEJ9y/7ySI7C8fv+T 23PQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y132si2659190itf.49.2017.10.02.06.02.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:04 -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 1dz0KD-0003cG-7m; Mon, 02 Oct 2017 12:59:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KB-0003bu-WD for xen-devel@lists.xen.org; Mon, 02 Oct 2017 12:59:56 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 78/11-02044-B4832D95; Mon, 02 Oct 2017 12:59:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTdfL4lK kQfMUMYslHxezODB6HN39mymAMYo1My8pvyKBNePvr4OsBY+zK66c38fWwHjKr4uRi0NIYDOj xNpPB9khnNOMEp3X5wM5nBxsApoSdz5/YgKxRQSkJa59vswIUsQssJhR4vP+XmaQhLCAp8TzX SvAilgEVCUmX1wI1swrYCmx5MduFhBbQkBeYlfbRVYQm1PASuL98Y9gthBQzfHuSUwTGLkXMD KsYtQoTi0qSy3SNTLQSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQI9HE9AwPjDsb mE36HGCU5mJREeZkNL0UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuB9bQaUEyxKTU+tSMvMAQYb TFqCg0dJhPcXSJq3uCAxtzgzHSJ1ilGXo+Pm3T9MQix5+XmpUuK8/0GKBECKMkrz4EbAAv8So 6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeLnOgKTyZeSVwm14BHcEEdMScrgsgR5QkIqSkGh jjts9W6n6lInWBOSJky4Ejl4+2yUVVKQr4Sfh2nZwgf+D97Yw9Evd4D64U7tstsjFx1/1g7Rf KgS3l/SeLXsSsjj0fv1jEfK6FRMa82y1Pa3hz2i22ZKmk77PZEZKuPengEcXDzVKvFDvkDaYV Rip9qL1geijidHlLk/OF6uVFrJ7WXF+SEpRYijMSDbWYi4oTASjajx93AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1506949193!113438303!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 42861 invoked from network); 2 Oct 2017 12:59:53 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-15.tower-31.messagelabs.com with SMTP; 2 Oct 2017 12:59:53 -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 47B1015BF; Mon, 2 Oct 2017 05:59:53 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 153263F53D; Mon, 2 Oct 2017 05:59:51 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:29 +0100 Message-Id: <20171002125941.11274-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 03/15] xen/x86: p2m-pod: Fix coding style for comments 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Move the 1UL << changes in the next patch - Add George's and Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 150 ++++++++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 50 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 1f07441259..6beb26b00a 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -155,8 +155,10 @@ static struct page_info * p2m_pod_cache_get(struct p2m_domain *p2m, BUG_ON( page_list_empty(&p2m->pod.super) ); - /* Break up a superpage to make single pages. NB count doesn't - * need to be adjusted. */ + /* + * Break up a superpage to make single pages. NB count doesn't + * need to be adjusted. + */ p = page_list_remove_head(&p2m->pod.super); mfn = mfn_x(page_to_mfn(p)); @@ -242,8 +244,10 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int p } /* Decreasing the target */ - /* We hold the pod lock here, so we don't need to worry about - * cache disappearing under our feet. */ + /* + * We hold the pod lock here, so we don't need to worry about + * cache disappearing under our feet. + */ while ( pod_target < p2m->pod.count ) { struct page_info * page; @@ -345,15 +349,19 @@ p2m_pod_set_mem_target(struct domain *d, unsigned long target) if ( d->is_dying ) goto out; - /* T' < B: Don't reduce the cache size; let the balloon driver - * take care of it. */ + /* + * T' < B: Don't reduce the cache size; let the balloon driver + * take care of it. + */ if ( target < d->tot_pages ) goto out; pod_target = target - populated; - /* B < T': Set the cache size equal to # of outstanding entries, - * let the balloon driver fill in the rest. */ + /* + * B < T': Set the cache size equal to # of outstanding entries, + * let the balloon driver fill in the rest. + */ if ( populated > 0 && pod_target > p2m->pod.entry_count ) pod_target = p2m->pod.entry_count; @@ -491,7 +499,8 @@ static int p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn); -/* This function is needed for two reasons: +/* + * This function is needed for two reasons: * + To properly handle clearing of PoD entries * + To "steal back" memory being freed for the PoD cache, rather than * releasing it. @@ -513,8 +522,10 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_lock(p2m, gpfn, order); pod_lock(p2m); - /* If we don't have any outstanding PoD entries, let things take their - * course */ + /* + * If we don't have any outstanding PoD entries, let things take their + * course. + */ if ( p2m->pod.entry_count == 0 ) goto out_unlock; @@ -550,8 +561,10 @@ p2m_pod_decrease_reservation(struct domain *d, if ( !nonpod ) { - /* All PoD: Mark the whole region invalid and tell caller - * we're done. */ + /* + * All PoD: Mark the whole region invalid and tell caller + * we're done. + */ p2m_set_entry(p2m, gpfn, INVALID_MFN, order, p2m_invalid, p2m->default_access); p2m->pod.entry_count-=(1<pod.entry_count > p2m->pod.count)); } - /* Process as long as: + /* + * Process as long as: * + There are PoD entries to handle, or * + There is ram left, and we want to steal it */ @@ -631,8 +645,10 @@ p2m_pod_decrease_reservation(struct domain *d, } } - /* If there are no more non-PoD entries, tell decrease_reservation() that - * there's nothing left to do. */ + /* + * If there are no more non-PoD entries, tell decrease_reservation() that + * there's nothing left to do. + */ if ( nonpod == 0 ) ret = 1; @@ -658,9 +674,11 @@ void p2m_pod_dump_data(struct domain *d) } -/* Search for all-zero superpages to be reclaimed as superpages for the +/* + * Search for all-zero superpages to be reclaimed as superpages for the * PoD cache. Must be called w/ pod lock held, must lock the superpage - * in the p2m */ + * in the p2m. + */ static int p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) { @@ -682,12 +700,16 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) if ( paging_mode_shadow(d) ) max_ref++; - /* NOTE: this is why we don't enforce deadlock constraints between p2m - * and pod locks */ + /* + * NOTE: this is why we don't enforce deadlock constraints between p2m + * and pod locks. + */ gfn_lock(p2m, gfn, SUPERPAGE_ORDER); - /* Look up the mfns, checking to make sure they're the same mfn - * and aligned, and mapping them. */ + /* + * Look up the mfns, checking to make sure they're the same mfn + * and aligned, and mapping them. + */ for ( i = 0; i < SUPERPAGE_PAGES; i += n ) { p2m_access_t a; @@ -697,7 +719,8 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) mfn = p2m->get_entry(p2m, gfn + i, &type, &a, 0, &cur_order, NULL); - /* Conditions that must be met for superpage-superpage: + /* + * Conditions that must be met for superpage-superpage: * + All gfns are ram types * + All gfns have the same type * + All of the mfns are allocated to a domain @@ -751,9 +774,11 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) p2m_populate_on_demand, p2m->default_access); p2m_tlb_flush_sync(p2m); - /* Make none of the MFNs are used elsewhere... for example, mapped + /* + * Make none of the MFNs are used elsewhere... for example, mapped * via the grant table interface, or by qemu. Allow one refcount for - * being allocated to the domain. */ + * being allocated to the domain. + */ for ( i=0; i < SUPERPAGE_PAGES; i++ ) { mfn = _mfn(mfn_x(mfn0) + i); @@ -797,8 +822,10 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) __trace_var(TRC_MEM_POD_ZERO_RECLAIM, 0, sizeof(t), &t); } - /* Finally! We've passed all the checks, and can add the mfn superpage - * back on the PoD cache, and account for the new p2m PoD entries */ + /* + * Finally! We've passed all the checks, and can add the mfn superpage + * back on the PoD cache, and account for the new p2m PoD entries. + */ p2m_pod_cache_add(p2m, mfn_to_page(mfn0), PAGE_ORDER_2M); p2m->pod.entry_count += SUPERPAGE_PAGES; @@ -833,8 +860,10 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) { p2m_access_t a; mfns[i] = p2m->get_entry(p2m, gfns[i], types + i, &a, 0, NULL, NULL); - /* If this is ram, and not a pagetable or from the xen heap, and probably not mapped - elsewhere, map it; otherwise, skip. */ + /* + * If this is ram, and not a pagetable or from the xen heap, and + * probably not mapped elsewhere, map it; otherwise, skip. + */ if ( p2m_is_ram(types[i]) && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 ) && ( (mfn_to_page(mfns[i])->count_info & (PGC_page_table|PGC_xen_heap)) == 0 ) @@ -844,8 +873,10 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) map[i] = NULL; } - /* Then, go through and check for zeroed pages, removing write permission - * for those with zeroes. */ + /* + * Then, go through and check for zeroed pages, removing write permission + * for those with zeroes. + */ for ( i=0; idefault_access); - /* See if the page was successfully unmapped. (Allow one refcount - * for being allocated to a domain.) */ + /* + * See if the page was successfully unmapped. (Allow one refcount + * for being allocated to a domain.) + */ if ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) > 1 ) { unmap_domain_page(map[i]); @@ -895,8 +928,10 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) unmap_domain_page(map[i]); - /* See comment in p2m_pod_zero_check_superpage() re gnttab - * check timing. */ + /* + * See comment in p2m_pod_zero_check_superpage() re gnttab + * check timing. + */ if ( j < PAGE_SIZE/sizeof(*map[i]) ) { p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K, @@ -944,9 +979,11 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) limit = (start > POD_SWEEP_LIMIT) ? (start - POD_SWEEP_LIMIT) : 0; /* FIXME: Figure out how to avoid superpages */ - /* NOTE: Promote to globally locking the p2m. This will get complicated + /* + * NOTE: Promote to globally locking the p2m. This will get complicated * in a fine-grained scenario. If we lock each gfn individually we must be - * careful about spinlock recursion limits and POD_SWEEP_STRIDE. */ + * careful about spinlock recursion limits and POD_SWEEP_STRIDE. + */ p2m_lock(p2m); for ( i=p2m->pod.reclaim_single; i > 0 ; i-- ) { @@ -963,11 +1000,13 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) j = 0; } } - /* Stop if we're past our limit and we have found *something*. + /* + * Stop if we're past our limit and we have found *something*. * * NB that this is a zero-sum game; we're increasing our cache size * by re-increasing our 'debt'. Since we hold the pod lock, - * (entry_count - count) must remain the same. */ + * (entry_count - count) must remain the same. + */ if ( i < limit && (p2m->pod.count > 0 || hypercall_preempt_check()) ) break; } @@ -1045,20 +1084,25 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, ASSERT(gfn_locked_by_me(p2m, gfn)); pod_lock(p2m); - /* This check is done with the pod lock held. This will make sure that + /* + * This check is done with the pod lock held. This will make sure that * even if d->is_dying changes under our feet, p2m_pod_empty_cache() - * won't start until we're done. */ + * won't start until we're done. + */ if ( unlikely(d->is_dying) ) goto out_fail; - /* Because PoD does not have cache list for 1GB pages, it has to remap - * 1GB region to 2MB chunks for a retry. */ + /* + * Because PoD does not have cache list for 1GB pages, it has to remap + * 1GB region to 2MB chunks for a retry. + */ if ( order == PAGE_ORDER_1G ) { pod_unlock(p2m); gfn_aligned = (gfn >> order) << order; - /* Note that we are supposed to call p2m_set_entry() 512 times to + /* + * Note that we are supposed to call p2m_set_entry() 512 times to * split 1GB into 512 2MB pages here. But We only do once here because * p2m_set_entry() should automatically shatter the 1GB page into * 512 2MB pages. The rest of 511 calls are unnecessary. @@ -1075,8 +1119,10 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, if ( p2m->pod.entry_count > p2m->pod.count ) pod_eager_reclaim(p2m); - /* Only sweep if we're actually out of memory. Doing anything else - * causes unnecessary time and fragmentation of superpages in the p2m. */ + /* + * Only sweep if we're actually out of memory. Doing anything else + * causes unnecessary time and fragmentation of superpages in the p2m. + */ if ( p2m->pod.count == 0 ) p2m_pod_emergency_sweep(p2m); @@ -1088,8 +1134,10 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, if ( gfn > p2m->pod.max_guest ) p2m->pod.max_guest = gfn; - /* Get a page f/ the cache. A NULL return value indicates that the - * 2-meg range should be marked singleton PoD, and retried */ + /* + * Get a page f/ the cache. A NULL return value indicates that the + * 2-meg range should be marked singleton PoD, and retried. + */ if ( (p = p2m_pod_cache_get(p2m, order)) == NULL ) goto remap_and_retry; @@ -1146,8 +1194,10 @@ remap_and_retry: pod_unlock(p2m); /* Remap this 2-meg region in singleton chunks */ - /* NOTE: In a p2m fine-grained lock scenario this might - * need promoting the gfn lock from gfn->2M superpage */ + /* + * NOTE: In a p2m fine-grained lock scenario this might + * need promoting the gfn lock from gfn->2M superpage. + */ gfn_aligned = (gfn>>order)< X-Patchwork-Id: 114609 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653918qgn; Mon, 2 Oct 2017 06:02:12 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBD5t5bMCdFgk5+vld6GLacGcyyLZwXRwLKOqY9ZsfApD8wc69pVmk4Mcspof75x6ySQ/CX X-Received: by 10.36.53.75 with SMTP id k72mr19375322ita.8.1506949332244; Mon, 02 Oct 2017 06:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949332; cv=none; d=google.com; s=arc-20160816; b=laMOWBR+tH9nQknVXy35eDcACvyH7HD128uFH2QZ9tL9AFFN7ZFQ/4eTY3bGmNrBlr RKHAXZg+dqPmtZMXNwcgy8T/bfZ0WoO2JQCP8VF0x8IvyqEc8qnhfTqVeNxHFiyzUpi7 SstH9YmZKc9JvF7BDHQbITa9ZZYd5F2xpgF3PDBaBhoeeUNhZvcs50vvSKeIfraZBSdo 8te6uA9bZhNpGKlGyHqQl+yJylppgmGSmMlUJ7mTSeAEwk/EQvZ2tSxo9a8hJ5eA81Vi GoiLB6z2+MFTDNZlmvKVahNUMdjMzwD8591KFZrS32UBpgoGwWpIRit80jhjBtxwL93k +e7Q== 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:arc-authentication-results; bh=7ysG71tHsIZ+ZkTJnj8iLp3ZN9pbcrmXbp6JrM2/2cc=; b=CYTYz0boVNFjWANmRwV3r6q4FFSyZow2NRQpihqn4/qZv1QwF4Byizn0Kj2xgVJY5K 4nqmuX3H5RGomamE3xmZQPumwq6Z9u158lHkHMGkhxbzU9WmVZ5K+u2zUPJAN/LeR3w9 tKCMzuQ8d9i1XHZG6bChLOBs0IcE7rFjnAJxKxwWg9Xd6dxBUH/UopVFiG5teyceO87S A4GHfWtzTYkR5hTcv/0yUeeJfnCmiTmn5gx/gj0y4e0i3Z+ftgfKihgT7HTqaMwT6VT7 73YBV8LdhuwmVRIbsEid6nM3GJXgt9QGAz6xlzJJmulDtpok7qELmIoy5E/qksoN6UFh spOg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id h66si8603127itg.201.2017.10.02.06.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:12 -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 1dz0KE-0003cd-FE; Mon, 02 Oct 2017 12:59:58 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KC-0003bX-TW for xen-devel@lists.xen.org; Mon, 02 Oct 2017 12:59:57 +0000 Received: from [85.158.137.68] by server-16.bemta-3.messagelabs.com id 21/8A-01778-C4832D95; Mon, 02 Oct 2017 12:59:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdfb4lK kwcKT2hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aX9S/ZC97mVRy53MPYwLjEt4uRi0NIYDOj xPz/k5ggnNOMEgfWNjJ2MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8BiRonP+3uZQRLCAjYSJ 6feZgexWQRUJS7ePc8CYvMKWErsbLvGBmJLCMhL7Gq7yApicwpYSbw//hHMFgKqOd49iWkCI/ cCRoZVjOrFqUVlqUW6ZnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIEermdgYNz BeKXN+RCjJAeTkigvs+GlSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvBrmQDnBotT01Iq0zBxg qMGkJTh4lER4TUHSvMUFibnFmekQqVOMuhwdN+/+YRJiycvPS5US5/1vBlQkAFKUUZoHNwIW9 pcYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfPWgqziycwrgdv0CugIJqAj5nRdADmiJBEhJd XAyMvzJUXnns4UC7FJtuy/L54MEdzCXNb0doL9Y32m54pfa44mbrHWSwyZm60YYZ5mp/tgcaF EjeeR75Kc7ZPZ0me3LFu4S/rZpwMHi32bNDdP4Pb1Wsin8/WpS53e0asyO1Y6Kjav2v79nOOR e7wtXFnRmuszTPt/v2K8khdVlH3q5PQL73MtlViKMxINtZiLihMBJlGY8nYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1506949194!114264054!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22724 invoked from network); 2 Oct 2017 12:59:55 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-31.messagelabs.com with SMTP; 2 Oct 2017 12:59:55 -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 9F4A1165D; Mon, 2 Oct 2017 05:59:54 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 868A33F53D; Mon, 2 Oct 2017 05:59:53 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:30 +0100 Message-Id: <20171002125941.11274-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 04/15] xen/x86: p2m-pod: Fix coding style 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" Also take the opportunity to: - move from 1 << * to 1UL << *. - use unsigned when possible - move from unsigned int -> unsigned long for some induction variables Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Move some 1 << * to 1UL << * changes from previous to this patch - Add George's and Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 106 +++++++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 52 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 6beb26b00a..f04d6e03e2 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -60,7 +60,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m, struct page_info *page, unsigned int order) { - int i; + unsigned long i; struct page_info *p; struct domain *d = p2m->domain; @@ -70,23 +70,24 @@ p2m_pod_cache_add(struct p2m_domain *p2m, mfn = page_to_mfn(page); /* Check to make sure this is a contiguous region */ - if( mfn_x(mfn) & ((1 << order) - 1) ) + if ( mfn_x(mfn) & ((1UL << order) - 1) ) { printk("%s: mfn %lx not aligned order %u! (mask %lx)\n", __func__, mfn_x(mfn), order, ((1UL << order) - 1)); return -1; } - for(i=0; i < 1 << order ; i++) { + for ( i = 0; i < 1UL << order ; i++) + { struct domain * od; p = mfn_to_page(_mfn(mfn_x(mfn) + i)); od = page_get_owner(p); - if(od != d) + if ( od != d ) { printk("%s: mfn %lx expected owner d%d, got owner d%d!\n", __func__, mfn_x(mfn), d->domain_id, - od?od->domain_id:-1); + od ? od->domain_id : -1); return -1; } } @@ -99,12 +100,12 @@ p2m_pod_cache_add(struct p2m_domain *p2m, * guaranteed to be zero; but by reclaiming zero pages, we implicitly * promise to provide zero pages. So we scrub pages before using. */ - for ( i = 0; i < (1 << order); i++ ) + for ( i = 0; i < (1UL << order); i++ ) clear_domain_page(_mfn(mfn_x(page_to_mfn(page)) + i)); /* First, take all pages off the domain list */ lock_page_alloc(p2m); - for(i=0; i < 1 << order ; i++) + for ( i = 0; i < 1UL << order ; i++ ) { p = page + i; page_list_del(p, &d->page_list); @@ -128,7 +129,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m, default: BUG(); } - p2m->pod.count += 1L << order; + p2m->pod.count += 1UL << order; return 0; } @@ -140,7 +141,7 @@ static struct page_info * p2m_pod_cache_get(struct p2m_domain *p2m, unsigned int order) { struct page_info *p = NULL; - int i; + unsigned long i; ASSERT(pod_locked_by_me(p2m)); @@ -162,7 +163,7 @@ static struct page_info * p2m_pod_cache_get(struct p2m_domain *p2m, p = page_list_remove_head(&p2m->pod.super); mfn = mfn_x(page_to_mfn(p)); - for ( i=0; ipod.single); @@ -174,12 +175,12 @@ static struct page_info * p2m_pod_cache_get(struct p2m_domain *p2m, case PAGE_ORDER_2M: BUG_ON( page_list_empty(&p2m->pod.super) ); p = page_list_remove_head(&p2m->pod.super); - p2m->pod.count -= 1 << order; + p2m->pod.count -= 1UL << order; break; case PAGE_ORDER_4K: BUG_ON( page_list_empty(&p2m->pod.single) ); p = page_list_remove_head(&p2m->pod.single); - p2m->pod.count -= 1; + p2m->pod.count -= 1UL; break; default: BUG(); @@ -187,7 +188,7 @@ static struct page_info * p2m_pod_cache_get(struct p2m_domain *p2m, /* Put the pages back on the domain page_list */ lock_page_alloc(p2m); - for ( i = 0 ; i < (1 << order); i++ ) + for ( i = 0 ; i < (1UL << order); i++ ) { BUG_ON(page_get_owner(p + i) != p2m->domain); page_list_add_tail(p + i, &p2m->domain->page_list); @@ -251,7 +252,8 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int p while ( pod_target < p2m->pod.count ) { struct page_info * page; - int order, i; + unsigned int order; + unsigned long i; if ( (p2m->pod.count - pod_target) > SUPERPAGE_PAGES && !page_list_empty(&p2m->pod.super) ) @@ -264,10 +266,10 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int p ASSERT(page != NULL); /* Then free them */ - for ( i = 0 ; i < (1 << order) ; i++ ) + for ( i = 0 ; i < (1UL << order) ; i++ ) { /* Copied from common/memory.c:guest_remove_page() */ - if ( unlikely(!get_page(page+i, d)) ) + if ( unlikely(!get_page(page + i, d)) ) { gdprintk(XENLOG_INFO, "Bad page free for domain %u\n", d->domain_id); ret = -EINVAL; @@ -275,12 +277,12 @@ p2m_pod_set_cache_target(struct p2m_domain *p2m, unsigned long pod_target, int p } if ( test_and_clear_bit(_PGT_pinned, &(page+i)->u.inuse.type_info) ) - put_page_and_type(page+i); + put_page_and_type(page + i); if ( test_and_clear_bit(_PGC_allocated, &(page+i)->count_info) ) - put_page(page+i); + put_page(page + i); - put_page(page+i); + put_page(page + i); if ( preemptible && pod_target != p2m->pod.count && hypercall_preempt_check() ) @@ -513,7 +515,7 @@ p2m_pod_decrease_reservation(struct domain *d, xen_pfn_t gpfn, unsigned int order) { - int ret=0; + int ret = 0; unsigned long i, n; struct p2m_domain *p2m = p2m_get_hostp2m(d); bool_t steal_for_cache; @@ -556,7 +558,7 @@ p2m_pod_decrease_reservation(struct domain *d, } /* No populate-on-demand? Don't need to steal anything? Then we're done!*/ - if(!pod && !steal_for_cache) + if ( !pod && !steal_for_cache ) goto out_unlock; if ( !nonpod ) @@ -567,7 +569,7 @@ p2m_pod_decrease_reservation(struct domain *d, */ p2m_set_entry(p2m, gpfn, INVALID_MFN, order, p2m_invalid, p2m->default_access); - p2m->pod.entry_count-=(1<pod.entry_count -= 1UL << order; BUG_ON(p2m->pod.entry_count < 0); ret = 1; goto out_entry_check; @@ -581,10 +583,10 @@ p2m_pod_decrease_reservation(struct domain *d, * - order >= SUPERPAGE_ORDER (the loop below will take care of this) * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER) */ - if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1 << order) && + if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1UL << order) && p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES - 1)) ) { - pod = 1 << order; + pod = 1UL << order; ram = nonpod = 0; ASSERT(steal_for_cache == (p2m->pod.entry_count > p2m->pod.count)); } @@ -625,7 +627,7 @@ p2m_pod_decrease_reservation(struct domain *d, * avoid breaking up superpages. */ struct page_info *page; - unsigned int j; + unsigned long j; ASSERT(mfn_valid(mfn)); @@ -753,13 +755,13 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) } /* Now, do a quick check to see if it may be zero before unmapping. */ - for ( i=0; icount_info & PGC_count_mask) > 1 ) @@ -790,12 +792,12 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) } /* Finally, do a full zero-check */ - for ( i=0; i < SUPERPAGE_PAGES; i++ ) + for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { map = map_domain_page(_mfn(mfn_x(mfn0) + i)); - for ( j=0; jdomain; int i, j; @@ -856,7 +858,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) max_ref++; /* First, get the gfn list, translate to mfns, and map the pages. */ - for ( i=0; iget_entry(p2m, gfns[i], types + i, &a, 0, NULL, NULL); @@ -877,14 +879,14 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) * Then, go through and check for zeroed pages, removing write permission * for those with zeroes. */ - for ( i=0; idefault_access); + types[i], p2m->default_access); } else { @@ -968,7 +970,7 @@ static void p2m_pod_emergency_sweep(struct p2m_domain *p2m) { unsigned long gfns[POD_SWEEP_STRIDE]; - unsigned long i, j=0, start, limit; + unsigned long i, j = 0, start, limit; p2m_type_t t; @@ -985,7 +987,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) * careful about spinlock recursion limits and POD_SWEEP_STRIDE. */ p2m_lock(p2m); - for ( i=p2m->pod.reclaim_single; i > 0 ; i-- ) + for ( i = p2m->pod.reclaim_single; i > 0 ; i-- ) { p2m_access_t a; (void)p2m->get_entry(p2m, i, &t, &a, 0, NULL, NULL); @@ -1079,7 +1081,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, struct page_info *p = NULL; /* Compiler warnings */ unsigned long gfn_aligned; mfn_t mfn; - int i; + unsigned long i; ASSERT(gfn_locked_by_me(p2m, gfn)); pod_lock(p2m); @@ -1143,7 +1145,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, mfn = page_to_mfn(p); - BUG_ON((mfn_x(mfn) & ((1 << order)-1)) != 0); + BUG_ON((mfn_x(mfn) & ((1UL << order) - 1)) != 0); gfn_aligned = (gfn >> order) << order; @@ -1156,7 +1158,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, paging_mark_dirty(d, mfn_add(mfn, i)); } - p2m->pod.entry_count -= (1 << order); + p2m->pod.entry_count -= (1UL << order); BUG_ON(p2m->pod.entry_count < 0); pod_eager_record(p2m, gfn_aligned, order); @@ -1198,8 +1200,8 @@ remap_and_retry: * NOTE: In a p2m fine-grained lock scenario this might * need promoting the gfn lock from gfn->2M superpage. */ - gfn_aligned = (gfn>>order)<> order) << order; + for ( i = 0; i < (1UL << order); i++ ) p2m_set_entry(p2m, gfn_aligned + i, INVALID_MFN, PAGE_ORDER_4K, p2m_populate_on_demand, p2m->default_access); if ( tb_init_done ) @@ -1262,7 +1264,7 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, if ( rc == 0 ) { pod_lock(p2m); - p2m->pod.entry_count += 1 << order; + p2m->pod.entry_count += 1UL << order; p2m->pod.entry_count -= pod_count; BUG_ON(p2m->pod.entry_count < 0); pod_unlock(p2m); From patchwork Mon Oct 2 12:59:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114599 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653552qgn; Mon, 2 Oct 2017 06:01:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAIKjyu3CV7eJ6Ypnn72zKY5OdOTG3tKnK4A85RTuzrnPu/iMtFI3juVX9ypZELBwNoea0v X-Received: by 10.107.24.133 with SMTP id 127mr25031240ioy.115.1506949318417; Mon, 02 Oct 2017 06:01:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949318; cv=none; d=google.com; s=arc-20160816; b=X5X42AjsKUDLscpGbATC5+/Kt6fLaq4/44Rwtv6qhKo7z75mG54JwLLGVnImb9UoCW L6xRrosz6cEUN/i/WxGM9ttbLDy76gVenjgA7oWc7Dy6iPeh0LyNRwFNIO4df6gXbY+F qLsfGTH6/1epHf6bQxoRM4AX99WqU3z/jSf6IW8C8RTyl0FGRhf+7hAnp7ACv0j3GssL 2j5yQ99V5ks7wIOgonVFnwAZE9noNQq+OoKZ1keEAoaohM2krsSCKDdC1GS+pT3bFj5Q vgQ0voPd3rqZxBi5utJ5qQWHA2n9IMh4tN+d4Y6XwwL71UcBqX/8GkYxnQ52++JvB5+Z BV4Q== 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:arc-authentication-results; bh=6mFGRGeEvkFbGibadCG7Ovr1nDsYChaFfZMn/Euw93c=; b=FJgFtSZskHCjPp2C8fyFeqYWRW4mrliKjFW2PiUA8GBdCedCvld9t9oOjhTkW9sSBR jg0/FHSQwhfQGTtzzd4RLUOH/mMMt3zhnE+iBUs0AqK18U8oyt6XPASYvqj2wXdKYLxf aRav8USixnDfmLpqWJIQAH6UN+4CtxWc5bMqwslTZ8XWUAuW+2wy+181cPirbkfGwUKF dTFvafM/NsL4qSwg4enla6Jpw9q48WFl9I1FQH37U8TltMeVNk6OzM2i79RFn4mqMIox OdNtDbC6bz5fdkxW+0KFq5IhZnap0tfeb6NqO+Z5246GTnksogqX58aYQvnTwcbm7PBJ vQQQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id g84si8987547iof.76.2017.10.02.06.01.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:01:58 -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 1dz0KE-0003co-NW; Mon, 02 Oct 2017 12:59:58 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KE-0003cR-2l for xen-devel@lists.xen.org; Mon, 02 Oct 2017 12:59:58 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id EA/87-18674-D4832D95; Mon, 02 Oct 2017 12:59:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdfH4lK kwYdZuhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bfs1kFrwUrfp3pYm5g/MnbxcjFISSwmVFi 9qenbBDOaUaJH6/usHQxcnKwCWhK3Pn8iQnEFhGQlrj2+TIjSBGzwGJGic/7e5lBEsICSRKnb 64Fs1kEVCV2NbwEa+AVsJSY+/EPO4gtISAvsavtIiuIzSlgJfH++EcwWwio5nj3JKYJjNwLGB lWMWoUpxaVpRbpGhnqJRVlpmeU5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIEeriegYFxB+P dyX6HGCU5mJREeZkNL0UK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuBNMQfKCRalpqdWpGXmAEMN Ji3BwaMkwlsMkuYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6qlDhvBUiRAEhRRmke3AhY2F9il JUS5mVkYGAQ4ilILcrNLEGVf8UozsGoJMxbCzKFJzOvBG7TK6AjmICOmNN1AeSIkkSElFQD4w HP8oT6xUIfiraEBKxPZJc7EX5Nej9fSsi2A9O/nmv4qvlLwmHj+vtXbXbFHvB6on/JQ/XUzWf fVU8+nvYkm8cuePnWts47+0QE+66edTggfmNSq8vyyssVDdsX7r/80+yKkcJdt9PS37a+Y2M8 ObPu0rKHbo9ip1ZX/Z5bN+Xfjg/ZaytDJ19TYinOSDTUYi4qTgQADEQP0nYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1506949196!85727806!1 X-Originating-IP: [217.140.101.70] 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 63509 invoked from network); 2 Oct 2017 12:59:56 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-206.messagelabs.com with SMTP; 2 Oct 2017 12:59:56 -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 E33A915BF; Mon, 2 Oct 2017 05:59:55 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D453C3F53D; Mon, 2 Oct 2017 05:59:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:31 +0100 Message-Id: <20171002125941.11274-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 05/15] xen/x86: p2m-pod: Avoid redundant assignments in p2m_pod_demand_populate 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" gfn_aligned is assigned 3 times with the exact same formula. All the variables used are not modified, so consolidate in a single assignment at the beginning of the function. Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add George's and Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index f04d6e03e2..bcc87aee03 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1079,7 +1079,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, { struct domain *d = p2m->domain; struct page_info *p = NULL; /* Compiler warnings */ - unsigned long gfn_aligned; + unsigned long gfn_aligned = (gfn >> order) << order; mfn_t mfn; unsigned long i; @@ -1102,7 +1102,6 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, if ( order == PAGE_ORDER_1G ) { pod_unlock(p2m); - gfn_aligned = (gfn >> order) << order; /* * Note that we are supposed to call p2m_set_entry() 512 times to * split 1GB into 512 2MB pages here. But We only do once here because @@ -1147,8 +1146,6 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, BUG_ON((mfn_x(mfn) & ((1UL << order) - 1)) != 0); - gfn_aligned = (gfn >> order) << order; - p2m_set_entry(p2m, gfn_aligned, mfn, order, p2m_ram_rw, p2m->default_access); @@ -1200,7 +1197,6 @@ remap_and_retry: * NOTE: In a p2m fine-grained lock scenario this might * need promoting the gfn lock from gfn->2M superpage. */ - gfn_aligned = (gfn >> order) << order; for ( i = 0; i < (1UL << order); i++ ) p2m_set_entry(p2m, gfn_aligned + i, INVALID_MFN, PAGE_ORDER_4K, p2m_populate_on_demand, p2m->default_access); From patchwork Mon Oct 2 12:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114606 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653853qgn; Mon, 2 Oct 2017 06:02:09 -0700 (PDT) X-Google-Smtp-Source: AOwi7QChVLJTZOJ7Dcz1K6UFnBi5qpgCwvti0C5jXwHtyqeD0Kt6k8U6H9RwJcGcmIEIWE3k71Nb X-Received: by 10.107.132.204 with SMTP id o73mr23199680ioi.89.1506949329847; Mon, 02 Oct 2017 06:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949329; cv=none; d=google.com; s=arc-20160816; b=m6rAVAxIqYloewdY2bI4bgGdBchJt2cd5fHKdsEboNfuRTFPp8qz/LttrxemX2/L2d a1yPLrhyMd/W1FBAfzJWKkD49wcjIFwOi/PnU2L+n4NXfK9B4iK/zfsmIBgtWCn6I8DP NAPh348/9cjRTvfs7SVNAqTCeZjIzKudi5ukWCgHMvwdlwpL9xo9o6dPeiqB2snv7KfY W4lAIN4GbUI21AVrPDfbe3/u1CSA4dgd5o2tRS+pT4JEU2jp4H1JqyXY8LoEXmwnusOb q1NnUn+QYGgYTxUQ1Qbc9LX0PASBXGyPA0Psp46O/7HNTClwSL3U0r9wQr5btW84/HCf vzNg== 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:arc-authentication-results; bh=2lfdPwEPwr8Z9d0LI7FjztxCjhHMqRyuGAqwZ/IsnZA=; b=ezvfu4Z8gmYy6e+EDPadEM8uNX72mLwmfT2FzdB2gIpZx0Xl/F+BhIxnrRdsIRB81+ z0KO6jHmM7hbsrE/Rpj5i3ubYFqFWldF4YV91jA8m4wGxgNecJ+0H/BkF2mkTMejkI6O xvm6QCDKztHCLbW2iV/QMveu/Xgj7lTx9OH0R1OTHcrYSzke+78KLEoKMzzyrpxNzrLZ asAzj4LRxzMhYq+JM21wr89S6NKsmF+Jwb4cp86/4BFX1MZCx8LWSH5EpyUG3XpxJcCk PgmiLJfLKysXaX91bfibAGMf531DoQdXobwpJq2MuwAdF+CVIteDeAK8+4vaI8eo3M1x KmFg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id w191si8911915ith.6.2017.10.02.06.02.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:09 -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 1dz0KY-0004QR-4K; Mon, 02 Oct 2017 13:00:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KX-0004OI-3l for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:17 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id FD/20-03422-06832D95; Mon, 02 Oct 2017 13:00:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTdfX4lK kwY4rlhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bzh+esBSdFKloOzGZsYNzG38XIxSEksJlR Ysmsm0wQzmlGiV1tB4EcTg42AU2JO58/gdkiAtIS1z5fZgQpYhZYzCjxeX8vM0hCWMBD4uL9P +xdjBwcLAKqEgsvuoGEeQUsJa5v3sMGYksIyAPNvMgKYnMKWEm8P/4RzBYCqjnePYlpAiP3Ak aGVYwaxalFZalFukZGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgR5mAIIdjGv mBx5ilORgUhLlZTa8FCnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgjfFHCgnWJSanlqRlpkDDDWY tAQHj5II7wRToDRvcUFibnFmOkTqFKMxx49JV/4wcXTcvPuHSYglLz8vVUqc978ZUKkASGlGa R7cIFgMXGKUlRLmZQQ6TYinILUoN7MEVf4VozgHo5IwLxfIPTyZeSVw+14BncIEdMqcrgsgp5 QkIqSkGhinXD80/2zshHMuFwsmO0bE/phTmfyB42S16Zu/RZMUfmlsO6HtbmHoeXv5l8+9N/Y /Y2lVv3XZ69ZXqx054hsWnP5l17V/g9DaZp6773+qiVR292QIOUpHX0kqmVvG/nrujuNXqr7E OyScyig/UWO/5rOvq8wq6dNzVPZVBy9w/t+1RNMp4cwpJZbijERDLeai4kQAyyKw33wCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1506949197!118733057!1 X-Originating-IP: [217.140.101.70] 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 35796 invoked from network); 2 Oct 2017 12:59:57 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 2 Oct 2017 12:59:57 -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 3CC4A164F; Mon, 2 Oct 2017 05:59:57 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2DE523F53D; Mon, 2 Oct 2017 05:59:56 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:32 +0100 Message-Id: <20171002125941.11274-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 06/15] xen/x86: p2m-pod: Clean-up use of typesafe MFN 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" Some unboxing/boxing can be avoided by using mfn_add(...) instead. Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap Reviewed-by: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add George's and Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index bcc87aee03..34f5239b6d 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -101,7 +101,7 @@ p2m_pod_cache_add(struct p2m_domain *p2m, * promise to provide zero pages. So we scrub pages before using. */ for ( i = 0; i < (1UL << order); i++ ) - clear_domain_page(_mfn(mfn_x(page_to_mfn(page)) + i)); + clear_domain_page(mfn_add(page_to_mfn(page), i)); /* First, take all pages off the domain list */ lock_page_alloc(p2m); @@ -743,7 +743,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) mfn0 = mfn; type0 = type; } - else if ( type != type0 || mfn_x(mfn) != (mfn_x(mfn0) + i) ) + else if ( type != type0 || !mfn_eq(mfn, mfn_add(mfn0, i)) ) goto out; n = 1UL << min(cur_order, SUPERPAGE_ORDER + 0U); @@ -758,7 +758,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { /* Quick zero-check */ - map = map_domain_page(_mfn(mfn_x(mfn0) + i)); + map = map_domain_page(mfn_add(mfn0, i)); for ( j = 0; j < 16; j++ ) if ( *(map + j) != 0 ) @@ -783,7 +783,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) */ for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { - mfn = _mfn(mfn_x(mfn0) + i); + mfn = mfn_add(mfn0, i); if ( (mfn_to_page(mfn)->count_info & PGC_count_mask) > 1 ) { reset = 1; @@ -794,7 +794,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) /* Finally, do a full zero-check */ for ( i = 0; i < SUPERPAGE_PAGES; i++ ) { - map = map_domain_page(_mfn(mfn_x(mfn0) + i)); + map = map_domain_page(mfn_add(mfn0, i)); for ( j = 0; j < (PAGE_SIZE / sizeof(*map)); j++ ) if ( *(map+j) != 0 ) From patchwork Mon Oct 2 12:59:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114597 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653593qgn; Mon, 2 Oct 2017 06:02:00 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCajsn3sH0cyvjxJXkBFbXKpFCauOt8z487LAl21kC2fw7YDnwS8XrjBAyglOujFgktN+47 X-Received: by 10.107.168.138 with SMTP id e10mr24968585ioj.152.1506949319954; Mon, 02 Oct 2017 06:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949319; cv=none; d=google.com; s=arc-20160816; b=RYixhvQXcx4mEtyn28qFsNxcuAJ9+21WR2z6dEd8d1t4aA2CC6JOOH4hziFUuHDCic NY1i8p8j3egku/fkYTcMdjxQkZ8+1GcYbEaJ/BJR653fhqJgQUwZsA4DnMIWa2fnasUI TGoyaL5nj+FQ+twuPy789xlksTqozuAreTYaWna3zNu6uHpFCyoeMfoMEo8e+dcxMIVz sXv2szkV37iB532wbvPXfttKTmY48R92KJMlAQUc4+ZJG9x79aLafMeOzn7rYrShV79D IosUSY63rmhrr/UE0tFb/GGvLbFkW4HrPC/iccBKKQYN4gRt2UD5EbsHB0US3yY6aRO9 id6g== 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:arc-authentication-results; bh=m3hguIuVnFQlUl4uAkNKra1oxpcnWEVpkG3ApP8onZA=; b=sV39gyfQlU0YEyjRDqyluRRs3LP1gsT1EX/FMhe767uIpX12oHHq0v2M47m/G/uHct 72ME59wrM/Je49bsENfQqtOFRSnNF+fD5pLhLCwRJNQVCNsvZB3deSpnoEuG4Ur3o9fC 2Kw4WrVgchtP8IX3LbQi9HoHxnG3k5tcebmO7jbjPlcouzrt6/56+n44YprJpOI+/auP JvK99jj5vpmKpAa5watnk1xRwadl4g6pK9hWG+GzZGuruBoq4ydHZYx6LI0f/kRjbVDn e22xymNxDVchMWCcvq7Bfx2wszj8uHzNEbFPgStVrpl5S6lxCF2aMs+dI4Wbq6OJzpAF azlw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f202si8638895itb.173.2017.10.02.06.01.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:01:59 -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 1dz0KI-0003ov-AG; Mon, 02 Oct 2017 13:00:02 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KG-0003dq-V9 for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:01 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id ED/EF-03093-05832D95; Mon, 02 Oct 2017 13:00:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdff4lK kwferihZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bij+cZC5ZZVXxff4e1gfGzdhcjJ4eQwGZG iaeTvCDs04wSM/orQWw2AU2JO58/MYHYIgLSEtc+X2bsYuTiYBZYzCjxeX8vM0hCWCBGYuWC1 ewgNouAqsSP///BbF4BS4nf91+zgdgSAvISu9ousoLYnAJWEu+Pf2SFWGYpcbx7EtMERu4FjA yrGDWKU4vKUot0jUz1kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzEC/csABDsYVy0 IPMQoycGkJMrLbHgpUogvKT+lMiOxOCO+qDQntfgQowwHh5IE72szoJxgUWp6akVaZg4w0GDS Ehw8SiK8E0yB0rzFBYm5xZnpEKlTjLocHTfv/mESYsnLz0uVEuf9DzJDAKQoozQPbgQs6C8xy koJ8zICHSXEU5BalJtZgir/ilGcg1FJmLfWHGgKT2ZeCdymV0BHMAEdMafrAsgRJYkIKakGxo LXSbWWaq9PZ0tde3Tylb147uY7M3wcfjP3PrOv45F5vEBWIPwMu+qm7imt7hmnSqtMZxoZP93 DJ3a+X+gik0zi9njeaZPlfatOMAoGHbj5MU7/s2jQXuVHuXO5HyybbXrE5fLr1O8bq4MaCkKn HLObw3XYlCfuYMShfIYPfMG2C+REpfdxKLEUZyQaajEXFScCAAravyJ1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1506949198!85486809!1 X-Originating-IP: [217.140.101.70] 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 5110 invoked from network); 2 Oct 2017 12:59:59 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-21.messagelabs.com with SMTP; 2 Oct 2017 12:59:59 -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 8A77715BF; Mon, 2 Oct 2017 05:59:58 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7BA403F53D; Mon, 2 Oct 2017 05:59:57 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:33 +0100 Message-Id: <20171002125941.11274-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 07/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_decrease_reservation 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Acked-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - Add Andrew's acked-by --- xen/arch/arm/p2m.c | 3 +-- xen/arch/x86/mm/p2m-pod.c | 20 +++++++++----------- xen/common/memory.c | 3 ++- xen/include/asm-arm/p2m.h | 13 ------------- xen/include/asm-x86/p2m.h | 7 ------- xen/include/xen/p2m-common.h | 13 +++++++++++++ 6 files changed, 25 insertions(+), 34 deletions(-) diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index 192a1c329d..0410b1e86b 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -393,8 +393,7 @@ int guest_physmap_mark_populate_on_demand(struct domain *d, return -ENOSYS; } -int p2m_pod_decrease_reservation(struct domain *d, - xen_pfn_t gpfn, +int p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) { return -ENOSYS; diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 34f5239b6d..eb74e5c01f 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -511,9 +511,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn); * allow decrease_reservation() to handle everything else. */ int -p2m_pod_decrease_reservation(struct domain *d, - xen_pfn_t gpfn, - unsigned int order) +p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) { int ret = 0; unsigned long i, n; @@ -521,7 +519,7 @@ p2m_pod_decrease_reservation(struct domain *d, bool_t steal_for_cache; long pod, nonpod, ram; - gfn_lock(p2m, gpfn, order); + gfn_lock(p2m, gfn, order); pod_lock(p2m); /* @@ -545,7 +543,7 @@ p2m_pod_decrease_reservation(struct domain *d, p2m_type_t t; unsigned int cur_order; - p2m->get_entry(p2m, gpfn + i, &t, &a, 0, &cur_order, NULL); + p2m->get_entry(p2m, gfn_x(gfn) + i, &t, &a, 0, &cur_order, NULL); n = 1UL << min(order, cur_order); if ( t == p2m_populate_on_demand ) pod += n; @@ -567,7 +565,7 @@ p2m_pod_decrease_reservation(struct domain *d, * All PoD: Mark the whole region invalid and tell caller * we're done. */ - p2m_set_entry(p2m, gpfn, INVALID_MFN, order, p2m_invalid, + p2m_set_entry(p2m, gfn_x(gfn), INVALID_MFN, order, p2m_invalid, p2m->default_access); p2m->pod.entry_count -= 1UL << order; BUG_ON(p2m->pod.entry_count < 0); @@ -584,7 +582,7 @@ p2m_pod_decrease_reservation(struct domain *d, * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER) */ if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1UL << order) && - p2m_pod_zero_check_superpage(p2m, gpfn & ~(SUPERPAGE_PAGES - 1)) ) + p2m_pod_zero_check_superpage(p2m, gfn_x(gfn) & ~(SUPERPAGE_PAGES - 1)) ) { pod = 1UL << order; ram = nonpod = 0; @@ -605,13 +603,13 @@ p2m_pod_decrease_reservation(struct domain *d, p2m_access_t a; unsigned int cur_order; - mfn = p2m->get_entry(p2m, gpfn + i, &t, &a, 0, &cur_order, NULL); + mfn = p2m->get_entry(p2m, gfn_x(gfn) + i, &t, &a, 0, &cur_order, NULL); if ( order < cur_order ) cur_order = order; n = 1UL << cur_order; if ( t == p2m_populate_on_demand ) { - p2m_set_entry(p2m, gpfn + i, INVALID_MFN, cur_order, + p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order, p2m_invalid, p2m->default_access); p2m->pod.entry_count -= n; BUG_ON(p2m->pod.entry_count < 0); @@ -633,7 +631,7 @@ p2m_pod_decrease_reservation(struct domain *d, page = mfn_to_page(mfn); - p2m_set_entry(p2m, gpfn + i, INVALID_MFN, cur_order, + p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order, p2m_invalid, p2m->default_access); p2m_tlb_flush_sync(p2m); for ( j = 0; j < n; ++j ) @@ -663,7 +661,7 @@ out_entry_check: out_unlock: pod_unlock(p2m); - gfn_unlock(p2m, gpfn, order); + gfn_unlock(p2m, gfn, order); return ret; } diff --git a/xen/common/memory.c b/xen/common/memory.c index a2abf554e3..ad987e0f29 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -417,7 +417,8 @@ static void decrease_reservation(struct memop_args *a) /* See if populate-on-demand wants to handle this */ if ( is_hvm_domain(a->domain) - && p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) ) + && p2m_pod_decrease_reservation(a->domain, _gfn(gmfn), + a->extent_order) ) continue; for ( j = 0; j < (1 << a->extent_order); j++ ) diff --git a/xen/include/asm-arm/p2m.h b/xen/include/asm-arm/p2m.h index bc5bbf0db7..faadcfe8fe 100644 --- a/xen/include/asm-arm/p2m.h +++ b/xen/include/asm-arm/p2m.h @@ -266,19 +266,6 @@ static inline int guest_physmap_add_page(struct domain *d, mfn_t gfn_to_mfn(struct domain *d, gfn_t gfn); -/* - * Populate-on-demand - */ - -/* - * Call when decreasing memory reservation to handle PoD entries properly. - * Will return '1' if all entries were handled and nothing more need be done. - */ -int -p2m_pod_decrease_reservation(struct domain *d, - xen_pfn_t gpfn, - unsigned int order); - /* Look up a GFN and take a reference count on the backing page. */ typedef unsigned int p2m_query_t; #define P2M_ALLOC (1u<<0) /* Populate PoD and paged-out entries */ diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 10cdfc09a9..8f3409b400 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -643,13 +643,6 @@ int p2m_pod_empty_cache(struct domain *d); * domain matches target */ int p2m_pod_set_mem_target(struct domain *d, unsigned long target); -/* Call when decreasing memory reservation to handle PoD entries properly. - * Will return '1' if all entries were handled and nothing more need be done.*/ -int -p2m_pod_decrease_reservation(struct domain *d, - xen_pfn_t gpfn, - unsigned int order); - /* Scan pod cache when offline/broken page triggered */ int p2m_pod_offline_or_broken_hit(struct page_info *p); diff --git a/xen/include/xen/p2m-common.h b/xen/include/xen/p2m-common.h index 2b5696cf33..27f89208f5 100644 --- a/xen/include/xen/p2m-common.h +++ b/xen/include/xen/p2m-common.h @@ -20,4 +20,17 @@ int unmap_mmio_regions(struct domain *d, unsigned long nr, mfn_t mfn); +/* + * Populate-on-Demand + */ + +/* + * Call when decreasing memory reservation to handle PoD entries properly. + * Will return '1' if all entries were handled and nothing more need be done. + */ +int +p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, + unsigned int order); + + #endif /* _XEN_P2M_COMMON_H */ From patchwork Mon Oct 2 12:59:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114610 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp654023qgn; Mon, 2 Oct 2017 06:02:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD93y4fZwvHd81gyPjbO8ZeTXJ0CjUf7Q3MXqFmTUBViYzWYiL/Bs5yUYeL7chwDEGozShb X-Received: by 10.107.176.70 with SMTP id z67mr24496059ioe.81.1506949336913; Mon, 02 Oct 2017 06:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949336; cv=none; d=google.com; s=arc-20160816; b=u5m9ADqXJBaZkYSe9nNhIWNCle/sY8AKsbmnvlTI4TAY+eBAFiJq2yJcRBEa3xDb8a ojnZakOI6y2YK9eAc3gfGuHn3UguDLsqyxFuCs4oG6ScCYiOilenyNfqakYNROo/9dNZ h9rnAUAFbb2+sou8p0FCXWSbtEHK3WubmNO776bF+77d+cfRzldXqX3mDe3jbfNO0Xn4 IxDcwj+XxsWGdaHJGFtvOmqLmLelb3D8znO6j0E99HyJ6ZEfeqY2NJQSqzaDbOPo9mj1 80ktliv5i5daOIayux9KxE/zZGMr8EEGWnl2nRxecrwP/en8m+eEuFRFGcJcxDTFee3r gNbQ== 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:arc-authentication-results; bh=GX1kuKZcXX+PgyFTQcMqwqkUaOVBM2dxP9vV4lHsqHM=; b=G2fNTqUpjqp6TYGrBPwzQXhg2CPACRDoBAyWnW23+C3LgCZMDDej4pxCKicqSL+aAi 5nSHJXxfMdrGdpUVvb9Oh1CDmJIaqCC/eYl2brGFEYyCSvACsqVYOLwk2Ge9LA7XCMSL ONSD7gcj9BTj3c3L1C4vHm/JjAlv/KoqZluW1gp7EnxOgj7hMIqopbcG7tYR8aKUYTfH dgCSQ3D/TXIeS3/rE98l9UoMi8o5PrCDhUhvbXp7/pGRUVGBOs9nWpbZCALZrhD74SN6 sTX+YdblhNzSYlSsZDONqVAPCdAQ+kpWLPw30xKzpIGD3r+e0EzTFDijfQm2Lmf+y0O1 ElcA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i1si3517948itf.134.2017.10.02.06.02.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:16 -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 1dz0KN-0004Bs-JB; Mon, 02 Oct 2017 13:00:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KM-0004Al-6n for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:06 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id 47/31-03616-55832D95; Mon, 02 Oct 2017 13:00:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTfQ4lK kwccr2hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0Zv3zmWgvadjBWHJ91iamBc3MLYxcjFISSw mVHizpUudgjnNKPEuov7mLsYOTnYBDQl7nz+xARiiwhIS1z7fBmsg1ngKJPEnpYdrF2MHBzCA mkSe6c7gZgsAqoSx+9UgZTzClhKXL79DaxVQkBeYlfbRVYQm1PASuL98Y9gthBQzfHuSUwTGL kXMDKsYtQoTi0qSy3SNbTQSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQI9DEDEOx gvLkx4BCjJAeTkigvs+GlSCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvCnmQDnBotT01Iq0zBxg sMGkJTh4lER4i0HSvMUFibnFmekQqVOMuhwdN+/+YRJiycvPS5US560AKRIAKcoozYMbAQv8S 4yyUsK8jEBHCfEUpBblZpagyr9iFOdgVBLm5QKZwpOZVwK36RXQEUxAR8zpugByREkiQkqqgb F0At80dV/Rbe92zzlue2y3W0/wxKvP0y96z3nWbHPs7vxFTDn7/JZq7pXa9Fji+JfuJb8sDYr CtL9HJRt7fSz9Y693+3iK3pcKg1mByex/m4oDVs2o65jlw9uqYVp3kE+aWfHCdG+v1fOD9qmu Sew8pLInIXntmv+zXA5m3/qnVP+xekKN4y4lluKMREMt5qLiRAAtpL7NdwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1506949200!78959135!1 X-Originating-IP: [217.140.101.70] 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 3951 invoked from network); 2 Oct 2017 13:00:01 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-21.messagelabs.com with SMTP; 2 Oct 2017 13:00:01 -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 9931D164F; Mon, 2 Oct 2017 06:00:00 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CA0BE3F53D; Mon, 2 Oct 2017 05:59:58 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:34 +0100 Message-Id: <20171002125941.11274-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: Kevin Tian , Tamas K Lengyel , Jun Nakajima , Razvan Cojocaru , George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 08/15] xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and set_entry 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Kevin Tian Acked-by: Razvan Cojocaru Reviewed-by: Wei Liu Reviewed-by: George Dunlap Acked-by: Tamas K Lengyel --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Razvan Cojocaru Cc: Tamas K Lengyel Cc: George Dunlap Cc: Jun Nakajima Cc: Kevin Tian Changes in v3: - Add Razvan's acked-by - Add Wei's reviewed-by Changes in v2: - Add Andre's acked - Add Kevin's reviewed (EPT part) --- xen/arch/x86/hvm/hvm.c | 2 +- xen/arch/x86/mm/mem_access.c | 19 +++++------ xen/arch/x86/mm/mem_sharing.c | 4 +-- xen/arch/x86/mm/p2m-ept.c | 6 ++-- xen/arch/x86/mm/p2m-pod.c | 15 +++++---- xen/arch/x86/mm/p2m-pt.c | 6 ++-- xen/arch/x86/mm/p2m.c | 77 +++++++++++++++++++++++-------------------- xen/include/asm-x86/p2m.h | 4 +-- 8 files changed, 73 insertions(+), 60 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 887f0e556c..6b8c4cbdda 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1787,7 +1787,7 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla, { bool_t sve; - p2m->get_entry(p2m, gfn, &p2mt, &p2ma, 0, NULL, &sve); + p2m->get_entry(p2m, _gfn(gfn), &p2mt, &p2ma, 0, NULL, &sve); if ( !sve && altp2m_vcpu_emulate_ve(curr) ) { diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 33a77c9f1d..c0cd0174cf 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -66,7 +66,7 @@ static int _p2m_get_mem_access(struct p2m_domain *p2m, gfn_t gfn, } gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn_x(gfn), &t, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL); gfn_unlock(p2m, gfn, 0); if ( mfn_eq(mfn, INVALID_MFN) ) @@ -142,7 +142,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla, vm_event_request_t **req_ptr) { struct vcpu *v = current; - unsigned long gfn = gpa >> PAGE_SHIFT; + gfn_t gfn = gaddr_to_gfn(gpa); struct domain *d = v->domain; struct p2m_domain *p2m = NULL; mfn_t mfn; @@ -215,7 +215,7 @@ bool p2m_mem_access_check(paddr_t gpa, unsigned long gla, *req_ptr = req; req->reason = VM_EVENT_REASON_MEM_ACCESS; - req->u.mem_access.gfn = gfn; + req->u.mem_access.gfn = gfn_x(gfn); req->u.mem_access.offset = gpa & ((1 << PAGE_SHIFT) - 1); if ( npfec.gla_valid ) { @@ -247,7 +247,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, unsigned long gfn_l = gfn_x(gfn); int rc; - mfn = ap2m->get_entry(ap2m, gfn_l, &t, &old_a, 0, NULL, NULL); + mfn = ap2m->get_entry(ap2m, gfn, &t, &old_a, 0, NULL, NULL); /* Check host p2m if no valid entry in alternate */ if ( !mfn_valid(mfn) ) @@ -264,16 +264,16 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, if ( page_order != PAGE_ORDER_4K ) { unsigned long mask = ~((1UL << page_order) - 1); - unsigned long gfn2_l = gfn_l & mask; + gfn_t gfn2 = _gfn(gfn_l & mask); mfn_t mfn2 = _mfn(mfn_x(mfn) & mask); - rc = ap2m->set_entry(ap2m, gfn2_l, mfn2, page_order, t, old_a, 1); + rc = ap2m->set_entry(ap2m, gfn2, mfn2, page_order, t, old_a, 1); if ( rc ) return rc; } } - return ap2m->set_entry(ap2m, gfn_l, mfn, PAGE_ORDER_4K, t, a, + return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a, current->domain != d); } @@ -295,10 +295,9 @@ static int set_mem_access(struct domain *d, struct p2m_domain *p2m, mfn_t mfn; p2m_access_t _a; p2m_type_t t; - unsigned long gfn_l = gfn_x(gfn); - mfn = p2m->get_entry(p2m, gfn_l, &t, &_a, 0, NULL, NULL); - rc = p2m->set_entry(p2m, gfn_l, mfn, PAGE_ORDER_4K, t, a, -1); + mfn = p2m->get_entry(p2m, gfn, &t, &_a, 0, NULL, NULL); + rc = p2m->set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, t, a, -1); } return rc; diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 3ab119cef2..62a3899089 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1234,7 +1234,7 @@ int relinquish_shared_pages(struct domain *d) if ( atomic_read(&d->shr_pages) == 0 ) break; - mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &t, &a, 0, NULL, NULL); if ( mfn_valid(mfn) && (t == p2m_ram_shared) ) { /* Does not fail with ENOMEM given the DESTROY flag */ @@ -1243,7 +1243,7 @@ int relinquish_shared_pages(struct domain *d) /* Clear out the p2m entry so no one else may try to * unshare. Must succeed: we just read the old entry and * we hold the p2m lock. */ - set_rc = p2m->set_entry(p2m, gfn, _mfn(0), PAGE_ORDER_4K, + set_rc = p2m->set_entry(p2m, _gfn(gfn), _mfn(0), PAGE_ORDER_4K, p2m_invalid, p2m_access_rwx, -1); ASSERT(set_rc == 0); count += 0x10; diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 23c0518733..f14d1686b7 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -674,11 +674,12 @@ bool_t ept_handle_misconfig(uint64_t gpa) * Returns: 0 for success, -errno for failure */ static int -ept_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, +ept_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn, unsigned int order, p2m_type_t p2mt, p2m_access_t p2ma, int sve) { ept_entry_t *table, *ept_entry = NULL; + unsigned long gfn = gfn_x(gfn_); unsigned long gfn_remainder = gfn; unsigned int i, target = order / EPT_TABLE_ORDER; unsigned long fn_mask = !mfn_eq(mfn, INVALID_MFN) ? (gfn | mfn_x(mfn)) : gfn; @@ -910,11 +911,12 @@ out: /* Read ept p2m entries */ static mfn_t ept_get_entry(struct p2m_domain *p2m, - unsigned long gfn, p2m_type_t *t, p2m_access_t* a, + gfn_t gfn_, p2m_type_t *t, p2m_access_t* a, p2m_query_t q, unsigned int *page_order, bool_t *sve) { ept_entry_t *table = map_domain_page(_mfn(pagetable_get_pfn(p2m_get_pagetable(p2m)))); + unsigned long gfn = gfn_x(gfn_); unsigned long gfn_remainder = gfn; ept_entry_t *ept_entry; u32 index; diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index eb74e5c01f..c8c8cff014 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -543,7 +543,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) p2m_type_t t; unsigned int cur_order; - p2m->get_entry(p2m, gfn_x(gfn) + i, &t, &a, 0, &cur_order, NULL); + p2m->get_entry(p2m, gfn_add(gfn, i), &t, &a, 0, &cur_order, NULL); n = 1UL << min(order, cur_order); if ( t == p2m_populate_on_demand ) pod += n; @@ -603,7 +603,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) p2m_access_t a; unsigned int cur_order; - mfn = p2m->get_entry(p2m, gfn_x(gfn) + i, &t, &a, 0, &cur_order, NULL); + mfn = p2m->get_entry(p2m, gfn_add(gfn, i), &t, &a, 0, &cur_order, NULL); if ( order < cur_order ) cur_order = order; n = 1UL << cur_order; @@ -717,7 +717,8 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) unsigned long k; const struct page_info *page; - mfn = p2m->get_entry(p2m, gfn + i, &type, &a, 0, &cur_order, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn + i), &type, &a, 0, + &cur_order, NULL); /* * Conditions that must be met for superpage-superpage: @@ -859,7 +860,9 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) for ( i = 0; i < count; i++ ) { p2m_access_t a; - mfns[i] = p2m->get_entry(p2m, gfns[i], types + i, &a, 0, NULL, NULL); + + mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, &a, + 0, NULL, NULL); /* * If this is ram, and not a pagetable or from the xen heap, and * probably not mapped elsewhere, map it; otherwise, skip. @@ -988,7 +991,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) for ( i = p2m->pod.reclaim_single; i > 0 ; i-- ) { p2m_access_t a; - (void)p2m->get_entry(p2m, i, &t, &a, 0, NULL, NULL); + (void)p2m->get_entry(p2m, _gfn(i), &t, &a, 0, NULL, NULL); if ( p2m_is_ram(t) ) { gfns[j] = i; @@ -1237,7 +1240,7 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, p2m_access_t a; unsigned int cur_order; - p2m->get_entry(p2m, gfn + i, &ot, &a, 0, &cur_order, NULL); + p2m->get_entry(p2m, _gfn(gfn + i), &ot, &a, 0, &cur_order, NULL); n = 1UL << min(order, cur_order); if ( p2m_is_ram(ot) ) { diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 0e63d6ed11..4bfec4f5f0 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -479,12 +479,13 @@ int p2m_pt_handle_deferred_changes(uint64_t gpa) /* Returns: 0 for success, -errno for failure */ static int -p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, +p2m_pt_set_entry(struct p2m_domain *p2m, gfn_t gfn_, mfn_t mfn, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma, int sve) { /* XXX -- this might be able to be faster iff current->domain == d */ void *table; + unsigned long gfn = gfn_x(gfn_); unsigned long i, gfn_remainder = gfn; l1_pgentry_t *p2m_entry, entry_content; /* Intermediate table to free if we're replacing it with a superpage. */ @@ -731,11 +732,12 @@ p2m_pt_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, } static mfn_t -p2m_pt_get_entry(struct p2m_domain *p2m, unsigned long gfn, +p2m_pt_get_entry(struct p2m_domain *p2m, gfn_t gfn_, p2m_type_t *t, p2m_access_t *a, p2m_query_t q, unsigned int *page_order, bool_t *sve) { mfn_t mfn; + unsigned long gfn = gfn_x(gfn_); paddr_t addr = ((paddr_t)gfn) << PAGE_SHIFT; l2_pgentry_t *l2e; l1_pgentry_t *l1e; diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 0b479105b9..35d4a15391 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -415,11 +415,12 @@ void p2m_unlock_and_tlb_flush(struct p2m_domain *p2m) mm_write_unlock(&p2m->lock); } -mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn, +mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn_l, p2m_type_t *t, p2m_access_t *a, p2m_query_t q, unsigned int *page_order, bool_t locked) { mfn_t mfn; + gfn_t gfn = _gfn(gfn_l); /* Unshare makes no sense withuot populate. */ if ( q & P2M_UNSHARE ) @@ -430,7 +431,7 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn, /* Not necessarily true, but for non-translated guests, we claim * it's the most generic kind of memory */ *t = p2m_ram_rw; - return _mfn(gfn); + return _mfn(gfn_l); } if ( locked ) @@ -444,8 +445,8 @@ mfn_t __get_gfn_type_access(struct p2m_domain *p2m, unsigned long gfn, ASSERT(p2m_is_hostp2m(p2m)); /* Try to unshare. If we fail, communicate ENOMEM without * sleeping. */ - if ( mem_sharing_unshare_page(p2m->domain, gfn, 0) < 0 ) - (void)mem_sharing_notify_enomem(p2m->domain, gfn, 0); + if ( mem_sharing_unshare_page(p2m->domain, gfn_l, 0) < 0 ) + (void)mem_sharing_notify_enomem(p2m->domain, gfn_l, 0); mfn = p2m->get_entry(p2m, gfn, t, a, q, page_order, NULL); } @@ -556,7 +557,7 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, else order = 0; - set_rc = p2m->set_entry(p2m, gfn, mfn, order, p2mt, p2ma, -1); + set_rc = p2m->set_entry(p2m, _gfn(gfn), mfn, order, p2mt, p2ma, -1); if ( set_rc ) rc = set_rc; @@ -735,7 +736,8 @@ p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned long mfn, { for ( i = 0; i < (1UL << page_order); i++ ) { - mfn_return = p2m->get_entry(p2m, gfn + i, &t, &a, 0, NULL, NULL); + mfn_return = p2m->get_entry(p2m, _gfn(gfn + i), &t, &a, 0, + NULL, NULL); if ( !p2m_is_grant(t) && !p2m_is_shared(t) && !p2m_is_foreign(t) ) set_gpfn_from_mfn(mfn+i, INVALID_M2P_ENTRY); ASSERT( !p2m_is_valid(t) || mfn + i == mfn_x(mfn_return) ); @@ -762,7 +764,8 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t t) { struct p2m_domain *p2m = p2m_get_hostp2m(d); - unsigned long i, ogfn; + unsigned long i; + gfn_t ogfn; p2m_type_t ot; p2m_access_t a; mfn_t omfn; @@ -803,7 +806,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, /* First, remove m->p mappings for existing p->m mappings */ for ( i = 0; i < (1UL << page_order); i++ ) { - omfn = p2m->get_entry(p2m, gfn_x(gfn_add(gfn, i)), &ot, + omfn = p2m->get_entry(p2m, gfn_add(gfn, i), &ot, &a, 0, NULL, NULL); if ( p2m_is_shared(ot) ) { @@ -831,7 +834,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, 0); return rc; } - omfn = p2m->get_entry(p2m, gfn_x(gfn_add(gfn, i)), + omfn = p2m->get_entry(p2m, gfn_add(gfn, i), &ot, &a, 0, NULL, NULL); ASSERT(!p2m_is_shared(ot)); } @@ -873,21 +876,24 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, } if ( page_get_owner(mfn_to_page(mfn_add(mfn, i))) != d ) continue; - ogfn = mfn_to_gfn(d, mfn_add(mfn, i)); - if ( (ogfn != INVALID_M2P_ENTRY) && (ogfn != gfn_x(gfn_add(gfn, i))) ) + ogfn = _gfn(mfn_to_gfn(d, mfn_add(mfn, i))); + if ( !gfn_eq(ogfn, _gfn(INVALID_M2P_ENTRY)) && + !gfn_eq(ogfn, gfn_add(gfn, i)) ) { /* This machine frame is already mapped at another physical * address */ P2M_DEBUG("aliased! mfn=%#lx, old gfn=%#lx, new gfn=%#lx\n", - mfn_x(mfn_add(mfn, i)), ogfn, gfn_x(gfn_add(gfn, i))); + mfn_x(mfn_add(mfn, i)), gfn_x(ogfn), + gfn_x(gfn_add(gfn, i))); omfn = p2m->get_entry(p2m, ogfn, &ot, &a, 0, NULL, NULL); if ( p2m_is_ram(ot) && !p2m_is_paged(ot) ) { ASSERT(mfn_valid(omfn)); P2M_DEBUG("old gfn=%#lx -> mfn %#lx\n", - ogfn , mfn_x(omfn)); + gfn_x(ogfn) , mfn_x(omfn)); if ( mfn_eq(omfn, mfn_add(mfn, i)) ) - p2m_remove_page(p2m, ogfn, mfn_x(mfn_add(mfn, i)), 0); + p2m_remove_page(p2m, gfn_x(ogfn), mfn_x(mfn_add(mfn, i)), + 0); } } } @@ -948,7 +954,7 @@ int p2m_change_type_one(struct domain *d, unsigned long gfn, gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &pt, &a, 0, NULL, NULL); rc = likely(pt == ot) ? p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, nt, p2m->default_access) @@ -1065,14 +1071,15 @@ int p2m_finish_type_change(struct domain *d, * 1 + new order for caller to retry with smaller order (guaranteed * to be smaller than order passed in) */ -static int set_typed_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, - unsigned int order, p2m_type_t gfn_p2mt, - p2m_access_t access) +static int set_typed_p2m_entry(struct domain *d, unsigned long gfn_l, + mfn_t mfn, unsigned int order, + p2m_type_t gfn_p2mt, p2m_access_t access) { int rc = 0; p2m_access_t a; p2m_type_t ot; mfn_t omfn; + gfn_t gfn = _gfn(gfn_l); unsigned int cur_order = 0; struct p2m_domain *p2m = p2m_get_hostp2m(d); @@ -1103,11 +1110,11 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, } } - P2M_DEBUG("set %d %lx %lx\n", gfn_p2mt, gfn, mfn_x(mfn)); - rc = p2m_set_entry(p2m, gfn, mfn, order, gfn_p2mt, access); + P2M_DEBUG("set %d %lx %lx\n", gfn_p2mt, gfn_l, mfn_x(mfn)); + rc = p2m_set_entry(p2m, gfn_l, mfn, order, gfn_p2mt, access); if ( rc ) gdprintk(XENLOG_ERR, "p2m_set_entry: %#lx:%u -> %d (0x%"PRI_mfn")\n", - gfn, order, rc, mfn_x(mfn)); + gfn_l, order, rc, mfn_x(mfn)); else if ( p2m_is_pod(ot) ) { pod_lock(p2m); @@ -1157,7 +1164,7 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn, gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); if ( p2mt == p2m_invalid || p2mt == p2m_mmio_dm ) ret = p2m_set_entry(p2m, gfn, _mfn(gfn), PAGE_ORDER_4K, @@ -1201,7 +1208,7 @@ int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, return -EIO; gfn_lock(p2m, gfn, order); - actual_mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, &cur_order, NULL); + actual_mfn = p2m->get_entry(p2m, _gfn(gfn), &t, &a, 0, &cur_order, NULL); if ( cur_order < order ) { rc = cur_order + 1; @@ -1245,7 +1252,7 @@ int clear_identity_p2m_entry(struct domain *d, unsigned long gfn) gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); if ( p2mt == p2m_mmio_direct && mfn_x(mfn) == gfn ) { ret = p2m_set_entry(p2m, gfn, INVALID_MFN, PAGE_ORDER_4K, @@ -1278,7 +1285,7 @@ int set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) return -EIO; gfn_lock(p2m, gfn, 0); - omfn = p2m->get_entry(p2m, gfn, &ot, &a, 0, NULL, NULL); + omfn = p2m->get_entry(p2m, _gfn(gfn), &ot, &a, 0, NULL, NULL); /* At the moment we only allow p2m change if gfn has already been made * sharable first */ ASSERT(p2m_is_shared(ot)); @@ -1330,7 +1337,7 @@ int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn) gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); /* Check if mfn is valid */ if ( !mfn_valid(mfn) ) @@ -1392,7 +1399,7 @@ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn) gfn_lock(p2m, gfn, 0); /* Get mfn */ - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); if ( unlikely(!mfn_valid(mfn)) ) goto out; @@ -1524,7 +1531,7 @@ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) /* Fix p2m mapping */ gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); /* Allow only nominated or evicted pages to enter page-in path */ if ( p2mt == p2m_ram_paging_out || p2mt == p2m_ram_paged ) { @@ -1586,7 +1593,7 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer) gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); ret = -ENOENT; /* Allow missing pages */ @@ -1674,7 +1681,7 @@ void p2m_mem_paging_resume(struct domain *d, vm_event_response_t *rsp) unsigned long gfn = rsp->u.mem_access.gfn; gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); /* * Allow only pages which were prepared properly, or pages which * were nominated but not evicted. @@ -2263,7 +2270,7 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, p2m_lock(hp2m); p2m_lock(ap2m); - mfn = ap2m->get_entry(ap2m, gfn_x(old_gfn), &t, &a, 0, NULL, NULL); + mfn = ap2m->get_entry(ap2m, old_gfn, &t, &a, 0, NULL, NULL); if ( gfn_eq(new_gfn, INVALID_GFN) ) { @@ -2292,21 +2299,21 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx, gfn = _gfn(gfn_x(old_gfn) & mask); mfn = _mfn(mfn_x(mfn) & mask); - if ( ap2m->set_entry(ap2m, gfn_x(gfn), mfn, page_order, t, a, 1) ) + if ( ap2m->set_entry(ap2m, gfn, mfn, page_order, t, a, 1) ) goto out; } } - mfn = ap2m->get_entry(ap2m, gfn_x(new_gfn), &t, &a, 0, NULL, NULL); + mfn = ap2m->get_entry(ap2m, new_gfn, &t, &a, 0, NULL, NULL); if ( !mfn_valid(mfn) ) - mfn = hp2m->get_entry(hp2m, gfn_x(new_gfn), &t, &a, 0, NULL, NULL); + mfn = hp2m->get_entry(hp2m, new_gfn, &t, &a, 0, NULL, NULL); /* Note: currently it is not safe to remap to a shared entry */ if ( !mfn_valid(mfn) || (t != p2m_ram_rw) ) goto out; - if ( !ap2m->set_entry(ap2m, gfn_x(old_gfn), mfn, PAGE_ORDER_4K, t, a, + if ( !ap2m->set_entry(ap2m, old_gfn, mfn, PAGE_ORDER_4K, t, a, (current->domain != d)) ) { rc = 0; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 8f3409b400..1c9a51e9ad 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -234,13 +234,13 @@ struct p2m_domain { struct page_list_head pages; int (*set_entry)(struct p2m_domain *p2m, - unsigned long gfn, + gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma, int sve); mfn_t (*get_entry)(struct p2m_domain *p2m, - unsigned long gfn, + gfn_t gfn, p2m_type_t *p2mt, p2m_access_t *p2ma, p2m_query_t q, From patchwork Mon Oct 2 12:59:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114611 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp654109qgn; Mon, 2 Oct 2017 06:02:20 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDi3VXqUmJDCUDEhBrcfTzmXAG1g0v5tCzXwvCgpURgrJrhoS9PE4NiMJ3jgKgrFQJw8Oxf X-Received: by 10.36.71.208 with SMTP id t199mr11174838itb.59.1506949340338; Mon, 02 Oct 2017 06:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949340; cv=none; d=google.com; s=arc-20160816; b=cEZXZz1Y1mvOxfWIxXgYVnPyed170gROa293NRjPHotZYoODsxVyn6HW0iaocgLIKK lsKR4zu82luYdZOONlqgMlhHmcy/3ELGTZYC00PoHO/bN7zWMzohkkhKJ0RqgHzqJ6S9 mDDxwFkd+qP1ab03yPr4SDiF+eCUmEJeemUzeBNZfEJZrsUuqidAxFJdadk/MLl/nPfS nJRgtaaaFIESRnD6E/HHMOj1zlBXe6zx+CQaIySQ8Y0URIxSJxyxs41aAp29+C0+5tbt KZWYmzsTIHqiOAKgF3AW0CzoiJXL5CFPqWNZCxdyo0SVs7Fbv6RiB4wzsHdF4nEO77AU 60ow== 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:arc-authentication-results; bh=ZTTgFrO0SOXsbs09vElLO95RytAREoJVMS4xGYXiygo=; b=A29N1p0LmEbVcnE1N3ph3eZI1AsYY+SsLeP2cdt8qyUWmJvCAfsanMkdnOCwdfeMAm FT4plcsgLg3nZyLqvXsY8V1qlDfB/qyk1+pVQ2r4PtavMJT7D/r0mlw6SaZYxzm5JEQz rzmGEg75FvSm+RFEkA1x7YoOPE7IwKKA7BKwFh8zlcOhfbyWiqJB7tnBaJWVIbbtN4Tj 8Gue3qRlZtL6pcTKb20zQBSZ7JjMUYfOCy4LBk5MX19egKvsIPtTAazb9nSAIhDvnaTR KSjLPt7doHRq25QHT0UBv7vPYJvnoS05zK8E94/jdu1FETTfP8jFqHWhtKF0S2aPGbOQ L2eg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c14si8244447itb.19.2017.10.02.06.02.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:20 -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 1dz0KQ-0004Ej-8n; Mon, 02 Oct 2017 13:00:10 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KP-0004D5-0K for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:09 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 60/56-02225-85832D95; Mon, 02 Oct 2017 13:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFLMWRWlGSWpSXmKPExsVysyfVTTfY4lK kQfM2IYslHxezODB6HN39mymAMYo1My8pvyKBNWPC0mNMBf03GCu2/+5iaWBcOZ+xi5GLQ0hg M6PE48lv2bsYOYGc04wS889og9hsApoSdz5/YgKxRQSkJa59vgzWwAxS039hL1iDsICnxIz/e 9hAbBYBVYm1E9exgNi8AlYSh5cvYgaxJQTkJXa1XWQFsTmB4u+Pf2SFWGYpcbx7EtMERu4FjA yrGNWLU4vKUot0zfWSijLTM0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQJ9zAAEOxgbvzs dYpTkYFIS5WU2vBQpxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXwxwoJ1iUmp5akZaZAww2mLQE B4+SCK8pSJq3uCAxtzgzHSJ1itGY48ekK3+YODpu3v3DJMSSl5+XKiXO+98MqFQApDSjNA9uE CwKLjHKSgnzMgKdJsRTkFqUm1mCKv+KUZyDUUmY1wVkIU9mXgncvldApzABnTKn6wLIKSWJCC mpBsaCwD1zd2+u1b01qeSH9zfXzQ3lJ3OOHN3Qkuqk9ufarmtny73CFGaGJM7ub0gLX/J3qcA suwXMuce2+bjflPqePd8lP7TQZ+sk36Yki9fNZwx90uXP+6XWL9w1Q+vszekn9oWG8q56Nlt3 oeYs6/sGC1wDkzOP+e1avLOd+/FE2dPyq4VuzPyuxFKckWioxVxUnAgADnYTBH0CAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1506949202!109946457!1 X-Originating-IP: [217.140.101.70] 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 21447 invoked from network); 2 Oct 2017 13:00:02 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 2 Oct 2017 13:00:02 -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 1669415BF; Mon, 2 Oct 2017 06:00:02 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D6F2C3F53D; Mon, 2 Oct 2017 06:00:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:35 +0100 Message-Id: <20171002125941.11274-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Tamas K Lengyel , Jan Beulich Subject: [Xen-devel] [PATCH v3 09/15] xen/x86: p2m: Use typesafe GFN in p2m_set_entry 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Acked-by: Tamas K Lengyel Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Tamas K Lengyel Changes in v3: - Add Wei's reviewed-by Changes in v2: - Add Andrew & Tamas' acked-by - Rename the variable gfn_t to gfn_ to avoid shadowing the type gfn_t --- xen/arch/x86/mm/hap/nested_hap.c | 2 +- xen/arch/x86/mm/mem_sharing.c | 3 +- xen/arch/x86/mm/p2m-pod.c | 36 +++++++------ xen/arch/x86/mm/p2m.c | 112 ++++++++++++++++++++++----------------- xen/include/asm-x86/p2m.h | 2 +- 5 files changed, 85 insertions(+), 70 deletions(-) diff --git a/xen/arch/x86/mm/hap/nested_hap.c b/xen/arch/x86/mm/hap/nested_hap.c index 162afed46b..346fcb53e5 100644 --- a/xen/arch/x86/mm/hap/nested_hap.c +++ b/xen/arch/x86/mm/hap/nested_hap.c @@ -121,7 +121,7 @@ nestedhap_fix_p2m(struct vcpu *v, struct p2m_domain *p2m, gfn = (L2_gpa >> PAGE_SHIFT) & mask; mfn = _mfn((L0_gpa >> PAGE_SHIFT) & mask); - rc = p2m_set_entry(p2m, gfn, mfn, page_order, p2mt, p2ma); + rc = p2m_set_entry(p2m, _gfn(gfn), mfn, page_order, p2mt, p2ma); } p2m_unlock(p2m); diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 62a3899089..b856028c02 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -1052,7 +1052,8 @@ int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_handle goto err_unlock; } - ret = p2m_set_entry(p2m, cgfn, smfn, PAGE_ORDER_4K, p2m_ram_shared, a); + ret = p2m_set_entry(p2m, _gfn(cgfn), smfn, PAGE_ORDER_4K, + p2m_ram_shared, a); /* Tempted to turn this into an assert */ if ( ret ) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index c8c8cff014..b8a51cf12a 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -565,7 +565,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) * All PoD: Mark the whole region invalid and tell caller * we're done. */ - p2m_set_entry(p2m, gfn_x(gfn), INVALID_MFN, order, p2m_invalid, + p2m_set_entry(p2m, gfn, INVALID_MFN, order, p2m_invalid, p2m->default_access); p2m->pod.entry_count -= 1UL << order; BUG_ON(p2m->pod.entry_count < 0); @@ -609,7 +609,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) n = 1UL << cur_order; if ( t == p2m_populate_on_demand ) { - p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order, + p2m_set_entry(p2m, gfn_add(gfn, i), INVALID_MFN, cur_order, p2m_invalid, p2m->default_access); p2m->pod.entry_count -= n; BUG_ON(p2m->pod.entry_count < 0); @@ -631,7 +631,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) page = mfn_to_page(mfn); - p2m_set_entry(p2m, gfn_x(gfn) + i, INVALID_MFN, cur_order, + p2m_set_entry(p2m, gfn_add(gfn, i), INVALID_MFN, cur_order, p2m_invalid, p2m->default_access); p2m_tlb_flush_sync(p2m); for ( j = 0; j < n; ++j ) @@ -680,9 +680,10 @@ void p2m_pod_dump_data(struct domain *d) * in the p2m. */ static int -p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) +p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn_l) { mfn_t mfn, mfn0 = INVALID_MFN; + gfn_t gfn = _gfn(gfn_l); p2m_type_t type, type0 = 0; unsigned long * map = NULL; int ret=0, reset = 0; @@ -693,7 +694,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) ASSERT(pod_locked_by_me(p2m)); - if ( !superpage_aligned(gfn) ) + if ( !superpage_aligned(gfn_l) ) goto out; /* Allow an extra refcount for one shadow pt mapping in shadowed domains */ @@ -717,7 +718,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) unsigned long k; const struct page_info *page; - mfn = p2m->get_entry(p2m, _gfn(gfn + i), &type, &a, 0, + mfn = p2m->get_entry(p2m, gfn_add(gfn, i), &type, &a, 0, &cur_order, NULL); /* @@ -815,7 +816,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn) int d:16,order:16; } t; - t.gfn = gfn; + t.gfn = gfn_l; t.mfn = mfn_x(mfn); t.d = d->domain_id; t.order = 9; @@ -898,7 +899,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) } /* Try to remove the page, restoring old mapping if it fails. */ - p2m_set_entry(p2m, gfns[i], INVALID_MFN, PAGE_ORDER_4K, + p2m_set_entry(p2m, _gfn(gfns[i]), INVALID_MFN, PAGE_ORDER_4K, p2m_populate_on_demand, p2m->default_access); /* @@ -910,7 +911,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) unmap_domain_page(map[i]); map[i] = NULL; - p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K, + p2m_set_entry(p2m, _gfn(gfns[i]), mfns[i], PAGE_ORDER_4K, types[i], p2m->default_access); continue; @@ -937,7 +938,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) */ if ( j < (PAGE_SIZE / sizeof(*map[i])) ) { - p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K, + p2m_set_entry(p2m, _gfn(gfns[i]), mfns[i], PAGE_ORDER_4K, types[i], p2m->default_access); } else @@ -1080,7 +1081,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, { struct domain *d = p2m->domain; struct page_info *p = NULL; /* Compiler warnings */ - unsigned long gfn_aligned = (gfn >> order) << order; + gfn_t gfn_aligned = _gfn((gfn >> order) << order); mfn_t mfn; unsigned long i; @@ -1152,14 +1153,14 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, for( i = 0; i < (1UL << order); i++ ) { - set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_aligned + i); + set_gpfn_from_mfn(mfn_x(mfn) + i, gfn_x(gfn_aligned) + i); paging_mark_dirty(d, mfn_add(mfn, i)); } p2m->pod.entry_count -= (1UL << order); BUG_ON(p2m->pod.entry_count < 0); - pod_eager_record(p2m, gfn_aligned, order); + pod_eager_record(p2m, gfn_x(gfn_aligned), order); if ( tb_init_done ) { @@ -1199,7 +1200,7 @@ remap_and_retry: * need promoting the gfn lock from gfn->2M superpage. */ for ( i = 0; i < (1UL << order); i++ ) - p2m_set_entry(p2m, gfn_aligned + i, INVALID_MFN, PAGE_ORDER_4K, + p2m_set_entry(p2m, gfn_add(gfn_aligned, i), INVALID_MFN, PAGE_ORDER_4K, p2m_populate_on_demand, p2m->default_access); if ( tb_init_done ) { @@ -1219,10 +1220,11 @@ remap_and_retry: int -guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, +guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn_l, unsigned int order) { struct p2m_domain *p2m = p2m_get_hostp2m(d); + gfn_t gfn = _gfn(gfn_l); unsigned long i, n, pod_count = 0; int rc = 0; @@ -1231,7 +1233,7 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, gfn_lock(p2m, gfn, order); - P2M_DEBUG("mark pod gfn=%#lx\n", gfn); + P2M_DEBUG("mark pod gfn=%#lx\n", gfn_l); /* Make sure all gpfns are unused */ for ( i = 0; i < (1UL << order); i += n ) @@ -1240,7 +1242,7 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn, p2m_access_t a; unsigned int cur_order; - p2m->get_entry(p2m, _gfn(gfn + i), &ot, &a, 0, &cur_order, NULL); + p2m->get_entry(p2m, gfn_add(gfn, i), &ot, &a, 0, &cur_order, NULL); n = 1UL << min(order, cur_order); if ( p2m_is_ram(ot) ) { diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c index 35d4a15391..3fbc537da6 100644 --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -532,7 +532,7 @@ struct page_info *p2m_get_page_from_gfn( } /* Returns: 0 for success, -errno for failure */ -int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, +int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma) { struct domain *d = p2m->domain; @@ -546,8 +546,9 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, { if ( hap_enabled(d) ) { - unsigned long fn_mask = !mfn_eq(mfn, INVALID_MFN) ? - (gfn | mfn_x(mfn) | todo) : (gfn | todo); + unsigned long fn_mask = !mfn_eq(mfn, INVALID_MFN) ? mfn_x(mfn) : 0; + + fn_mask |= gfn_x(gfn) | todo; order = (!(fn_mask & ((1ul << PAGE_ORDER_1G) - 1)) && hap_has_1gb) ? PAGE_ORDER_1G : @@ -557,11 +558,11 @@ int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, else order = 0; - set_rc = p2m->set_entry(p2m, _gfn(gfn), mfn, order, p2mt, p2ma, -1); + set_rc = p2m->set_entry(p2m, gfn, mfn, order, p2mt, p2ma, -1); if ( set_rc ) rc = set_rc; - gfn += 1ul << order; + gfn = gfn_add(gfn, 1ul << order); if ( !mfn_eq(mfn, INVALID_MFN) ) mfn = mfn_add(mfn, 1ul << order); todo -= 1ul << order; @@ -652,7 +653,7 @@ int p2m_alloc_table(struct p2m_domain *p2m) /* Initialise physmap tables for slot zero. Other code assumes this. */ p2m->defer_nested_flush = 1; - rc = p2m_set_entry(p2m, 0, INVALID_MFN, PAGE_ORDER_4K, + rc = p2m_set_entry(p2m, _gfn(0), INVALID_MFN, PAGE_ORDER_4K, p2m_invalid, p2m->default_access); p2m->defer_nested_flush = 0; p2m_unlock(p2m); @@ -703,10 +704,11 @@ void p2m_final_teardown(struct domain *d) static int -p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned long mfn, +p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn_l, unsigned long mfn, unsigned int page_order) { unsigned long i; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn_return; p2m_type_t t; p2m_access_t a; @@ -730,13 +732,13 @@ p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned long mfn, } ASSERT(gfn_locked_by_me(p2m, gfn)); - P2M_DEBUG("removing gfn=%#lx mfn=%#lx\n", gfn, mfn); + P2M_DEBUG("removing gfn=%#lx mfn=%#lx\n", gfn_l, mfn); if ( mfn_valid(_mfn(mfn)) ) { for ( i = 0; i < (1UL << page_order); i++ ) { - mfn_return = p2m->get_entry(p2m, _gfn(gfn + i), &t, &a, 0, + mfn_return = p2m->get_entry(p2m, gfn_add(gfn, i), &t, &a, 0, NULL, NULL); if ( !p2m_is_grant(t) && !p2m_is_shared(t) && !p2m_is_foreign(t) ) set_gpfn_from_mfn(mfn+i, INVALID_M2P_ENTRY); @@ -901,7 +903,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, /* Now, actually do the two-way mapping */ if ( mfn_valid(mfn) ) { - rc = p2m_set_entry(p2m, gfn_x(gfn), mfn, page_order, t, + rc = p2m_set_entry(p2m, gfn, mfn, page_order, t, p2m->default_access); if ( rc ) goto out; /* Failed to update p2m, bail without updating m2p. */ @@ -917,7 +919,7 @@ guest_physmap_add_entry(struct domain *d, gfn_t gfn, mfn_t mfn, { gdprintk(XENLOG_WARNING, "Adding bad mfn to p2m map (%#lx -> %#lx)\n", gfn_x(gfn), mfn_x(mfn)); - rc = p2m_set_entry(p2m, gfn_x(gfn), INVALID_MFN, page_order, + rc = p2m_set_entry(p2m, gfn, INVALID_MFN, page_order, p2m_invalid, p2m->default_access); if ( rc == 0 ) { @@ -940,11 +942,12 @@ out: * Returns: 0 for success, -errno for failure. * Resets the access permissions. */ -int p2m_change_type_one(struct domain *d, unsigned long gfn, +int p2m_change_type_one(struct domain *d, unsigned long gfn_l, p2m_type_t ot, p2m_type_t nt) { p2m_access_t a; p2m_type_t pt; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int rc; @@ -954,7 +957,7 @@ int p2m_change_type_one(struct domain *d, unsigned long gfn, gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &pt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &pt, &a, 0, NULL, NULL); rc = likely(pt == ot) ? p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, nt, p2m->default_access) @@ -1111,7 +1114,7 @@ static int set_typed_p2m_entry(struct domain *d, unsigned long gfn_l, } P2M_DEBUG("set %d %lx %lx\n", gfn_p2mt, gfn_l, mfn_x(mfn)); - rc = p2m_set_entry(p2m, gfn_l, mfn, order, gfn_p2mt, access); + rc = p2m_set_entry(p2m, gfn, mfn, order, gfn_p2mt, access); if ( rc ) gdprintk(XENLOG_ERR, "p2m_set_entry: %#lx:%u -> %d (0x%"PRI_mfn")\n", gfn_l, order, rc, mfn_x(mfn)); @@ -1146,11 +1149,12 @@ int set_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, return set_typed_p2m_entry(d, gfn, mfn, order, p2m_mmio_direct, access); } -int set_identity_p2m_entry(struct domain *d, unsigned long gfn, +int set_identity_p2m_entry(struct domain *d, unsigned long gfn_l, p2m_access_t p2ma, unsigned int flag) { p2m_type_t p2mt; p2m_access_t a; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret; @@ -1159,17 +1163,17 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn, { if ( !need_iommu(d) ) return 0; - return iommu_map_page(d, gfn, gfn, IOMMUF_readable|IOMMUF_writable); + return iommu_map_page(d, gfn_l, gfn_l, IOMMUF_readable|IOMMUF_writable); } gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); if ( p2mt == p2m_invalid || p2mt == p2m_mmio_dm ) - ret = p2m_set_entry(p2m, gfn, _mfn(gfn), PAGE_ORDER_4K, + ret = p2m_set_entry(p2m, gfn, _mfn(gfn_l), PAGE_ORDER_4K, p2m_mmio_direct, p2ma); - else if ( mfn_x(mfn) == gfn && p2mt == p2m_mmio_direct && a == p2ma ) + else if ( mfn_x(mfn) == gfn_l && p2mt == p2m_mmio_direct && a == p2ma ) ret = 0; else { @@ -1180,7 +1184,7 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn, printk(XENLOG_G_WARNING "Cannot setup identity map d%d:%lx," " gfn already mapped to %lx.\n", - d->domain_id, gfn, mfn_x(mfn)); + d->domain_id, gfn_l, mfn_x(mfn)); } gfn_unlock(p2m, gfn, 0); @@ -1194,10 +1198,11 @@ int set_identity_p2m_entry(struct domain *d, unsigned long gfn, * order+1 for caller to retry with order (guaranteed smaller than * the order value passed in) */ -int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, +int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn_l, mfn_t mfn, unsigned int order) { int rc = -EINVAL; + gfn_t gfn = _gfn(gfn_l); mfn_t actual_mfn; p2m_access_t a; p2m_type_t t; @@ -1208,7 +1213,7 @@ int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, return -EIO; gfn_lock(p2m, gfn, order); - actual_mfn = p2m->get_entry(p2m, _gfn(gfn), &t, &a, 0, &cur_order, NULL); + actual_mfn = p2m->get_entry(p2m, gfn, &t, &a, 0, &cur_order, NULL); if ( cur_order < order ) { rc = cur_order + 1; @@ -1219,13 +1224,13 @@ int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, if ( mfn_eq(actual_mfn, INVALID_MFN) || (t != p2m_mmio_direct) ) { gdprintk(XENLOG_ERR, - "gfn_to_mfn failed! gfn=%08lx type:%d\n", gfn, t); + "gfn_to_mfn failed! gfn=%08lx type:%d\n", gfn_l, t); goto out; } if ( mfn_x(mfn) != mfn_x(actual_mfn) ) gdprintk(XENLOG_WARNING, "no mapping between mfn %08lx and gfn %08lx\n", - mfn_x(mfn), gfn); + mfn_x(mfn), gfn_l); rc = p2m_set_entry(p2m, gfn, INVALID_MFN, order, p2m_invalid, p2m->default_access); @@ -1235,10 +1240,11 @@ int clear_mmio_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn, return rc; } -int clear_identity_p2m_entry(struct domain *d, unsigned long gfn) +int clear_identity_p2m_entry(struct domain *d, unsigned long gfn_l) { p2m_type_t p2mt; p2m_access_t a; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret; @@ -1247,13 +1253,13 @@ int clear_identity_p2m_entry(struct domain *d, unsigned long gfn) { if ( !need_iommu(d) ) return 0; - return iommu_unmap_page(d, gfn); + return iommu_unmap_page(d, gfn_l); } gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); - if ( p2mt == p2m_mmio_direct && mfn_x(mfn) == gfn ) + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); + if ( p2mt == p2m_mmio_direct && mfn_x(mfn) == gfn_l ) { ret = p2m_set_entry(p2m, gfn, INVALID_MFN, PAGE_ORDER_4K, p2m_invalid, p2m->default_access); @@ -1264,7 +1270,7 @@ int clear_identity_p2m_entry(struct domain *d, unsigned long gfn) gfn_unlock(p2m, gfn, 0); printk(XENLOG_G_WARNING "non-identity map d%d:%lx not cleared (mapped to %lx)\n", - d->domain_id, gfn, mfn_x(mfn)); + d->domain_id, gfn_l, mfn_x(mfn)); ret = 0; } @@ -1272,10 +1278,11 @@ int clear_identity_p2m_entry(struct domain *d, unsigned long gfn) } /* Returns: 0 for success, -errno for failure */ -int set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) +int set_shared_p2m_entry(struct domain *d, unsigned long gfn_l, mfn_t mfn) { struct p2m_domain *p2m = p2m_get_hostp2m(d); int rc = 0; + gfn_t gfn = _gfn(gfn_l); p2m_access_t a; p2m_type_t ot; mfn_t omfn; @@ -1285,7 +1292,7 @@ int set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) return -EIO; gfn_lock(p2m, gfn, 0); - omfn = p2m->get_entry(p2m, _gfn(gfn), &ot, &a, 0, NULL, NULL); + omfn = p2m->get_entry(p2m, gfn, &ot, &a, 0, NULL, NULL); /* At the moment we only allow p2m change if gfn has already been made * sharable first */ ASSERT(p2m_is_shared(ot)); @@ -1297,14 +1304,14 @@ int set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) || (pg_type & PGT_type_mask) != PGT_shared_page ) set_gpfn_from_mfn(mfn_x(omfn), INVALID_M2P_ENTRY); - P2M_DEBUG("set shared %lx %lx\n", gfn, mfn_x(mfn)); + P2M_DEBUG("set shared %lx %lx\n", gfn_l, mfn_x(mfn)); rc = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_shared, p2m->default_access); gfn_unlock(p2m, gfn, 0); if ( rc ) gdprintk(XENLOG_ERR, "p2m_set_entry failed! mfn=%08lx rc:%d\n", - mfn_x(get_gfn_query_unlocked(p2m->domain, gfn, &ot)), rc); + mfn_x(get_gfn_query_unlocked(p2m->domain, gfn_l, &ot)), rc); return rc; } @@ -1326,18 +1333,19 @@ int set_shared_p2m_entry(struct domain *d, unsigned long gfn, mfn_t mfn) * Once the p2mt is changed the page is readonly for the guest. On success the * pager can write the page contents to disk and later evict the page. */ -int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn) +int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn_l) { struct page_info *page; struct p2m_domain *p2m = p2m_get_hostp2m(d); p2m_type_t p2mt; p2m_access_t a; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; int ret = -EBUSY; gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); /* Check if mfn is valid */ if ( !mfn_valid(mfn) ) @@ -1387,11 +1395,12 @@ int p2m_mem_paging_nominate(struct domain *d, unsigned long gfn) * could evict it, eviction can not be done either. In this case the gfn is * still backed by a mfn. */ -int p2m_mem_paging_evict(struct domain *d, unsigned long gfn) +int p2m_mem_paging_evict(struct domain *d, unsigned long gfn_l) { struct page_info *page; p2m_type_t p2mt; p2m_access_t a; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret = -EBUSY; @@ -1399,7 +1408,7 @@ int p2m_mem_paging_evict(struct domain *d, unsigned long gfn) gfn_lock(p2m, gfn, 0); /* Get mfn */ - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); if ( unlikely(!mfn_valid(mfn)) ) goto out; @@ -1502,15 +1511,16 @@ void p2m_mem_paging_drop_page(struct domain *d, unsigned long gfn, * already sent to the pager. In this case the caller has to try again until the * gfn is fully paged in again. */ -void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) +void p2m_mem_paging_populate(struct domain *d, unsigned long gfn_l) { struct vcpu *v = current; vm_event_request_t req = { .reason = VM_EVENT_REASON_MEM_PAGING, - .u.mem_paging.gfn = gfn + .u.mem_paging.gfn = gfn_l }; p2m_type_t p2mt; p2m_access_t a; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); @@ -1519,7 +1529,7 @@ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) if ( rc == -ENOSYS ) { gdprintk(XENLOG_ERR, "Domain %hu paging gfn %lx yet no ring " - "in place\n", d->domain_id, gfn); + "in place\n", d->domain_id, gfn_l); /* Prevent the vcpu from faulting repeatedly on the same gfn */ if ( v->domain == d ) vcpu_pause_nosync(v); @@ -1531,7 +1541,7 @@ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) /* Fix p2m mapping */ gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); /* Allow only nominated or evicted pages to enter page-in path */ if ( p2mt == p2m_ram_paging_out || p2mt == p2m_ram_paged ) { @@ -1575,11 +1585,12 @@ void p2m_mem_paging_populate(struct domain *d, unsigned long gfn) * mfn if populate was called for gfn which was nominated but not evicted. In * this case only the p2mt needs to be forwarded. */ -int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer) +int p2m_mem_paging_prep(struct domain *d, unsigned long gfn_l, uint64_t buffer) { struct page_info *page; p2m_type_t p2mt; p2m_access_t a; + gfn_t gfn = _gfn(gfn_l); mfn_t mfn; struct p2m_domain *p2m = p2m_get_hostp2m(d); int ret, page_extant = 1; @@ -1593,7 +1604,7 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer) gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); ret = -ENOENT; /* Allow missing pages */ @@ -1629,7 +1640,7 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer) if ( rc ) { gdprintk(XENLOG_ERR, "Failed to load paging-in gfn %lx domain %u " - "bytes left %d\n", gfn, d->domain_id, rc); + "bytes left %d\n", gfn_l, d->domain_id, rc); ret = -EFAULT; put_page(page); /* Don't leak pages */ goto out; @@ -1642,7 +1653,7 @@ int p2m_mem_paging_prep(struct domain *d, unsigned long gfn, uint64_t buffer) ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, paging_mode_log_dirty(d) ? p2m_ram_logdirty : p2m_ram_rw, a); - set_gpfn_from_mfn(mfn_x(mfn), gfn); + set_gpfn_from_mfn(mfn_x(mfn), gfn_l); if ( !page_extant ) atomic_dec(&d->paged_pages); @@ -1678,10 +1689,10 @@ void p2m_mem_paging_resume(struct domain *d, vm_event_response_t *rsp) /* Fix p2m entry if the page was not dropped */ if ( !(rsp->u.mem_paging.flags & MEM_PAGING_DROP_PAGE) ) { - unsigned long gfn = rsp->u.mem_access.gfn; + gfn_t gfn = _gfn(rsp->u.mem_access.gfn); gfn_lock(p2m, gfn, 0); - mfn = p2m->get_entry(p2m, _gfn(gfn), &p2mt, &a, 0, NULL, NULL); + mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, 0, NULL, NULL); /* * Allow only pages which were prepared properly, or pages which * were nominated but not evicted. @@ -1691,7 +1702,7 @@ void p2m_mem_paging_resume(struct domain *d, vm_event_response_t *rsp) p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, paging_mode_log_dirty(d) ? p2m_ram_logdirty : p2m_ram_rw, a); - set_gpfn_from_mfn(mfn_x(mfn), gfn); + set_gpfn_from_mfn(mfn_x(mfn), gfn_x(gfn)); } gfn_unlock(p2m, gfn, 0); } @@ -2109,8 +2120,9 @@ bool_t p2m_altp2m_lazy_copy(struct vcpu *v, paddr_t gpa, */ mask = ~((1UL << page_order) - 1); mfn = _mfn(mfn_x(mfn) & mask); + gfn = _gfn(gfn_x(gfn) & mask); - rv = p2m_set_entry(*ap2m, gfn_x(gfn) & mask, mfn, page_order, p2mt, p2ma); + rv = p2m_set_entry(*ap2m, gfn, mfn, page_order, p2mt, p2ma); p2m_unlock(*ap2m); if ( rv ) @@ -2396,7 +2408,7 @@ void p2m_altp2m_propagate_change(struct domain *d, gfn_t gfn, } } else if ( !mfn_eq(m, INVALID_MFN) ) - p2m_set_entry(p2m, gfn_x(gfn), mfn, page_order, p2mt, p2ma); + p2m_set_entry(p2m, gfn, mfn, page_order, p2mt, p2ma); __put_gfn(p2m, gfn_x(gfn)); } diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 1c9a51e9ad..07ca02a173 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -682,7 +682,7 @@ void p2m_free_ptp(struct p2m_domain *p2m, struct page_info *pg); /* Directly set a p2m entry: only for use by p2m code. Does not need * a call to put_gfn afterwards/ */ -int p2m_set_entry(struct p2m_domain *p2m, unsigned long gfn, mfn_t mfn, +int p2m_set_entry(struct p2m_domain *p2m, gfn_t gfn, mfn_t mfn, unsigned int page_order, p2m_type_t p2mt, p2m_access_t p2ma); /* Set up function pointers for PT implementation: only for use by p2m code */ From patchwork Mon Oct 2 12:59:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114608 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653905qgn; Mon, 2 Oct 2017 06:02:11 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDea78kf9jBhrXdxzCIgPtGNKwGnFYXDt4W1zmk6HZCymL4OToq02JAxc/0xCR16cmCUfSh X-Received: by 10.36.82.145 with SMTP id d139mr19223257itb.86.1506949331491; Mon, 02 Oct 2017 06:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949331; cv=none; d=google.com; s=arc-20160816; b=o8A4cbkyddX0Y7qJMm67cUICeGJiDY6CfeCf9Lb6TCXlT60OUlRgC3y7cO5X92btst Va6mCNh8AerjUnNCljkk8rB/hdDR8089wOEW5yS/mGswLQBlPfHZgS+oxwto27riQxT+ +R/NYyQA+KzlZLYdwFuuld362lAgBxHSxdwL03H5L/jI+ImebhtqmLsS91IYIv0TUlQS X0tXpYlmLGK79lMzfi2vqF0F0k1sVYEtUCcq3a8v4PODjxzTjTe5s4Ibgnh6POkEZAxe vVDEc2cU6REtZqXXfCYQQU7d/IIQnyCvoda1rbMwYMm0srOVNanVrt1BiQxX1aOOICBl RSlA== 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:arc-authentication-results; bh=gW3ZSWs9cgXQnq+hszEs9NseU/7DXrSzFCQ5cGx+C0w=; b=qSGNT6G02y0hRo8TeaIEAHl0l+4hAGyV+Qrhf7E591KYfqJEd++iL/CpDODiNMV32Z fQCHz5Q0JyKId7SJR+fM89IBNr0ZTbHXnmO+SWNjFme+r+woxjjodFt9uz0jQwBbUHJj IC8eZxdQFiaOsS/rBwSGVn3FHuQCavL/Vg6euy04r6gJVW7w9+J+wIvyMrUrB5kOtiK3 Z1wu8I+VIPIgeffXE1Mxm18VyREfMu35/pkKHRUbAFCU4AlhdPqZNIA06WmzLAdUwZYn 4Fg6ZdHHnJdKU4EKGBrEeIVgikFWrTv6tiQh8W0XzxYSnb4Ki9kC2tSIXVPRqr/f2Db2 xh5Q== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id u127si8632205itg.154.2017.10.02.06.02.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:11 -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 1dz0KP-0004DN-1D; Mon, 02 Oct 2017 13:00:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KN-0004Bg-Gc for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:07 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 1D/E9-02224-65832D95; Mon, 02 Oct 2017 13:00:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTTfE4lK kwZaznBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8apLwuZCjbyVvw+3szUwHiVq4uRk0NIYDOj xMdTqV2MXED2aUaJe30T2EASbAKaEnc+f2ICsUUEpCWufb7MCFLELLCYUeLz/l5mkISwQIDE5 +e/wIpYBFQlWnYuAovzClhJTFy0gB3ElhCQl9jVdpEVxOYEir8//pEVYrOlxPHuSUwTGLkXMD KsYlQvTi0qSy3SNdJLKspMzyjJTczM0TU0MNbLTS0uTkxPzUlMKtZLzs/dxAj0bz0DA+MOxlP NzocYJTmYlER5mQ0vRQrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4E0xB8oJFqWmp1akZeYAAw0m LcHBoyTCawqS5i0uSMwtzkyHSJ1i1OXouHn3D5MQS15+XqqUOO9/M6AiAZCijNI8uBGwoL/EK CslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZjXBWQVT2ZeCdymV0BHMAEdMafrAsgRJYkIKakGRk +5W65ygm0f1wXP4Nv0LSk6PZSztHpTmeZ3/awjxStT2uWU4jct+N9ZOOnOB6tIm46nFhcmbpf aFuTemHIpxP9Q3ePHys0bFtQkTVv2Pyam/rZfEG/ZTtezX75odF2XfST/bO+5z5+2Kk3Ofzhl 1XlRHbOn/NZ8S860+B1+KCee9euaGdMWMyWW4oxEQy3mouJEAD6bVmV1AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1506949203!109946467!1 X-Originating-IP: [217.140.101.70] 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 22028 invoked from network); 2 Oct 2017 13:00:03 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 2 Oct 2017 13:00:03 -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 6444D165D; Mon, 2 Oct 2017 06:00:03 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 552263F53D; Mon, 2 Oct 2017 06:00:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:36 +0100 Message-Id: <20171002125941.11274-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 10/15] xen/x86: p2m-pod: Use typesafe GFN in pod_eager_record 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index b8a51cf12a..176d06cb42 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1062,15 +1062,15 @@ static void pod_eager_reclaim(struct p2m_domain *p2m) } while ( (p2m->pod.count == 0) && (i < ARRAY_SIZE(mrp->list)) ); } -static void pod_eager_record(struct p2m_domain *p2m, - unsigned long gfn, unsigned int order) +static void pod_eager_record(struct p2m_domain *p2m, gfn_t gfn, + unsigned int order) { struct pod_mrp_list *mrp = &p2m->pod.mrp; - ASSERT(gfn != gfn_x(INVALID_GFN)); + ASSERT(!gfn_eq(gfn, INVALID_GFN)); mrp->list[mrp->idx++] = - gfn | (order == PAGE_ORDER_2M ? POD_LAST_SUPERPAGE : 0); + gfn_x(gfn) | (order == PAGE_ORDER_2M ? POD_LAST_SUPERPAGE : 0); mrp->idx %= ARRAY_SIZE(mrp->list); } @@ -1160,7 +1160,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, p2m->pod.entry_count -= (1UL << order); BUG_ON(p2m->pod.entry_count < 0); - pod_eager_record(p2m, gfn_x(gfn_aligned), order); + pod_eager_record(p2m, gfn_aligned, order); if ( tb_init_done ) { From patchwork Mon Oct 2 12:59:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114605 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653719qgn; Mon, 2 Oct 2017 06:02:05 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBcBYwF6e542PHAAQdAsBCVxjMNq2SLmk87o7xW1RovTTQAufZt0dg9HG16Kl5xW7bf1ewj X-Received: by 10.202.56.10 with SMTP id f10mr7282265oia.396.1506949325255; Mon, 02 Oct 2017 06:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949325; cv=none; d=google.com; s=arc-20160816; b=NiIlOqSng1cOu8YZ18yIHvxczU6PJAOc5T6ouh9ygEp0hE6gYfb+9YWStsAgcokqX9 ThN6sUDnuROrfIj6nmgG4t29f80jKXRX9IRjWSwsM1Lv6C6X1Mim5biV1m4yKMwQYbHQ sS+lXKWuUb68wBX0FARDAi+L+NEm5pi8XetuGrtgitY24RNIKwIWAUVqpBADJlJhR9Zb AckVtqrCM7a9ppb0k6N1SrZo14tVipkzIzip6RzWV5NubFtjK+ZcuntCPo9bTMXaF1FL ARqkRgWj0XntqG/ehQJxTZfNSKoPWbcwBY0QqveJksQ6mtPUNip3Tg+Rdc+pLnZ5Vs+Q wnvQ== 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:arc-authentication-results; bh=1QjRkiDn8ruQbr1shDCskNhaiq1BJRMrXXfSaZfT4HQ=; b=neIawOzwthgG+NqyfA7Bgcfvjbg5Y6pflvA/56g/RIN3bqWgxkxWbZH58Pg/ULPoG9 cm+QZRbYaEHisBex+Gwes3b6ZzH+tO0Mke+sTN5rufbCk1OzrekNNiLfAusKVAPRMOj+ y8IqhFGr0l1C2kYCgM+pbeNk6oDyxBzl83P5tZ8cWmbiO5v45Cb00jGbtbh8gNJyfPYX DQE4xlAm/gleYZhOcEPSQ7TK8Qxf63nhvUdKVdL4rhsrhlfGSHHueVrIbzZyK1y6+SPz PL5+A6JIKMS7r5aTwof6RLUVvDfgGPIhLuR/dz8iVNdolQTKEf5kQTC0R5i/cu9iugP3 Y97w== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r184si9242037iod.208.2017.10.02.06.02.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:05 -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 1dz0KR-0004GS-02; Mon, 02 Oct 2017 13:00:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KP-0004DW-Kv for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:09 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id D9/80-03093-85832D95; Mon, 02 Oct 2017 13:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTfU4lK kwcsPkhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8brfbPYC17yVqyedJyxgXEaVxcjF4eQwGZG iR+TX7BAOKcZJaZ8msrUxcjJwSagKXHn8ycwW0RAWuLa58uMIEXMAosZJT7v72XuYuTgEBZwl 7j2ugikhkVAVWLBvweMIDavgJXEu1snwWwJAXmJXW0XWUFsTqD4++MfwWwhAUuJ492TmCYwci 9gZFjFqFGcWlSWWqRrbKyXVJSZnlGSm5iZo2toYKaXm1pcnJiempOYVKyXnJ+7iRHoYQYg2MG 4c33gIUZJDiYlUV5mw0uRQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4NcyBcoJFqempFWmZOcBQ g0lLcPAoifCagqR5iwsSc4sz0yFSpxh1OTpu3v3DJMSSl5+XKiXO+98MqEgApCijNA9uBCzsL zHKSgnzMgIdJcRTkFqUm1mCKv+KUZyDUUmY1wVkFU9mXgncpldARzABHTGn6wLIESWJCCmpBs Yrcmvmp/+ofDHVOeist6WG/4npEc+z1zlfYQ7oOWsm/+5ytPW14unBBx7UVK8Idr52oONdzuL I5cWl31+cv3XOONnioukXj33tn0/l18wV536w2CZ+3u3Mo9MWFxd5MrJ91CyI1d49f9rtWfwf TnxPlra4MbMpzqF0jdGCdjWhH2J7GTyl1skrsRRnJBpqMRcVJwIAxfxDVnYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1506949204!82141557!1 X-Originating-IP: [217.140.101.70] 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 57315 invoked from network); 2 Oct 2017 13:00:05 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-21.messagelabs.com with SMTP; 2 Oct 2017 13:00:05 -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 B218A1682; Mon, 2 Oct 2017 06:00:04 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A30723F53D; Mon, 2 Oct 2017 06:00:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:37 +0100 Message-Id: <20171002125941.11274-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 11/15] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Replace (foo == 0) by !foo - Remove uneeded parentheses Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 176d06cb42..6581f8d82f 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -861,17 +861,19 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) for ( i = 0; i < count; i++ ) { p2m_access_t a; + struct page_info *pg; mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, &a, 0, NULL, NULL); + pg = mfn_to_page(mfns[i]); + /* * If this is ram, and not a pagetable or from the xen heap, and * probably not mapped elsewhere, map it; otherwise, skip. */ - if ( p2m_is_ram(types[i]) - && ( (mfn_to_page(mfns[i])->count_info & PGC_allocated) != 0 ) - && ( (mfn_to_page(mfns[i])->count_info & (PGC_page_table|PGC_xen_heap)) == 0 ) - && ( (mfn_to_page(mfns[i])->count_info & PGC_count_mask) <= max_ref ) ) + if ( p2m_is_ram(types[i]) && (pg->count_info & PGC_allocated) && + !(pg->count_info & (PGC_page_table | PGC_xen_heap)) && + ((pg->count_info & PGC_count_mask) <= max_ref) ) map[i] = map_domain_page(mfns[i]); else map[i] = NULL; From patchwork Mon Oct 2 12:59:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114596 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653293qgn; Mon, 2 Oct 2017 06:01:49 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBkKScAt73Zu33KvsG8j+yIPQknHzIqSII8ZHu5+N08+Pxiip+/yIphhjpqC5tVp9NxKSPI X-Received: by 10.107.133.92 with SMTP id h89mr22386853iod.208.1506949308920; Mon, 02 Oct 2017 06:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949308; cv=none; d=google.com; s=arc-20160816; b=VMZ4jf2IsCm8EvqNoMtfHSAGX6hmAVHFBudwYbEB1Dh873gQQkLA4YBSbbtMjr07GR QE/oEjAW6SdIzAQx8Qg+wpZB07ik46Z0DdR9RjfTE/zxHql1Sib7t6fZvHaD3rh3uf1s gKOX3tVaZD35RtZ1R3xoc+yJidlX9tH7sD3WVWZx4KUYfgZWpZqyJRBgXArJpr5b5XdE mLDfil/9CYdofpfmmY99sMU1DXaQ6AbPM6ocAFsDWN1Jkjg/wlIlce7YXUQpUH+li7x7 gNWjxGYEGpr6t0vgNWWb5S0dZWbeGWNX8MNiJPiR5krQBSlAxp/gFwxOGRqg3cX4aP5B a4xw== 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:arc-authentication-results; bh=aHqYx53WIOVM+H5d1/6NrRPssX9kFk0VDuOriJQS32c=; b=UVZKUt/5EcYe7WpIvfX4v8otPgDpNgr7o895XrY43HKs40HKCEszB/LEvtmctnWPX3 O+BGNlUKSDv/18pou77Aw4uFDD0+XbDiHDNe6G3ROqEnCn9tmFI3XLsx+WIBBR3MXHB6 Fqkd4lFofZAzkU0UsfX8nEQthxmoHgl6oYN+Z7cs5VXTVsklDsMzqmqWgryHJcPxXA9f czmHvVimQmjqoXbF7xW+SMxw1JApapuDm+tdyJE0aTuq4wxWkj/xDg6iIRj0wWFg9bkH En++Z5/9HRZb5nv6v+ajSeIfbi0DzdZ6NgLzHzZ2mNDF4F5X1iw5aW66oBwwYSt8E7NJ 1Dgg== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id q185si8856504itc.206.2017.10.02.06.01.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:01:48 -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 1dz0KS-0004JC-GF; Mon, 02 Oct 2017 13:00:12 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KR-0004Fl-4q for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:11 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id 52/BF-03422-A5832D95; Mon, 02 Oct 2017 13:00:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTTfM4lK kwddpphZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8afnotsBWcMKmacesDawPhFqYuRi0NIYDOj xL6pUxghnNOMEhOnbGXrYuTkYBPQlLjz+RMTiC0iIC1x7fNlsCJmgcWMEp/39zKDJIQFgiRat /cB2RwcLAKqEq1zTEHCvAJWEmdbH4DNkRCQl9jVdpEVxOYEir8//hHMFhKwlDjePYlpAiP3Ak aGVYzqxalFZalFupZ6SUWZ6RkluYmZObqGBmZ6uanFxYnpqTmJScV6yfm5mxiB/mUAgh2Mdzc FHGKU5GBSEuVlNrwUKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCV8McKCdYlJqeWpGWmQMMNJi0 BAePkgivKUiat7ggMbc4Mx0idYrRmOPHpCt/mDg6bt79wyTEkpeflyolzlsBUioAUppRmgc3C BYBlxhlpYR5GYFOE+IpSC3KzSxBlX/FKM7BqCTM6wIyhSczrwRu3yugU5iATpnTdQHklJJEhJ RUAyM7s3bjobf+dyWfL2Nev/lFNKt/3N97dXHLH095rB5clnbh3T2n6yvXXdwUWfl1evW5yI+ f0zq0ta46t8qtePY0p9zy+HSn+McZPg1fl/jdmb6w69jWgKIZLb0pGx7Nj9q80HFyWcAOpRum 63dEHZ1409Og90Jc9NpgAY2G7aemPoiZWJbGveCNEktxRqKhFnNRcSIAW82IoXsCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1506949206!118733092!1 X-Originating-IP: [217.140.101.70] 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 37781 invoked from network); 2 Oct 2017 13:00:06 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 2 Oct 2017 13:00:06 -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 0BE61165D; Mon, 2 Oct 2017 06:00:06 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F10163F53D; Mon, 2 Oct 2017 06:00:04 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:38 +0100 Message-Id: <20171002125941.11274-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 12/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_zero_check 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" At the same time make the array gfns const has it is not modified within the function. Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 6581f8d82f..668c484a75 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -498,7 +498,7 @@ p2m_pod_offline_or_broken_replace(struct page_info *p) } static int -p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn); +p2m_pod_zero_check_superpage(struct p2m_domain *p2m, gfn_t gfn); /* @@ -582,7 +582,7 @@ p2m_pod_decrease_reservation(struct domain *d, gfn_t gfn, unsigned int order) * - not all of the pages were RAM (now knowing order < SUPERPAGE_ORDER) */ if ( steal_for_cache && order < SUPERPAGE_ORDER && ram == (1UL << order) && - p2m_pod_zero_check_superpage(p2m, gfn_x(gfn) & ~(SUPERPAGE_PAGES - 1)) ) + p2m_pod_zero_check_superpage(p2m, _gfn(gfn_x(gfn) & ~(SUPERPAGE_PAGES - 1))) ) { pod = 1UL << order; ram = nonpod = 0; @@ -680,10 +680,9 @@ void p2m_pod_dump_data(struct domain *d) * in the p2m. */ static int -p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn_l) +p2m_pod_zero_check_superpage(struct p2m_domain *p2m, gfn_t gfn) { mfn_t mfn, mfn0 = INVALID_MFN; - gfn_t gfn = _gfn(gfn_l); p2m_type_t type, type0 = 0; unsigned long * map = NULL; int ret=0, reset = 0; @@ -694,7 +693,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn_l) ASSERT(pod_locked_by_me(p2m)); - if ( !superpage_aligned(gfn_l) ) + if ( !superpage_aligned(gfn_x(gfn)) ) goto out; /* Allow an extra refcount for one shadow pt mapping in shadowed domains */ @@ -816,7 +815,7 @@ p2m_pod_zero_check_superpage(struct p2m_domain *p2m, unsigned long gfn_l) int d:16,order:16; } t; - t.gfn = gfn_l; + t.gfn = gfn_x(gfn); t.mfn = mfn_x(mfn); t.d = d->domain_id; t.order = 9; @@ -843,7 +842,7 @@ out: } static void -p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) +p2m_pod_zero_check(struct p2m_domain *p2m, const gfn_t *gfns, int count) { mfn_t mfns[count]; p2m_type_t types[count]; @@ -863,7 +862,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) p2m_access_t a; struct page_info *pg; - mfns[i] = p2m->get_entry(p2m, _gfn(gfns[i]), types + i, &a, + mfns[i] = p2m->get_entry(p2m, gfns[i], types + i, &a, 0, NULL, NULL); pg = mfn_to_page(mfns[i]); @@ -901,7 +900,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) } /* Try to remove the page, restoring old mapping if it fails. */ - p2m_set_entry(p2m, _gfn(gfns[i]), INVALID_MFN, PAGE_ORDER_4K, + p2m_set_entry(p2m, gfns[i], INVALID_MFN, PAGE_ORDER_4K, p2m_populate_on_demand, p2m->default_access); /* @@ -913,7 +912,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) unmap_domain_page(map[i]); map[i] = NULL; - p2m_set_entry(p2m, _gfn(gfns[i]), mfns[i], PAGE_ORDER_4K, + p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K, types[i], p2m->default_access); continue; @@ -940,7 +939,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) */ if ( j < (PAGE_SIZE / sizeof(*map[i])) ) { - p2m_set_entry(p2m, _gfn(gfns[i]), mfns[i], PAGE_ORDER_4K, + p2m_set_entry(p2m, gfns[i], mfns[i], PAGE_ORDER_4K, types[i], p2m->default_access); } else @@ -952,7 +951,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) int d:16,order:16; } t; - t.gfn = gfns[i]; + t.gfn = gfn_x(gfns[i]); t.mfn = mfn_x(mfns[i]); t.d = d->domain_id; t.order = 0; @@ -973,7 +972,7 @@ p2m_pod_zero_check(struct p2m_domain *p2m, unsigned long *gfns, int count) static void p2m_pod_emergency_sweep(struct p2m_domain *p2m) { - unsigned long gfns[POD_SWEEP_STRIDE]; + gfn_t gfns[POD_SWEEP_STRIDE]; unsigned long i, j = 0, start, limit; p2m_type_t t; @@ -997,7 +996,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) (void)p2m->get_entry(p2m, _gfn(i), &t, &a, 0, NULL, NULL); if ( p2m_is_ram(t) ) { - gfns[j] = i; + gfns[j] = _gfn(i); j++; BUG_ON(j > POD_SWEEP_STRIDE); if ( j == POD_SWEEP_STRIDE ) @@ -1039,19 +1038,19 @@ static void pod_eager_reclaim(struct p2m_domain *p2m) do { unsigned int idx = (mrp->idx + i++) % ARRAY_SIZE(mrp->list); - unsigned long gfn = mrp->list[idx]; + gfn_t gfn = _gfn(mrp->list[idx]); - if ( gfn != gfn_x(INVALID_GFN) ) + if ( !gfn_eq(gfn, INVALID_GFN) ) { - if ( gfn & POD_LAST_SUPERPAGE ) + if ( gfn_x(gfn) & POD_LAST_SUPERPAGE ) { - gfn &= ~POD_LAST_SUPERPAGE; + gfn = _gfn(gfn_x(gfn) & ~POD_LAST_SUPERPAGE); if ( p2m_pod_zero_check_superpage(p2m, gfn) == 0 ) { unsigned int x; - for ( x = 0; x < SUPERPAGE_PAGES; ++x, ++gfn ) + for ( x = 0; x < SUPERPAGE_PAGES; ++x, gfn = gfn_add(gfn, 1) ) p2m_pod_zero_check(p2m, &gfn, 1); } } From patchwork Mon Oct 2 12:59:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114604 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653792qgn; Mon, 2 Oct 2017 06:02:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBRGmj6Z7jMsKuN7IGRSPp14/4gJgBWVg3dcvXllp0Av2jTXjGwZd+m6ybqF3yiFUUv2imP X-Received: by 10.107.78.6 with SMTP id c6mr24195493iob.128.1506949327012; Mon, 02 Oct 2017 06:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949327; cv=none; d=google.com; s=arc-20160816; b=JI0wfOlOEG4dCLwAHqYZT1EQysE9buudj05g+G4lBW2sivdmTJAV4NRz0mJ5wpCEJD BaDQnktOGBCSMBF4MBrOFrr4uyGDarpTAn5PiP4sMe+COUtRLOfw0MXzbxRKbWY2ijaS YFSuMbSPYaZ7q4bvsTembXdoY81xZ/50qUnV589P7+gfyVakA0COwP66PfR5vEbzcXYj YZ7XuMeyJ6Fi7pgccJicAQRlXJfYjW5H5x6JznRfaDUeZX4N9KVWpiaAurHl81o/7wT4 jmcWzfcZfqyDoR2EiEyZ8+MyS6OJ/N1BQb7jAwBKXsZAcx6JCk0eqJl1kzX7xb0l4LQs 6KoA== 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:arc-authentication-results; bh=cdOOHYEdk0mPuxo3PeQ/O6UB6JJq3Qz8sudeHM3A/HA=; b=efOii3FV5S3KUM7NAo60l6gCzOCToCkg7sJS0pn1HrDHk+LWxBAo34oEUNiQSdSQQQ 3AZRYlI+mpCLHX2+OBGusPxvm5jzeoRB+Xrt2TF+qUZGcEhiyl97HDgQLwnxQA4Jz0Pp OFs20d5Kk5y4h0g5PD5tva4LDtmtiAmmyn3NmQ3QC2o+8Sn9OAK0qhxnadGq61xKTP5X 5ZxoaUL55V7yU8VGjSKLjD1Yoe7cgNCv9gkHLoJog6ApmjcK3Dn+1pcen03IUxKcUO+g g55n4BftyqxiCumX5zv3BWXaITNrjH4LGUDPC7cNwYpmGbG/n8b8HRLxt7v2okhO6ZEO 3F4Q== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id k65si8656530iof.308.2017.10.02.06.02.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:07 -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 1dz0KQ-0004Ft-O2; Mon, 02 Oct 2017 13:00:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KP-0004DL-FQ for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:09 +0000 Received: from [193.109.254.147] by server-4.bemta-6.messagelabs.com id 8D/F4-03283-85832D95; Mon, 02 Oct 2017 13:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTfC4lK kQfcNboslHxezODB6HN39mymAMYo1My8pvyKBNaPlXCdrwWqNiknb3jM3MD6R6WLk4hAS2MQo cWf6LXYI5zSjxITfPSxdjJwcbAKaEnc+f2ICsUUEpCWufb7MCFLELLCYUeLz/l5mkISwQLjEt 5+3wIpYBFQlNv5oB7N5BawkHn64AFYjISAvsavtIiuIzQkUf3/8I5gtJGApcbx7EtMERu4FjA yrGDWKU4vKUot0jSz0kooy0zNKchMzc3QNDcz0clOLixPTU3MSk4r1kvNzNzECfcwABDsYz68 NPMQoycGkJMrLbHgpUogvKT+lMiOxOCO+qDQntfgQowwHh5IE73xzoJxgUWp6akVaZg4w2GDS Ehw8SiK8xSBp3uKCxNzizHSI1ClGXY6Om3f/MAmx5OXnpUqJ81aAFAmAFGWU5sGNgAX+JUZZK WFeRqCjhHgKUotyM0tQ5V8xinMwKgnz1oJM4cnMK4Hb9AroCCagI+Z0XQA5oiQRISXVwLiq1P D9om79gFPaD+pWM4Zwraq9pfDD4uRuI8O3CvvjWdvdAnzOnuiQWi/LFFS2yjUvce5Edfs3vGw nqn+Fx7uf2DqpQvNhiX7vohNHD7Tevz5ZvWLj+rirYWw+rPe++fl56Loanjv7YP6N30cXFc5M v7KybWoJw86y87yzp9p0eYZp/Qs5k6zEUpyRaKjFXFScCACp91qadwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-27.messagelabs.com!1506949207!114052584!1 X-Originating-IP: [217.140.101.70] 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 20752 invoked from network); 2 Oct 2017 13:00:07 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-27.messagelabs.com with SMTP; 2 Oct 2017 13:00:07 -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 59EF480D; Mon, 2 Oct 2017 06:00:07 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4A9443F53D; Mon, 2 Oct 2017 06:00:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:39 +0100 Message-Id: <20171002125941.11274-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 13/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Stefano's reviewed-by Changes in v2: - Add Andrew's acked-by - Variable gfn_t was renamed to gfn_ in a previous patch. So use the new name --- xen/arch/x86/mm/p2m-ept.c | 5 ++--- xen/arch/x86/mm/p2m-pod.c | 12 ++++++------ xen/arch/x86/mm/p2m-pt.c | 6 +++--- xen/include/asm-x86/p2m.h | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index f14d1686b7..bc25582c5a 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -965,7 +965,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, index = gfn_remainder >> ( i * EPT_TABLE_ORDER); ept_entry = table + index; - if ( !p2m_pod_demand_populate(p2m, gfn, i * EPT_TABLE_ORDER, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER, q) ) goto retry; else goto out; @@ -987,8 +987,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, ASSERT(i == 0); - if ( p2m_pod_demand_populate(p2m, gfn, - PAGE_ORDER_4K, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) ) goto out; } diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 668c484a75..55f2fa4f18 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1076,13 +1076,13 @@ static void pod_eager_record(struct p2m_domain *p2m, gfn_t gfn, } int -p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, +p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order, p2m_query_t q) { struct domain *d = p2m->domain; struct page_info *p = NULL; /* Compiler warnings */ - gfn_t gfn_aligned = _gfn((gfn >> order) << order); + gfn_t gfn_aligned = _gfn((gfn_x(gfn) >> order) << order); mfn_t mfn; unsigned long i; @@ -1135,8 +1135,8 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, goto out_of_memory; /* Keep track of the highest gfn demand-populated by a guest fault */ - if ( gfn > p2m->pod.max_guest ) - p2m->pod.max_guest = gfn; + if ( gfn_x(gfn) > p2m->pod.max_guest ) + p2m->pod.max_guest = gfn_x(gfn); /* * Get a page f/ the cache. A NULL return value indicates that the @@ -1170,7 +1170,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, int d:16,order:16; } t; - t.gfn = gfn; + t.gfn = gfn_x(gfn); t.mfn = mfn_x(mfn); t.d = d->domain_id; t.order = order; @@ -1210,7 +1210,7 @@ remap_and_retry: int d:16; } t; - t.gfn = gfn; + t.gfn = gfn_x(gfn); t.d = d->domain_id; __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), &t); diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index 4bfec4f5f0..a639a00e9c 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -802,7 +802,7 @@ pod_retry_l3: { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_1G, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G, q) ) goto pod_retry_l3; gdprintk(XENLOG_ERR, "%s: Allocate 1GB failed!\n", __func__); } @@ -844,7 +844,7 @@ pod_retry_l2: if ( p2m_flags_to_type(flags) == p2m_populate_on_demand ) { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_2M, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M, q) ) goto pod_retry_l2; } else *t = p2m_populate_on_demand; @@ -883,7 +883,7 @@ pod_retry_l1: if ( l1t == p2m_populate_on_demand ) { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn, PAGE_ORDER_4K, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) ) goto pod_retry_l1; } else *t = p2m_populate_on_demand; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 07ca02a173..1ae9216404 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -720,7 +720,7 @@ extern void audit_p2m(struct domain *d, /* Called by p2m code when demand-populating a PoD page */ int -p2m_pod_demand_populate(struct p2m_domain *p2m, unsigned long gfn, +p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order, p2m_query_t q); From patchwork Mon Oct 2 12:59:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114602 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653680qgn; Mon, 2 Oct 2017 06:02:04 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDUywJynEejWMR6xSFelxa3r+LHCZTUxV7OSEil4d+eNhFxrnbk88PGr4+bR6tb4WAoYTf1 X-Received: by 10.107.19.139 with SMTP id 11mr23785901iot.286.1506949323975; Mon, 02 Oct 2017 06:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949323; cv=none; d=google.com; s=arc-20160816; b=mjajx8RQs/a+vg5ETcjYqmLRo/T1pS8PXye7eASOR4driuNBc4mPSlzFRofIrhIKAZ UDLveJ+qAGHHAKG9eFW68qcorZpB2YxHKZg7BgaFjl++r9SJJIxUB/+DfGkZTPLnZ5mB EM8crGDyeuLUHLEX1Qpk4jktFlLj0v4dEV4qRdTrirwLp3zjGhxA0EeWX7pLt/56suKS rjh9+lw2ELmhAeAsT3wUtirO3hRwWHI8H1XkqUSy2Byj31GPTwcEAE3PwQS/rSd2y1Bm n0ty84MiCdJ8cv2E8IHAiN8iwjGnyDJ8Sx0nvM0Xvt+y3HpFnFzevOf2NilVPY0xGRef mE6A== 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:arc-authentication-results; bh=1IDh8lf0d3NHYTC7S9T/bvZNw9XXMKDwRzWWdwCocKw=; b=c6tLnUSIf3/N40d+eFPDvJVnJTzBaPdTajnbXR2cuxoBcMjDG3xY7SR1mgLnkiCnDa 4u1CCfo15yS9iITwpjrOOUspk1uNaJzUYuGSCSLu4F0mOeW6tBV1GiDk79i69gZY6vQc IjsXnWNM46Ig1fy9EHImfpECrJx1wuGUb4bl9l3XryP5T+Mvr0bIt5GtW4+GAEmWzQmJ hlng/vb2JrZarUz/4QgB0I9B0XfiuFKyPiqcoDAICdpAiE2TqLRuuNcT5gJqM2tfUI9i XTDFT0EL1bHpHTOD2LdcI0OMJOOtN/B67oqLcZubN47GpapVZmN6ADXcyoGUwMoKxUVe x36w== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c3si9019218iog.153.2017.10.02.06.02.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:03 -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 1dz0KS-0004Ia-8i; Mon, 02 Oct 2017 13:00:12 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KQ-0004Er-RC for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:10 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 96/D0-01784-A5832D95; Mon, 02 Oct 2017 13:00:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTfS4lK kwZnD0hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bP7gtsBefFK15sWcvSwHhfsIuRk0NIYDOj xNrZ+V2MXED2aUaJFXtPsIAk2AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b3MIAlhgQyJm Sv+gdksAqoSEx9uBmvgFbCS+LXyDyOILSEgL7Gr7SIriM0JFH9//CMrxGZLiePdk5gmMHIvYG RYxahRnFpUllqka2isl1SUmZ5RkpuYmaNraGCql5taXJyYnpqTmFSsl5yfu4kR6GEGINjB+G+ b5yFGSQ4mJVFeZsNLkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeFPMgXKCRanpqRVpmTnAUINJ S3DwKInwmoKkeYsLEnOLM9MhUqcYdTk6bt79wyTEkpeflyolzlsBUiQAUpRRmgc3Ahb2lxhlp YR5GYGOEuIpSC3KzSxBlX/FKM7BqCTMywUyhSczrwRu0yugI5iAjpjTdQHkiJJEhJRUA2NSf6 1yTXLCvIkXn/7JPnNMTaeq2v3pl71mmkwBjz+ePa0o/4jrpPykd9+VErY0TmI5U8iU2vNpm69 xwhX2ZP3ZyWEnFvWLMc5eXrB8Y/CmZzFyBqGNRY4bVubvf1VofvKKoa/kZMuc++9t7/caftPa pP4gcta1rwxMZ15l/vgcou3Pr6JzIkGJpTgj0VCLuag4EQCEDLbSdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1506949208!112539087!1 X-Originating-IP: [217.140.101.70] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64879 invoked from network); 2 Oct 2017 13:00:09 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-206.messagelabs.com with SMTP; 2 Oct 2017 13:00:09 -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 A7B37165D; Mon, 2 Oct 2017 06:00:08 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 987903F53D; Mon, 2 Oct 2017 06:00:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:40 +0100 Message-Id: <20171002125941.11274-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 14/15] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest 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" Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 11 +++++------ xen/include/asm-x86/p2m.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 55f2fa4f18..8d50a0db85 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -977,10 +977,10 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) p2m_type_t t; - if ( p2m->pod.reclaim_single == 0 ) + if ( gfn_eq(p2m->pod.reclaim_single, _gfn(0)) ) p2m->pod.reclaim_single = p2m->pod.max_guest; - start = p2m->pod.reclaim_single; + start = gfn_x(p2m->pod.reclaim_single); limit = (start > POD_SWEEP_LIMIT) ? (start - POD_SWEEP_LIMIT) : 0; /* FIXME: Figure out how to avoid superpages */ @@ -990,7 +990,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) * careful about spinlock recursion limits and POD_SWEEP_STRIDE. */ p2m_lock(p2m); - for ( i = p2m->pod.reclaim_single; i > 0 ; i-- ) + for ( i = gfn_x(p2m->pod.reclaim_single); i > 0 ; i-- ) { p2m_access_t a; (void)p2m->get_entry(p2m, _gfn(i), &t, &a, 0, NULL, NULL); @@ -1020,7 +1020,7 @@ p2m_pod_emergency_sweep(struct p2m_domain *p2m) p2m_pod_zero_check(p2m, gfns, j); p2m_unlock(p2m); - p2m->pod.reclaim_single = i ? i - 1 : i; + p2m->pod.reclaim_single = _gfn(i ? i - 1 : i); } @@ -1135,8 +1135,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, goto out_of_memory; /* Keep track of the highest gfn demand-populated by a guest fault */ - if ( gfn_x(gfn) > p2m->pod.max_guest ) - p2m->pod.max_guest = gfn_x(gfn); + p2m->pod.max_guest = gfn_max(gfn, p2m->pod.max_guest); /* * Get a page f/ the cache. A NULL return value indicates that the diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index 1ae9216404..e8a9dca480 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -316,8 +316,8 @@ struct p2m_domain { single; /* Non-super lists */ long count, /* # of pages in cache lists */ entry_count; /* # of pages in p2m marked pod */ - unsigned long reclaim_single; /* Last gpfn of a scan */ - unsigned long max_guest; /* gpfn of max guest demand-populate */ + gfn_t reclaim_single; /* Last gfn of a scan */ + gfn_t max_guest; /* gfn of max guest demand-populate */ /* * Tracking of the most recently populated PoD pages, for eager From patchwork Mon Oct 2 12:59:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 114607 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp653902qgn; Mon, 2 Oct 2017 06:02:11 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDCgATiKNOIi4qunsPFlgJVUf2dP0JY7MzocDJStNfxTEUTznYi33oycCGKhRTAgyAqVDeu X-Received: by 10.36.122.70 with SMTP id a67mr17934624itc.99.1506949330932; Mon, 02 Oct 2017 06:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506949330; cv=none; d=google.com; s=arc-20160816; b=yKz4cMJCQYGFEZ7YWqv4/ti4/D7NTnMh1ToM2dwRHI+vyjIYO9LXomiiMKA2292kA5 H7LWUBg6QP//DTqKwJcbRamHqVGdkTNRwtId2dhVz3AsQiWA2SCbG8mVB1JMCryZn2/+ 2sWdw9re3ZFu2FEdaOswQkWoRR2FuxdUVspJKs2QcLL+4e+hIGY9xFvXlS9VXf7jiVDY RpJsg7MwwWHl0oL8v1LNma5vapeOok22/sVnw3Su1hx+cENlxW8Hxv9gIZjhshhb4gVn ZDTsii56O6SZMwjc2X+6JDusK+zRn8iH0wTilziedCQWZObvZG++Pfd8S/quv6auYhaw 6pGA== 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:arc-authentication-results; bh=VpF/GW0MDPH8T1ifcXSgHhytw6f3PUk6QPh5o0Dc1Pg=; b=mltmXDTDCsSV3uo3bk//+qSrIoqhRoU6fidDI6ZQ7SGiLaHDxZ+n13wFRjoPvvmjN8 zFTRtiqJWcG1wOmQaNI1dE/tkBtM/FNxFoxhukKRalpnwl+nCo8523SQTLMZ2c9tsPwf C94Zez0Sulk8VpzIUhyYTqERRLyyiQ+BknhREtjXBDUOTrbIP0Y5jN9QY2gpCNAkgHYc sSOhzLl9+U81OWcodOpAv1wmoxNI/6OOeaOXacmseU0ZxrMozCyws6m6ZhVSv19aB+Jn kcdeW6aHrPuTDKk3YEzMx+qZIkRt2ZuD1ZpkJnOiKRSjdLZ9JZ7MNh3mtOFKmwR/vsLr qVjQ== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id r193si1002760itc.73.2017.10.02.06.02.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 06:02:10 -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 1dz0KT-0004Km-NR; Mon, 02 Oct 2017 13:00:13 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dz0KS-0004Hr-1b for xen-devel@lists.xen.org; Mon, 02 Oct 2017 13:00:12 +0000 Received: from [85.158.139.211] by server-9.bemta-5.messagelabs.com id 7E/45-02817-B5832D95; Mon, 02 Oct 2017 13:00:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTfK4lK kwd6n5hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aplnVsBSs0Kro+72JrYFwk28XIxSEksIlR 4snFRUwQzmlGiaNtG5i7GDk52AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b1gRcIC4RIbf 7xhBLFZBFQlXvVNBIvzClhJvLt2GMyWEJCX2NV2kRXE5gSKvz/+EcwWErCUON49iWkCI/cCRo ZVjBrFqUVlqUW6huZ6SUWZ6RkluYmZObqGBqZ6uanFxYnpqTmJScV6yfm5mxiBPmYAgh2MF09 7HmKU5GBSEuVlNrwUKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCV8McKCdYlJqeWpGWmQMMNpi0 BAePkgivKUiat7ggMbc4Mx0idYpRl6Pj5t0/TEIsefl5qVLivP/NgIoEQIoySvPgRsAC/xKjr JQwLyPQUUI8BalFuZklqPKvGMU5GJWEeV1AVvFk5pXAbXoFdAQT0BFzui6AHFGSiJCSamCcGn FscULp91ZnKxanmisC9Tx+JzSqjHVWZJnap/adZD18YP3pezv4Xkd7ZZblJv7S8mI8pOIbwiQ 4b9IFl6254Sw7urYE3Wu8onnk4ALG6G2rFu91MCtxtXcN2iA2gc3t86mtP2T+3/FRnuJ1iHnH E+llE1zcD63uObTb92kYS+bidI00vfdKLMUZiYZazEXFiQAecCrQdwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1506949210!112539094!1 X-Originating-IP: [217.140.101.70] 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 65166 invoked from network); 2 Oct 2017 13:00:10 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-5.tower-206.messagelabs.com with SMTP; 2 Oct 2017 13:00:10 -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 013EE80D; Mon, 2 Oct 2017 06:00:10 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E671E3F53D; Mon, 2 Oct 2017 06:00:08 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 2 Oct 2017 13:59:41 +0100 Message-Id: <20171002125941.11274-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171002125941.11274-1-julien.grall@arm.com> References: <20171002125941.11274-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v3 15/15] xen/x86: p2m-pod: Rework prototype of p2m_pod_demand_populate 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" - Switch the return type to bool - Remove the parameter p2m_query_t q as it is not used Signed-off-by: Julien Grall Acked-by: Andrew Cooper Reviewed-by: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v3: - Add Wei's reviewed-by Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-ept.c | 4 ++-- xen/arch/x86/mm/p2m-pod.c | 15 +++++++-------- xen/arch/x86/mm/p2m-pt.c | 6 +++--- xen/include/asm-x86/p2m.h | 6 ++---- 4 files changed, 14 insertions(+), 17 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index bc25582c5a..054827aa88 100644 --- a/xen/arch/x86/mm/p2m-ept.c +++ b/xen/arch/x86/mm/p2m-ept.c @@ -965,7 +965,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, index = gfn_remainder >> ( i * EPT_TABLE_ORDER); ept_entry = table + index; - if ( !p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_, i * EPT_TABLE_ORDER) ) goto retry; else goto out; @@ -987,7 +987,7 @@ static mfn_t ept_get_entry(struct p2m_domain *p2m, ASSERT(i == 0); - if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K) ) goto out; } diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 8d50a0db85..0a811ccf28 100644 --- a/xen/arch/x86/mm/p2m-pod.c +++ b/xen/arch/x86/mm/p2m-pod.c @@ -1075,10 +1075,9 @@ static void pod_eager_record(struct p2m_domain *p2m, gfn_t gfn, mrp->idx %= ARRAY_SIZE(mrp->list); } -int +bool p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, - unsigned int order, - p2m_query_t q) + unsigned int order) { struct domain *d = p2m->domain; struct page_info *p = NULL; /* Compiler warnings */ @@ -1116,7 +1115,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, */ p2m_set_entry(p2m, gfn_aligned, INVALID_MFN, PAGE_ORDER_2M, p2m_populate_on_demand, p2m->default_access); - return 0; + return true; } /* Only reclaim if we're in actual need of more cache. */ @@ -1178,7 +1177,7 @@ p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, } pod_unlock(p2m); - return 0; + return true; out_of_memory: pod_unlock(p2m); @@ -1186,10 +1185,10 @@ out_of_memory: __func__, d->domain_id, d->tot_pages, p2m->pod.entry_count, current->domain->domain_id); domain_crash(d); - return -1; + return false; out_fail: pod_unlock(p2m); - return -1; + return false; remap_and_retry: BUG_ON(order != PAGE_ORDER_2M); pod_unlock(p2m); @@ -1215,7 +1214,7 @@ remap_and_retry: __trace_var(TRC_MEM_POD_SUPERPAGE_SPLINTER, 0, sizeof(t), &t); } - return 0; + return true; } diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c index a639a00e9c..50637083f4 100644 --- a/xen/arch/x86/mm/p2m-pt.c +++ b/xen/arch/x86/mm/p2m-pt.c @@ -802,7 +802,7 @@ pod_retry_l3: { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_1G) ) goto pod_retry_l3; gdprintk(XENLOG_ERR, "%s: Allocate 1GB failed!\n", __func__); } @@ -844,7 +844,7 @@ pod_retry_l2: if ( p2m_flags_to_type(flags) == p2m_populate_on_demand ) { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_2M) ) goto pod_retry_l2; } else *t = p2m_populate_on_demand; @@ -883,7 +883,7 @@ pod_retry_l1: if ( l1t == p2m_populate_on_demand ) { if ( q & P2M_ALLOC ) { - if ( !p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_, PAGE_ORDER_4K) ) goto pod_retry_l1; } else *t = p2m_populate_on_demand; diff --git a/xen/include/asm-x86/p2m.h b/xen/include/asm-x86/p2m.h index e8a9dca480..70f00c332f 100644 --- a/xen/include/asm-x86/p2m.h +++ b/xen/include/asm-x86/p2m.h @@ -719,10 +719,8 @@ extern void audit_p2m(struct domain *d, #endif /* Called by p2m code when demand-populating a PoD page */ -int -p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, - unsigned int order, - p2m_query_t q); +bool +p2m_pod_demand_populate(struct p2m_domain *p2m, gfn_t gfn, unsigned int order); /* * Functions specific to the p2m-pt implementation