From patchwork Thu Sep 21 12:40:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113248 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846030edb; Thu, 21 Sep 2017 05:42:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBPHqQEW4S8U1YqZ+zoHg6c9r4V6LlPj04kSNsjTcgVSlqdWTFq51g8CgEAFGiLFsppjWek X-Received: by 10.107.190.7 with SMTP id o7mr2768131iof.18.1505997777747; Thu, 21 Sep 2017 05:42:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997777; cv=none; d=google.com; s=arc-20160816; b=A98wPcaR7EtDmVTLiswzPq1Otc49iDpe+5DbsznupjTTkcou4Lhk3l/xcMKISHX4Zq WSmS0EAsLrolysbSa+4k0U5bMuJxfAJlTJwjt21a7dcsOdMpCfDhycidIhT1spTpfHz+ F2rKQiWpOh2jZQj2J9fvKejXVpNHD6MK1RcqDAHwm601DTRuk9HAhgGnyidu9V7QFY/Z SUaDiNA763v+8FFnt7FjvHFwAJLV0GQuOpXzQbVMCEtuF4P/J52mC1XGYluvjWEZ36tM +WP4/twWRUmNJZuQSKWzaixlQs9DtltNZz0ACBZhDDPi6k2Wg7i1BVjsN1LTv9wWujII Eezw== 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=THIqrWuDNNlazmpY28OxW9Vk0cYv5meOPQvBXC4bPpQ=; b=h6+aSUrFui337DvEHbN5VJN8NoKDxtfXuFZ7OHLt/S7TAGf6lMUcjxZ7AIL5nfb1Kj HmNMDGz06KnLnUw7AzNJ9oeq/wt/Y97fklm0hKfyr9y2HkI6NKtBxtcPkzuBQKpRhCxM YrsRspvJbyMrS94aNQDSkOu7dRh6uZY2nJCCZ6tGvWSJM2MKIU50m79mdtZtlO3X8C+m 159rN8PVvVfjcxNyCKSnxslJO2t8rgqVrrRLYGCczhV+1D7d7N9CniGEGLp6dM34yCkf 42t9c2AXwfXzaLmOniLR4cgAZ9aOrMy/UwXSiCcyD6lXbj6av1i5HRzCnla5rfJUwNoi 53Dw== 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 h21si1182618iof.62.2017.09.21.05.42.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:57 -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 1dv0md-0001CY-Rx; Thu, 21 Sep 2017 12:40:47 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mc-0001CS-JC for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:46 +0000 Received: from [85.158.143.35] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-2.bemta-6.messagelabs.com id 4C/F8-16615-D43B3C95; Thu, 21 Sep 2017 12:40:45 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFLMWRWlGSWpSXmKPExsVysyfVTddn8+F Ig43XLS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oyV31tYCw5wVpw58ZKxgXEJRxcjF4eQwGZG iW2PfjBBOKcZJW6ffQvkcHKwCWhK3Pn8CcwWEZCWuPb5MiNIEbPAYkaJz/t7mUESwgK2Em/2n wGzWQRUJS5ef8cIYvMKWEg82nUbzJYQkJfY1XaRFcTmFLCUaDv8DcwWAqr5NeEE6wRG7gWMDK sYNYpTi8pSi3QNzfSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQJ9zAAEOxjvbww 4xCjJwaQkyvtu3eFIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8AZuAcoJFqempFWmZOcBgg0lL cPAoifA2gaR5iwsSc4sz0yFSpxiNOQ5MuPKHiaPj5t0/TEIsefl5qVLivOYgpQIgpRmleXCDY FFwiVFWSpiXEeg0IZ6C1KLczBJU+VeM4hyMSsK8yiBTeDLzSuD2vQI6hQnolOwNB0BOKUlESE k1MEr+Xvc5a9UttsyDxzvVZWWPK8woPyQnGLDQb/KTPe8/ZM52CLx48ZjbG3kH5bvqvy16M3d ePnvl4fzV1kELEszqzTW+bf776Lrl5jCOGHu3Kk7+FN+DJ7sVFtapVjMcv1Znoidb3BPns9Bj 1tMVP+QX/jkfmrL/7NI112boBFRZWgg9/jLnZ64SS3FGoqEWc1FxIgDXwfWyfQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-21.messagelabs.com!1505997644!71997059!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 5471 invoked from network); 21 Sep 2017 12:40:44 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-21.messagelabs.com with SMTP; 21 Sep 2017 12:40:44 -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 183721529; Thu, 21 Sep 2017 05:40:44 -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 090B53F58C; Thu, 21 Sep 2017 05:40:42 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:20 +0100 Message-Id: <20170921124035.2410-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 01/16] 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 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 Thu Sep 21 12:40:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113244 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845956edb; Thu, 21 Sep 2017 05:42:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAgbuD6et8RSIhqlSODVKFE7+1arPoJRRZHVYKwKKv/BjdcGovqDO3zNDUqiRIU++XvYSjj X-Received: by 10.36.176.70 with SMTP id b6mr1341537itj.26.1505997773084; Thu, 21 Sep 2017 05:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997773; cv=none; d=google.com; s=arc-20160816; b=wJcnnSCbz8bpkX1slWSuMXyzhLiO1U7zpJy5Osw5p6h6c8u73Erj4hFmV4LlU8cCPl lzJv5gqxZrkWSZJB0FvL1hitofmaKyDpCSa4SeCAoL0J+XvYZzBJh4PF17Vn/wEioneS akR1015PocnEpOUWKljVwx6B7O4jQpLR4MJVCH7VjE3M0VOvr/42/ZOQkjKvtx88kFCF Loy1XfKGPn3FtbqgefA+5a68r1k7puJ6HxC6fsEqleiQG3O51q66sznK/WUBZ3J6tclO ND9yJAsbqhtZxIeA3STrOQWy3ZU52Z76m7gXcWlz+KRsZB/id3HtvOIErPDl8uFR9lWO CbWQ== 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=5LkedxGVepuXfooI3JX1z2s3xDQvcTzMdVi/Y1RNP78=; b=JMfI9B4eRX2zy9sWJEjQRPkZFfXyVqXWDuEpU6RLR4h+HCXGVccWO5vBSdsQ/lIBu8 nDESz9ASDpxr1H1LKlnyauuwRxOqZzE0KDHfImG32C7gqCgrtXg+1aVc4VC6opVqisj7 D/ndvfbDccATxomB5hmdzYbeFizH6VDixMbuy65WyeoOAcMOhDsRpblPqOWh0zSEIbs8 uMnKgrZ+z+tn77FN7p6RZkSeY5GlvPCACZKlA8EdmdYctl2bxcLMyhwnrTYgSNuMW6zB ScaJwwINZZHq/deHtIWn1Gsp7IRtXajutlcRxlPiy4QaGMMwoWHea93zNafsArVT0jw6 MF9g== 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 b65si1129928iob.116.2017.09.21.05.42.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:52 -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 1dv0mh-0001EA-K3; Thu, 21 Sep 2017 12:40:51 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mg-0001D1-D7 for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:50 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 4F/56-03642-153B3C95; Thu, 21 Sep 2017 12:40:49 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTddv8+F IgxO/+CyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oztM7rYC46ZVzx5uJ25gfG+RhcjF4eQwGZG iZ1nlzJDOKcZJSZsOM/UxcjJwSagKXHn8ycwW0RAWuLa58uMIEXMAosZJT7v72UGSQgLuEt0n 7zM1sXIwcEioCoxaUEsSJhXwELi7YlrYCUSAvISu9ousoLYnAKWEm2Hv4HZQkA1vyacYJ3AyL 2AkWEVo0ZxalFZapGukaleUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkaghxmAYAf jqgWBhxglOZiURHl5/hyKFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBa/cXKCdYlJqeWpGWmQMM NZi0BAePkgivIUiat7ggMbc4Mx0idYpRl6Pj5t0/TEIsefl5qVLivO4gRQIgRRmleXAjYGF/i VFWSpiXEegoIZ6C1KLczBJU+VeM4hyMSsK86iBTeDLzSuA2vQI6ggnoiOwNB0COKElESEk1MK oUb8s3lVsr+J2vcI73P8+ejz8O6YU7eJ3o2HHT8nLKpScrTc23OJrsmLdaTqtQ+/nU7x+s3Kv tdtj1Cb4xyrVKrfj/Ku/84w8bs1UK1SaVxU44vfnE173PeL3jLm+/Hce1bJG0QpSc/onEFRop gTwhV8/9+N9odCP83ox/9h3sFUy7Lwi8CldiKc5INNRiLipOBACf1PatdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1505997645!60906383!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 61289 invoked from network); 21 Sep 2017 12:40:45 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 21 Sep 2017 12:40:45 -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 66295164F; Thu, 21 Sep 2017 05:40:45 -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 571F33F58C; Thu, 21 Sep 2017 05:40:44 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:21 +0100 Message-Id: <20170921124035.2410-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 02/16] 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: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 Thu Sep 21 12:40:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113253 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846128edb; Thu, 21 Sep 2017 05:43:03 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBV0Yx/HvCCUtce5oarRjXUpCfTVXkESvR31C+1d8OAjs2D3vdpxicgDA+kr/rsuOksHxZP X-Received: by 10.36.250.10 with SMTP id v10mr1117342ith.135.1505997783830; Thu, 21 Sep 2017 05:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997783; cv=none; d=google.com; s=arc-20160816; b=j/+GJY9HVZf7+uhVkZhAZJUYdkSZqMUY5EIpJ3SXWadsZHnwHc1UFRjD0SUJpiV4X0 DuhBY0B19o3VnPX/W6nk4W27pwPzxtrQgZVIAGr2WL2lCacGBcBrUGt4mxhs2GnUGRRh 6bADkpF538o+UP4nNG90EVksy6DRkNEGO1I4T9E2nDGTfITEtfJmI91WTcPmoXACh/mH MZ+TW0XfvN4lYpk4F73Rg/nZe059r6cStcgjBg46HGc9ZF3j/IOH1Ca6lpgjYefru/hX ZZ0/BAKSacn9EnP4N384dpWPgbwWD8ddofqCksyo+TWVaguhHctSMpONaRscHfDsfOxt rj3A== 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=2eacanKA709jNaGR2S3799KfBI3UyBSRMJdF1G7LpZw=; b=K1XaFvJ1mPO8mSJvPFnmFWkyPgZ+aDNANHkB90hD8YimMaRyyj70PqBQBLyJjCvDsx d4UMZMjl0+JX2olAS2Ec9RwSbfhRQmlwFBGnUQ3SM1Up5CAKkWCcqTqk4wOMUKLVDUE1 OlZiUSFwiRH2tImcGS0gTxTCQBcKB5XkKkCFEc0ZMRDBbIWFEjZjZhDSF4N1Yhv1wirG /lEcBOQrjW1jbFQYU+eNEKxztgo+mF35GCUzimHqFocHq/JLYoyoGWrbJFwCYqUdwpNS 06ULU4udRPlephOY8UxdKAF/yTAep9HmMKzLX51Pu43v0mM/xSUNLv6qttKDjhumwrOw DMVQ== 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 c16si1317841itc.193.2017.09.21.05.43.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43: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 1dv0mg-0001DG-92; Thu, 21 Sep 2017 12:40:50 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mf-0001Ck-8a for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:49 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id B9/63-03610-053B3C95; Thu, 21 Sep 2017 12:40:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdd/8+F IgytnjS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ow1s2+zF/zIrTjRtIutgfGffxcjF4eQwCZG ifdTm1m7GDmBnNOMEhef1IHYbAKaEnc+f2ICsUUEpCWufb7MCNLALLCYUeLz/l5mkISwgKfEs 6v97CA2i4CqxIVdM8AG8QpYSFxvucQGYksIyEvsarsIFucUsJRoO/wNapmFxK8JJ1gnMHIvYG RYxahRnFpUllqka2iul1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6GEGINjBeHt jwCFGSQ4mJVHeI4WHI4X4kvJTKjMSizPii0pzUosPMcpwcChJ8D4tB8oJFqWmp1akZeYAQw0m LcHBoyTC+wckzVtckJhbnJkOkTrFqMvRcfPuHyYhlrz8vFQpcd6jIEUCIEUZpXlwI2Bhf4lRV kqYlxHoKCGegtSi3MwSVPlXjOIcjErCvNwVQFN4MvNK4Da9AjqCCeiI7A0HQI4oSURISTUwxj ubKrLuV0zo6XqSyWv5NCb1UrS7p/Tbe6+SV+vJK/19oX6hzfr5IZNZV+Oi2Jw3WFdsjnyQMLm Ewz/qhIlJa/fn3zuZhPr4X6zbKuT30u3UlGi7ddtefHjWaLztutvEujM+RpvX8h2TNUyauHDR jPArYet5OIr3GxkXnzmx62lxkEj8WblOJZbijERDLeai4kQA3BrFiXYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1505997647!106972113!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 45703 invoked from network); 21 Sep 2017 12:40:47 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-27.messagelabs.com with SMTP; 21 Sep 2017 12:40:47 -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 D7D1A80D; Thu, 21 Sep 2017 05:40:46 -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 A52823F58C; Thu, 21 Sep 2017 05:40:45 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:22 +0100 Message-Id: <20170921124035.2410-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 03/16] 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: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 154 ++++++++++++++++++++++++++++++---------------- 1 file changed, 102 insertions(+), 52 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 1f07441259..6f045081b5 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<= 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)); } - /* 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: 113242 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845932edb; Thu, 21 Sep 2017 05:42:50 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAXbWC3i1wUipb01zvD2BpstvWH6ETA5ZyDilN/IWv4uETv4hUp/123PWD0BzWgMA5eXYdp X-Received: by 10.107.157.129 with SMTP id g123mr2918980ioe.182.1505997770691; Thu, 21 Sep 2017 05:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997770; cv=none; d=google.com; s=arc-20160816; b=J/Qr9cgw7yXfxAY8DUsBXfRa6eKyvKQLP2vNiP86PFQAKHMhDt3+isUuOLLA8aRN91 ACghQ3X3S0QU2Io8OU4vFa1dav+MEK41b4N9FPsVyBlmK1lAHSEzRiJC7j5EmtfIMeEJ dmXTDwSGVkz2PKymO0l8c6bYgXkgxo3EUkVMlAGm5YhRmikZJlI0znmvDLtGrVMtI0Sn hW0nt+HHdfHyzy6jZUDO8pgNpofnbytQKVPp75dewRnSldcq94EsN2j/FtYMDVMYXJm8 6j92ysOPTvJOCdJN0Q2TNIRPGCNb5p+1k9WBXLCJpggfr2mNP4T46vwr9gFp6Aly1rmJ BZIw== 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=cuXsr75AteBATzUw8p67P7KSjnRWWXhpXj9lBsHy9YU=; b=fEapXmVwv1sq3dSgwSwTKZ2xOM/+gYABtlUCbvIMlfUP40AD5N2eeJrd3RBYAavmtp I1Ued+McyI50vYtq17h1201euDnhfUqiycg+pY+mtlEoY1Ym/ztGu7yxJt/GWKlTTEmF B9/+6ElNKH8v3oBSDqJ5s1nDEC0Eor5v5ygmWrzrdkp3PtomfiFExAaml8nzeP9unrUQ xs8WRCIauJFM3JP0yPqAAHkQNe0/gONo/1PJ3F7irrCmiVMZQdEehRJCZiQhQPa6e2RS acZJBvef6Ts7MYXXpp/95ZHYzL9MOw+koJA70IvBGewOSdQ8GbDZez+Ce5OMFOtnE2uT BPSQ== 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 x7si1495647ite.61.2017.09.21.05.42.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:50 -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 1dv0ml-0001H0-2E; Thu, 21 Sep 2017 12:40:55 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mj-0001Ck-A7 for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:53 +0000 Received: from [85.158.143.35] by server-7.bemta-6.messagelabs.com id 07/A3-03610-553B3C95; Thu, 21 Sep 2017 12:40:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTdw8+F Ig/nLuSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyz+yexFHxLrzjzYTd7A+N0jy5GLg4hgc2M EheXX2GCcE4zSnw9P4Wli5GTg01AU+LO509MILaIgLTEtc+XGUGKmAUWM0p83t/LDJIQFrCRu LNqLSOIzSKgKvHjxHmwOK+AhcSBk6/AbAkBeYldbRdZQWxOAUuJtsPfwGwhoJpfE06wTmDkXs DIsIpRozi1qCy1SNfIXC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9DHDECwg3H x2sBDjJIcTEqivAHuhyOF+JLyUyozEosz4otKc1KLDzHKcHAoSfCm+QDlBItS01Mr0jJzgMEG k5bg4FES4WUBSfMWFyTmFmemQ6ROMepydNy8+4dJiCUvPy9VSpzXBKRIAKQoozQPbgQs8C8xy koJ8zICHSXEU5BalJtZgir/ilGcg1FJmNcRZApPZl4J3KZXQEcwAR2RveEAyBEliQgpqQbG3U 5nP1/RCOn9lrplRwfHY8kyEcY69nqe+MJTjJJz9T+3K54JF8hRcuQ81iR2uGPNtyMb+r9pG4v k11SevVV9w5aDi4Hx47kLAnsWPjT5++ii5LmUrGXp23M978UtXfo0LSfo8fHpi+s/3z4v8OhH ovuhDcENWY9/S7AXbFPZ2/P/oYPr1OAFSizFGYmGWsxFxYkAP90GgncCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1505997648!60906395!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 61800 invoked from network); 21 Sep 2017 12:40:48 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 21 Sep 2017 12:40:48 -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 31C5C1529; Thu, 21 Sep 2017 05:40:48 -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 228D33F58C; Thu, 21 Sep 2017 05:40:46 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:23 +0100 Message-Id: <20170921124035.2410-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 04/16] 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: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - Add Andrew's acked-by --- xen/arch/x86/mm/p2m-pod.c | 102 +++++++++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 50 deletions(-) diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c index 6f045081b5..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; @@ -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 Thu Sep 21 12:40:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113241 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845922edb; Thu, 21 Sep 2017 05:42:50 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBXf57dIYj5Zo+/Zb0NaAng9ElueldvdV4mwACXC4aEagbpLi/oCuKqvxc/81P3lfX3N8Dn X-Received: by 10.36.105.142 with SMTP id e136mr1188855itc.17.1505997769979; Thu, 21 Sep 2017 05:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997769; cv=none; d=google.com; s=arc-20160816; b=C5OoeHR7gYOCvGe1wUWnrFV2csb3MEB0SxYS/w+AllS/8uV+9uybVacvMMEpjIvFs1 +3t25JnlOlqtKJmvkKY7lJwidngRXuL1H2um0XKeaVndlwq1jCCTS6L/RU4HQ24w68og r5DCSI0Ffy/e8aLDVUe92diWDOe9/3B4udR0lOw9mHFP1VWS8yz+L8q0EQz/4UOCfzns ty7UGu4p2pK4CYP8wCgSUXe667Zgrku9Abk2Fm8xyD+LwogVgnE40CKECI0Q6SI7KXW3 fK/R3Tnpp/U4/I6ZuSz1qTMaoSXZFyOGet00Dz1bEw5BMnwk4QXUjhrYbLPrrIZxbdXJ Bf6A== 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=x38TadgwGI1qNjXneTCG3zrgx/9Xpf6nCUIgBvfxdq0=; b=A6mj8cVGYErF15EGLFnqgHREZo1NqFqGUZhTYL/hRPP8ofkcXooaDGkVRUFJOd8Zqs oUn/ArcUgtWkVFlB3xZ9qIg9mLbo1BTnSm9rl5zAIajYbIzva8KwaWY3Dr3or4XDQlCI S3A9bHcoLntPc4uCgrSzRy3+oUg3iK2RKPa+duBSQU78yqyWZfLbxr0zeeFWLiydCk0i yvn2eBs7QTeFeVsgAo0V4qqaYwgBbxGEkzeBf5pByMw8FNzeTIYpbE5MnwL8Itprt+k+ psHpijFCI13s1k+I8QbS0xY/gamuKpv6z0xG/Min0ivs3QGeYG71ShoSGpAzkDkmXW2s Iz4w== 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 x136si1529851itb.84.2017.09.21.05.42.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:49 -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 1dv0mi-0001Ex-Qx; Thu, 21 Sep 2017 12:40:52 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mh-0001Dq-Rq for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:51 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 1E/DD-25121-253B3C95; Thu, 21 Sep 2017 12:40:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTTdo8+F Ig9WXpC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oxZqwoLTgpUbHp1g7GB8StPFyMXh5DAZkaJ lvl3WSCc04wS7zYuZ+pi5ORgE9CUuPP5E5gtIiAtce3zZUaQImaBxYwSn/f3MoMkhAWSJPre/ GQHsVkEVCV6Hq5nBLF5BSwknn57zgpiSwjIS+xquwhmcwpYSrQd/gZmCwHV/JpwgnUCI/cCRo ZVjBrFqUVlqUW6RqZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBHq5nYGDcwdh 6wu8QoyQHk5Io77t1hyOF+JLyUyozEosz4otKc1KLDzHKcHAoSfA2bQLKCRalpqdWpGXmAEMN Ji3BwaMkApHmLS5IzC3OTIdInWLU5ei4efcPkxBLXn5eqpQ4rzlIkQBIUUZpHtwIWNhfYpSVE uZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMqwwyhSczrwRu0yugI5iAjsjecADkiJJEhJRUA+Pi4/ wxfzjNlK6x3izdvuqcKl+e49xlp69s8tPawyPtqVz6N1H4fFPhH4ue6aGdadURz2bnrs6sO+8 UGeUZXyw8ySyZ6ZeQhYcFv5Haui8HZpu/YixIfPImW3XaGkufK/eXLrn4Zu2VZ6EzTwg+iJ5Q k7T/sZwQo1iDa+HLtcEi/zomKnW89ldiKc5INNRiLipOBAA9IJ+KdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-11.tower-31.messagelabs.com!1505997649!84945964!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 37536 invoked from network); 21 Sep 2017 12:40:50 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-11.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40:50 -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 7FC81164F; Thu, 21 Sep 2017 05:40:49 -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 709133F58C; Thu, 21 Sep 2017 05:40:48 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:24 +0100 Message-Id: <20170921124035.2410-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 05/16] 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: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 Thu Sep 21 12:40:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113251 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846103edb; Thu, 21 Sep 2017 05:43:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBn8mvsRVh35cFrjd1MftuqQ8O3vWEE7ePsjFnKXvrB3JvlzDThpXj4WlCFTekS5E3T9XIy X-Received: by 10.107.139.215 with SMTP id n206mr2843136iod.155.1505997782431; Thu, 21 Sep 2017 05:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997782; cv=none; d=google.com; s=arc-20160816; b=aLviISCW4ua9H9PKC0QV7rlPyxg/RPjbPoQQP0T11mgxMZY3qfyp9+RiJ3rwiDVoTj s9vDokzgaZQfZrDt/CmXwhKI4n4he+dGNhEKCjhTJXvAELmyQde4n25PNmIH/zLameLa ZzzfRFNiVf3MX+eq33zH8tJCh1ZYr0y4RZF6BNMBTFBAFYjjSGhBJe7EjGnn3GbimkZZ t9e8781Y86sDU/WvxNVAkdIrP3n3cLyHkYsVk//YlYsWHuLTGncw7qfR93dOfXnBI/KV Q1IFDHKSaV+07Vp3Cpz6gt+lapxXtumZeii3xnDfUG2fQrHUYjqpulEbenpaY2RRMeKE y2fQ== 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=tjFu/9hn6Tvny2ZWSd96qNYNS0oYu56Q40P5B/Wchw8=; b=0qFHtKmAHTeGs3bi+oyeQTK2pEaV/tRgilOlNyNB7ErGiN8uzIrZnBF4gjlII/8Nh5 4JSk/leb+1VIzSxughyr8haHZmCkT630FKKmTPS9xiAf6/xIqZQvikp+CnrcWebyZ/cS fqpBVpCmnEq6HJYuJAJslJr/QWS1e7ztBaBv6KmNJit5ZgrGWEsKyFif66BpLLNugUTK U6hT2BwKBGchJ0WirtLJ6IdjdSUBekeIMb3L4S7jknXDDLCW7ycnobhuFkh7TTdArC6L uk2szujyZF2LVzYYt/926vwM46j0KjNGuYV29lWiuKZGhBSpbSjpjlIP7zeHZqiRWgir V70g== 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 n63si1368626ite.79.2017.09.21.05.43.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43:02 -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 1dv0ms-0001RP-VE; Thu, 21 Sep 2017 12:41:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mr-0001PY-Sz for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:02 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 66/8F-01916-D53B3C95; Thu, 21 Sep 2017 12:41:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrJLMWRWlGSWpSXmKPExsVysyfVTTd48+F Ig5afyhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bbrNvsBcuFK1ovP2FrYNzE18XIySEksJlR 4nJrchcjF5B9mlFi2qJjbCAJNgFNiTufPzGB2CIC0hLXPl9mBCliFljMKPF5fy8zSEJYwENiy +o3YDaLgKrE+rfLWUFsXgELidPL94DZEgLyErvaLoLZnAKWEm2Hv7FCbLaQ+DXhBOsERu4FjA yrGDWKU4vKUot0jUz0kooy0zNKchMzc3QNDYz1clOLixPTU3MSk4r1kvNzNzECPVzPwMC4g/H Vcb9DjJIcTEqivO/WHY4U4kvKT6nMSCzOiC8qzUktPsQow8GhJMHLuQkoJ1iUmp5akZaZAww1 mLQEB4+SCO+EjUBp3uKCxNzizHSI1ClGY44fk678YeLouHn3D5MQS15+XqqUOO9KkFIBkNKM0 jy4QbAYuMQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmDcW5B6ezLwSuH2vgE5hAjole8MBkF NKEhFSUg2M2qa8FtMv3z+9yzjIwPyIrL5PNjNXgezRQ5rbr1utXJtvMDf0eKauy9FOX2vnJ79 OxR8Rkdec0/joXETK5K2NztETyntP5ZdlRRkqmlzLeVYs1s5tl9Qgd1fmqyTn6lWRs29GnL64 WreOX+eHzFeHl2efSR5s7hGLkju4teBA0n5e5XOcZqxKLMUZiYZazEXFiQASMc1qfAIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1505997651!57810137!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 59579 invoked from network); 21 Sep 2017 12:40:51 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40: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 CF11D1529; Thu, 21 Sep 2017 05:40: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 BEBCB3F58C; Thu, 21 Sep 2017 05:40:49 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:25 +0100 Message-Id: <20170921124035.2410-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 06/16] 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: Wei Liu Reviewed-by: George Dunlap --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 Thu Sep 21 12:40:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113252 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846122edb; Thu, 21 Sep 2017 05:43:03 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBM/N5jISPy1QideYsAmb5XkRdQBVSLEmteHjcmWNsdnARwsMwFuiR3y+3Q4z9m8nQF30Vm X-Received: by 10.36.110.3 with SMTP id w3mr1275276itc.113.1505997783595; Thu, 21 Sep 2017 05:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997783; cv=none; d=google.com; s=arc-20160816; b=ZTsZHISsUp13HFT52D/+JsCeJubatPhODgbfJEkKAAb0Qpto2KIyO4itz0hIofhigM xtXTf7OgKVj3AoyvQtzygQHhEZd0uU+GRl4OF/cP45KCwE3TAlT1ncqaai8G1omEuA9K cQpBQYLMz0pztZlDRwDx/Cfr5g71hYP65xNE4HtAgP8ojUVcLPUxoEVjeMVyxwuRl0n/ 3FqCorjWiKx3G32Aoc9mgcL8SVDy7AGcU1bvq3tvc9TFHFsbVHfsC29o17oXovN2UH2d 95AMerMgKnnLAXYzDROEy6OSd3QAlrhYaPBBq0/W2bjPBQsp7ZAukv86n7LpvQLoZtEH M0hw== 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=9du4enZMyIeFfVkSvUDfGEWDZ63xZdy0Tta6OonNFe8=; b=W0Uyb2EMueehPmolBtyKEHIbEPWTrAnrshMfjBGn1hILyqrIwK73J12LqmuAdGOZwW uK68s64XuoLihqxWh+px94tQq04jYNt8ThNWzstoou36OuHU+ugE+6aqcDOk3ou9dWm/ 0VQA8tpyyeo8kb5f6hQyoDUa9oG2ggE428pAi052M2qWi+lVHI2PHqN4fUQagwupd0xe p4qjNRw+fyoSoOnRXg7pxO7CBnDb7iRI4cI8ENQRNCwpWX26MZ8Vdk3SJjz8Y4ovstXS O0iL9inrb2fYnNbu7FUgwAxFXZ4iOTmGedVzSRgU7WLfSpFFvVsMp6Lbp7eUgNcaHjZL SplA== 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 q134si1084212iod.339.2017.09.21.05.43.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43: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 1dv0ml-0001Ht-FR; Thu, 21 Sep 2017 12:40:55 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mk-0001GP-HN for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:54 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id B1/98-02044-553B3C95; Thu, 21 Sep 2017 12:40:53 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTd08+F Ig3nzWCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oy2c1dYCk5YVky+0M7UwDhXu4uRi0NIYDOj xIO+vUwQzmlGiee9b9m7GDk52AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b3MIAlhgRiJ1 2/6WUBsFgFViXcPDoDZvAIWEje3fwFrlhCQl9jVdpEVxOYUsJRoO/wNzBYCqvk14QTrBEbuBY wMqxg1ilOLylKLdA1N9ZKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAn3MAAQ7GNd s9zzEKMnBpCTK+27d4UghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErwBm4BygkWp6akVaZk5wGCD SUtw8CiJ8DaBpHmLCxJzizPTIVKnGHU5Om7e/cMkxJKXn5cqJc5rDlIkAFKUUZoHNwIW+JcYZ aWEeRmBjhLiKUgtys0sQZV/xSjOwagkzBsLMoUnM68EbtMroCOYgI7I3nAA5IiSRISUVAOjiW CCR12LwFKdM2r8KyddnOrvtV/nzr6E0tzCeYzBgTLmSvPqU7YuUJIOf3Pcv/l8yaaSE/1fOyy us3FnOs79/chGS5j/AYvkQ5vqCxsk/JcE3Jzkt2qH03VN4UMd39YLC8x++aH9mkiTm13b1IrO gz90I1z1r+ec26X+3e8Pe0Hc1RW2UqJKLMUZiYZazEXFiQD/mvTqdwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1505997652!99078146!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 28846 invoked from network); 21 Sep 2017 12:40:52 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40: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 291C4165D; Thu, 21 Sep 2017 05:40:52 -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 19DB83F58C; Thu, 21 Sep 2017 05:40:50 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:26 +0100 Message-Id: <20170921124035.2410-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 07/16] 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 Thu Sep 21 12:40: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: 113255 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846168edb; Thu, 21 Sep 2017 05:43:06 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC4vrkR4dXorGrbFrUYjHC5I8Ym9iMjxmq9iQ3ZLs4Ay978FQmvQvAgbCpMjFr3OXAWsc0Z X-Received: by 10.36.41.78 with SMTP id p75mr1286845itp.21.1505997786527; Thu, 21 Sep 2017 05:43:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997786; cv=none; d=google.com; s=arc-20160816; b=kfWqA2lhviGCVA0KgkcOrcftNQN2EZLPcWUeZnPRSPtjFm29ai7hWY1P9Hocuw6iod Rb1M8NHDDFq6BGwmyDoQMnJqiK8tBQATu9s+A2I1/BvyBDJ3XAEKC10GRkXAlyi9g/HX bFRl5iOUiVvj7ywWkiC/GrGDMQ8dBZHi3wg96qXyParx6EBCY4+phMswVKcwvvSh9rUl cEyzdHsSyNTNuXzkSXAEtrizX6DUDOBwZtE08K8WIfLUcLB7khPWyyqUcqX9oe+XX/aQ ZAgN2pQ7AJDwmc0mkwJ2MeoIYjm0GypZPVDx/mYKDKfCEKopGUqQNoHmmg0UPzr7x6lL XTzA== 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=bNU6RtYl9ZugCLjf7zPiN2cQLozn+aGyLTTnZgRMENU=; b=m0wlj8jdvTMObkppcXYGja+95qhFI19bKqnZj75a9E/+4N88jxqFGhoKaT+kLNEUo1 VxFMfy7kEk/SoD9uBJbulsPhAAf87oTWEPtjyaziCQhxplTT3kS0hFRtFjYG6IUdaDNZ TYSVEYR9po0o9bPcLKTUw6F/wu2f0Rz7hMjE0wPi2kwXNZ0qORGmOZGa/wWWcByGULL1 YR0IfE5GkHeRnqYfydJvhE16TJ3s3moEkWSLhG4bFKwe4Rt3TfkFWeDgeCP7LfG3HgxY zuslTNtJO75oBw0mQ/KExTjRW4qrWQ9ho3r+RHtFx9DejrdUPyutw+SJbKTqmyPtc6DD gseQ== 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 i2si535678iob.252.2017.09.21.05.43.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43:06 -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 1dv0mo-0001Kq-NK; Thu, 21 Sep 2017 12:40: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 1dv0mn-0001JG-7e for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:57 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 1A/2D-02226-853B3C95; Thu, 21 Sep 2017 12:40:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGLMWRWlGSWpSXmKPExsVysyfVTTd88+F Ig8kN4hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aPG0dYCi5tZ6z4sGQNSwPjjGbGLkYuDiGB zYwS77dsY4NwTjNKND+ZA+RwcrAJaErc+fyJCcQWEZCWuPb5MlgHs8BRJok9LTtYQRLCAmkSs 9/MYwexWQRUJTo3T2UEsXkFLCTWzr4P1iwhIC+xq+0iWD2ngKVE2+FvYLYQUM2vCSdYJzByL2 BkWMWoUZxaVJZapGtorpdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJEehnBiDYwfj ytOchRkkOJiVR3nfrDkcK8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDl3ASUEyxKTU+tSMvMAQYc TFqCg0dJhNcVJM1bXJCYW5yZDpE6xajL0XHz7h8mIZa8/LxUKXFec5AiAZCijNI8uBGw4L/EK CslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYV5lkCk8mXklcJteAR3BBHRE9oYDIEeUJCKkpBoYXX oKjky78Lx1n6JS5rTvNf+TnA9wKulH/vjzpDuqw01jx6bXE39+PXD3u7KR4KVX9r9y+2232Ux 0634Zm/Djye4QuUv8f54c7WKvYJ7GuN4yp1xhy/MlXuEWFenCSsfSMmWZ49LEl5le4qqwzDex kmc2vpKlVnvgrX5monnJrSq9XxFbrs1UYinOSDTUYi4qTgQAF3pJ4nkCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1505997654!99078159!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 29174 invoked from network); 21 Sep 2017 12:40:54 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40:54 -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 356251529; Thu, 21 Sep 2017 05:40: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 689093F58C; Thu, 21 Sep 2017 05:40:52 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:27 +0100 Message-Id: <20170921124035.2410-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-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 v2 08/16] 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 Reviewed-by: Wei Liu --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Razvan Cojocaru Cc: Tamas K Lengyel Cc: George Dunlap Cc: Jun Nakajima Cc: Kevin Tian 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 93394c1fb6..2a32102a41 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 9211fc0abe..948e377e69 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 Thu Sep 21 12:40: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: 113250 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846075edb; Thu, 21 Sep 2017 05:43:00 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB6k8XehOgd/P2nQG0LvL4dxKC4lUFrYzUW+Fw1XaFbwq8aR+xWTYwa8O0RhiTskmu18yCx X-Received: by 10.36.115.148 with SMTP id y142mr1157610itb.147.1505997780414; Thu, 21 Sep 2017 05:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997780; cv=none; d=google.com; s=arc-20160816; b=Xf+RFeuzaD/MFT1MBDk2EPflv7DxaY0HvHNILz5XTNGTFTnG8CSUpeHPAUSR2bMSzC 79xktTzqihznpmK9Xi/UhS+dG+3AZ0hx7LjTLFP8tjluOo6jj5v1dfzrsT7FNvS+6Wg1 MCk9FzGfw9FIIVC7rkKO7AERBpgnRGiQoST0E0lH3bsgsL644Jf7jrrDSLgWzN8zLEl8 8cLGI8U27D8XI5YNC07VvVGUbYfoVMQox4BZlPjfCuXtPaq/Sla2iLcnkG9f4pyypfId AC0aXSjJndPag/+DMiQFP6ppXTUS80RdNchxUOGbqyatgm0zzHMbiJAGyXVd92X0udMH Ipeg== 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=9ZtWfL4HRqmec5far5oERCLdt3k6TWqXMRjSTnwqmNQ=; b=IQ+tUw1kZBX3EuycWl7FwG/DMFdJQLg+kIHONnsMzafNA4I23+g0g3UBhM1S64vl1m 9b0j7rNpjItVwnm8gjEyqvUgEDRwRhfwo5Y1LLD2xoL1LG8IDCDQXO3qd0qDXC0GaTI1 F+RJgkheY4sa/LMVqXWEFSkZx/2Mm4p4T4HJBQKyZKB6KJd/OsRsgoVGUMjBgtBk6iVk wtxfICvu1x5aZYKYqcthcM6dLH5f2nBmgANziVf6wDuy+FQAc2bz93lbI5kn3Jeu4lRC ahBduirNQPdu4bP1j81fQWJ5vrSLHac2e2QMxDiVFoizVeOwCc6oYkSrrSFn/9W/DjpR tmHg== 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 u194si1438066itb.84.2017.09.21.05.43.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43: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 1dv0mq-0001MW-2R; Thu, 21 Sep 2017 12:41: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 1dv0mo-0001KK-EB for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:58 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 09/EA-01910-953B3C95; Thu, 21 Sep 2017 12:40:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTTdi8+F Igw+XzCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyX1zcwFWy4zljx/ltJA+OjeYxdjFwcQgKb GSUuHD3N2sXICeScZpTYe9MaxGYT0JS48/kTE4gtIiAtce3zZbAGZpCa/gt72UESwgKeErtOL GAEsVkEVCXe//3P0sXIwcErYCnR0pEHEpYQkJfY1XYRbD4nULjt8DeoXRYSvyacYJ3AyL2AkW EVo3pxalFZapGusV5SUWZ6RkluYmaOrqGBsV5uanFxYnpqTmJSsV5yfu4mRqB/GYBgB2PzF6d DjJIcTEqivO/WHY4U4kvKT6nMSCzOiC8qzUktPsQow8GhJMHbtAkoJ1iUmp5akZaZAww0mLQE B4+SCESat7ggMbc4Mx0idYrRmOPHpCt/mDg6bt79wyTEkpeflyolzmsOUioAUppRmgc3CBYBl xhlpYR5GYFOE+IpSC3KzSxBlX/FKM7BqCTMqwwyhSczrwRu3yugU5iATsnecADklJJEhJRUAy P/5aKq5c//H0o6WyXUYVgeLOYyQ017E++Pb8ILrgfm733Kt70rX7BjRlPZgrjikL2mzw5E3c/ S8cppT/zkqMRvItj00v6/8XaLfRdK2HSn/FLY4c5s7yHlpfbr/lYn2Zyfh4osDnF/2OpwOPH0 ddW2KnefXpG+r5P3cjqk1dWlza+pfD5VV4mlOCPRUIu5qDgRAOXcGQN7AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1505997655!108332021!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 26465 invoked from network); 21 Sep 2017 12:40:56 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40: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 A6B82165D; Thu, 21 Sep 2017 05:40: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 740043F58C; Thu, 21 Sep 2017 05:40:54 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:28 +0100 Message-Id: <20170921124035.2410-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Tamas K Lengyel , Jan Beulich Subject: [Xen-devel] [PATCH v2 09/16] 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 --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Tamas K Lengyel 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 Thu Sep 21 12:40: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: 113246 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845988edb; Thu, 21 Sep 2017 05:42:55 -0700 (PDT) X-Google-Smtp-Source: AOwi7QB4Nbrs/DmZXonlKhBXHFPoV5vRu8dH8qUuDAYD6FPIaQ8CUy3kQ3gfg/q2hQ6i1aJWrV0r X-Received: by 10.107.180.216 with SMTP id d207mr3076008iof.275.1505997774901; Thu, 21 Sep 2017 05:42:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997774; cv=none; d=google.com; s=arc-20160816; b=Y7sHIjINgwsE0bmZnlPkcmQLxtm9AcombPvdPv67SD+qNulnkKXfF0VcG+cm5mqMaz ilkgBjvU1fSEYS5zKaK/nFIGWh2VxjNQQr+romg4FCNTPn5I2S3pqYREG3hRubT7N2PH Kbl+30UnXdNll1gJFaFkJT2TiXKg6Abx9zlpR+OAaiDE0v9V2s6Bc2psWq6yHPM49Nyc 3SrPhOhNJSzLHBT1BrG/siRIMp5I3os0mHwPeLsIlD43qu+mlH1PSuJW4mCVwCJiLOti 7yYiFyg9p9BsaGjoeSanaScIMM2xBGZ/AeG7tXaYMokZVdDf8LeSLlR4P5bpopJIbmv2 sdzQ== 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=FlCsDt1Agggaj7lc5Uhj/Rjmxjm9HsXCZ1JlKGnGkYY=; b=iiQQGCCQvvyJfkpEvoq/EMZ7FU7CehxfP1fDRTBalRp4Kq0Bq3DJ2o/5hms9iX7kXz 02ol3oeyFen2BGk3Rs2rxIlva8BgXZqXkKcBIaYQ0FcHAlpRQls9HC9vFMwK7EcGYchf FdPrFOMRio95NtT0E1jqkBcjlLM1IDo5tqe2EeJ6xD3DOHdZYt30voc+4RCYbBAkVhPC kVcQftwePbC1iOGYtVDrnnWgc+IhkrmTIhvnrODlaCs3W/nOe3uuBzPlkt9qNSl+Y3b/ 7zYDRUKDHMIHNcbIIFG6cxvALsC+rx7UUTo04XSlZDtxpO9lzxqdj4at3rPCQWHFDO5U yetQ== 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 q65si1398513itg.158.2017.09.21.05.42.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:54 -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 1dv0mq-0001NJ-Aa; Thu, 21 Sep 2017 12:41: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 1dv0mp-0001Kf-0t for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:40:59 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 2F/6A-01812-A53B3C95; Thu, 21 Sep 2017 12:40:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTdy8+F Ig73LdS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oy9rQtYCy7xVHTt2MPawNjH1cXIxSEksJlR 4s/rLjYI5zSjxKNZdxm7GDk52AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b3MIAlhgQCJf XP+gtksAqoS7y98BmvgFbCUaNv4hR3ElhCQl9jVdpEVxOYEiR/+BmYLCVhI/JpwgnUCI/cCRo ZVjBrFqUVlqUW6RgZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiBPq5nYGDcwdh 8wu8QoyQHk5Io7wbFw5FCfEn5KZUZicUZ8UWlOanFhxhlODiUJHh1lIFygkWp6akVaZk5wGCD SUtw8CiJ8AaApHmLCxJzizPTIVKnGHU5Om7e/cMkxJKXn5cqJc77WwmoSACkKKM0D24ELPAvM cpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLmFQVZxZOZVwK36RXQEUxAR2RvOAByREkiQkqqgX Fz2CEhs0tuTLdCVpyblsgRfvVX64LHXkmRHhMFnP4vCZiQpXLwV23spqO2pr/tT8w/fE2JzSX 8sOYej0eBy1kOr57Leon1VAO7rvWW4GT+Q0t0Fi7SObrE7tbDmxUG3BvX5Eu+2dyj+NLNsekB 26ttSm5P3lSZys+V8/yRl/tX62IC25xjbB1KLMUZiYZazEXFiQCeYIaodwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1505997657!115886870!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 51393 invoked from network); 21 Sep 2017 12:40:57 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:40: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 00D401529; Thu, 21 Sep 2017 05:40: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 E5C4E3F58C; Thu, 21 Sep 2017 05:40:55 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:29 +0100 Message-Id: <20170921124035.2410-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 10/16] 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 --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 Thu Sep 21 12:40:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 113249 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846044edb; Thu, 21 Sep 2017 05:42:58 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAwW0HKPQF3jDm3fzdDtwBIyOqtSPwfsSm9MUIT82aLjrfLHT2lEfvEjUp1CeSO51eODZkO X-Received: by 10.36.17.196 with SMTP id 187mr1099539itf.101.1505997778453; Thu, 21 Sep 2017 05:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997778; cv=none; d=google.com; s=arc-20160816; b=rBVqAAsbO9tiSOtwlSc/oEiM3C230JMAws2G4ZxhhhGwx9N1O4MUR3KEaTGZ6pHnJr GHf1agnInhvajftQ3jMrc5W2sbvSAAxqBrO9iq4+/7TkSkK34BaAAbWQ/ulSl+uucSSW rA34236/PVWg6hwbWDYt0LUQMlD+y7BXg8YKCq2cmYw9xmymddO4K1oPq2fRG5ofUeOj rZI6qqt8hE5o3zBR13te+h4MnZL802gq3cV4KicVBqlWeRUrbVvW5BFgt4T3OPctIK9O KwkMseA6pdqWH6cmptoXDKl1Vj/Zx/NRpOXbFDHndll6dm+irW0Ly1x10qcO5GGxZ+s0 5FGA== 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=qRUBwg5229ZWaOkUP5pe8+iq4qP2DlTc5t83HSz0SIU=; b=tj2RtH9uMejCNQoZiKaRBqY0LZ5EtjCsr/v2/Q2bepDjloO5Dmp6pCNcY47vWgDaK4 iESPg4K+e0niMjaxQr27mncwMDZnsnxYC++bsiTzxCdeEDdRJWhDhfg/hMhFrPuGhy2V 3BJAaU2pcHx29S6SW6rKpkSV298rDRu6wiC05v73sN7tHNHljWRdLCVE3mFu1Ijn+Tgz FUlJetGrqwgJ8XJ+vOoYcDzLIZd4ZGrldPesUDk05vi4/4NC7aqea/gCYn8t3dKqzC+o D98wZNZbNyJ8KM/Cu8xIPUT9VGyYyYSqg6JX2ZyR6dQB+pNHoLcoqOIKqQWkM3zJtwrC sAwg== 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 f12si1142630ioj.105.2017.09.21.05.42.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42: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 1dv0mu-0001Tg-6C; Thu, 21 Sep 2017 12:41:04 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mt-0001Qx-5c for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:03 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id EB/14-03610-E53B3C95; Thu, 21 Sep 2017 12:41:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTTd68+F Ig0VRFks+LmZxYPQ4uvs3UwBjFGtmXlJ+RQJrxoRl01kLJvNWzFw5g62B8SFnFyMXh5DAZkaJ y1snskE4pxklltzYw9rFyMnBJqApcefzJyYQW0RAWuLa58uMIEXMAosZJT7v72UGSQgLuEvcf NLGAmKzCKhK/HyylR3E5hWwlFi2+zJYXEJAXmJX20WwoZxA8bbD38BsIQELiV8TTrBOYORewM iwilG9OLWoLLVI11QvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyPQvwxAsINx+mX /Q4ySHExKoryu8w5HCvEl5adUZiQWZ8QXleakFh9ilOHgUJLgfbYAKCdYlJqeWpGWmQMMNJi0 BAePkgjvSpA0b3FBYm5xZjpE6hSjLkfHzbt/mIRY8vLzUqXEeT+DFAmAFGWU5sGNgAX9JUZZK WFeRqCjhHgKUotyM0tQ5V8xinMwKgFVLASawpOZVwK36RXQEUxAR2RvOAByREkiQkqqgXH79N 5jd/tKHgYbdr1lq+qw/PZq96KcLtYVa3OnrJGyutvr1iZ++I5SxRv5CY95mpN/2IabHk1Nm2B r/iXZ+u3MPx8sFJhWrtxhtEAj7DwLa9c1KdaVeuFHP2xMPBe2UWTKv6PXWb6c5lspca/blP+9 99VCk0e87VvEQu9cPvYpKE7nxUoFhXYlluKMREMt5qLiRADHLNJ6dQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1505997658!117078323!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 60624 invoked from network); 21 Sep 2017 12:40:58 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 21 Sep 2017 12:40:58 -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 4FA4D1684; Thu, 21 Sep 2017 05:40: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 3F9573F58C; Thu, 21 Sep 2017 05:40:57 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:30 +0100 Message-Id: <20170921124035.2410-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 11/16] 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: Wei Liu --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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..611a087855 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)) == 0) && + ((pg->count_info & (PGC_count_mask)) <= max_ref) ) map[i] = map_domain_page(mfns[i]); else map[i] = NULL; From patchwork Thu Sep 21 12:40: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: 113245 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845967edb; Thu, 21 Sep 2017 05:42:53 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCMLN+C9aOJ33uAQXKnPPcjrhNyHp8NWvgEy3eMzCmh8rSsWrH8nTXL+d+qNC0wk4eRpMmw X-Received: by 10.36.66.138 with SMTP id i132mr1084425itb.93.1505997773768; Thu, 21 Sep 2017 05:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997773; cv=none; d=google.com; s=arc-20160816; b=EQor0IFiNv8/erwT5loZEktWECDWoKm7cw3Ltpu/okQphg12HhZx8ZAZGaRelFUVVt uX6iGJwsWAAyfz+GEx4vCsGSGAMHi8h78FFcybccDrV+72ISwvZrpsWPC+NWheiNgCWr RWbgbkw2mKPRRXIQaN3uCLiCwqk3sHuNPZ4SDH9q93aaU0LCRN9Of5hClDx2NGkHkORe RbgPjKk98u2RICfqpGK4haCglQj2mUyfX2Dpd9inGCi3MFbDQIauBg1upiN++JtmTaeJ lN5YET0mjn0tec5tuZhxdVygHfNxVGiVD6ctzM76Cwrxh/IO3LC+7aU7eHkwPLcCuiTs zG1Q== 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=C04GWqgk7d2t7qi2pcanm9ZPbT+pAZCpdAaqQDxk4YA=; b=wuy2Q1jRnOzjGU7lcygBTaYJYQnJy8AhSnZjCV6EdT4jqsMKLi+x+6oSr4ItDbqQHz tuOm4sfVEFWbT+7/ZQgKnD4nAYlQ1JMZxVDr7o3VxKSB9a13zXBT6WwkP5LTVhYBWwjb FFcTRt4WypeaMoxEDQH40+Rwa0YSOV4OX5Yc9+di8f8xkiV+pmYd9ICqrz8VUXgxC/Vs 9mF+mNUV4uTYjMZLIk1HUkLKHk/A1tlRZJ1ZMMDvMS2PzJ+opn15DvZE9VAWQPGTu+yh GdTsHWmhFB720v0kSbzj4nIqAn6ykGtfrz9RfvEMHmXT5t+WT9zUp/t4vWlRrXVNlz01 f1cA== 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 b7si1558698itj.17.2017.09.21.05.42.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:53 -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 1dv0ms-0001Qt-Mw; Thu, 21 Sep 2017 12:41:02 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mr-0001PW-SS for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:01 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id BD/C6-02224-D53B3C95; Thu, 21 Sep 2017 12:41:01 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFLMWRWlGSWpSXmKPExsVysyfVTTdm8+F Ig3XnFCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ox5G26wFrzVr+i+OomxgXGtUhcjF4eQwGZG iUdP7zNCOKcZJRa/agRyODnYBDQl7nz+xARiiwhIS1z7fBmsiFlgMaPE5/29zCAJYYEgicVXZ 7GC2CwCqhLv2teBNfAKWEpsmd0FZksIyEvsarsIVsMJFG87/A3MFhKwkPg14QTrBEbuBYwMqx g1ilOLylKLdI2M9JKKMtMzSnITM3N0DQ2M9XJTi4sT01NzEpOK9ZLzczcxAn1cz8DAuINx6gm /Q4ySHExKorzv1h2OFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBG7AJKCdYlJqeWpGWmQMMNpi0 BAePkgjvhI1Aad7igsTc4sx0iNQpRmOOH5Ou/GHi6Lh59w+TEEtefl6qlDivOcgkAZDSjNI8u EGwKLjEKCslzMvIwMAgxFOQWpSbWYIq/4pRnINRSZj3OchCnsy8Erh9r4BOYQI6JXvDAZBTSh IRUlINjMUHmMsPRRtedZ5WfTkn48TOigmdx47+jDKxiY7j3Rw/YX/A+8r1+W9b/3LGxHasE1O 4aP957UcLpRb5Qvc3r++r1Pe93bRW5mGu8nK1g5Vup88ULTx37enfpLb/l8pNVrUt+7LzjzuL 6gV/obL/zrcuxV6qOn52p967iEXJShUfZ7GtCNEQ7VZiKc5INNRiLipOBABNAojCfQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1505997659!115724330!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 26422 invoked from network); 21 Sep 2017 12:41:00 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-14.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:41:00 -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 9C8EE1682; Thu, 21 Sep 2017 05:40:59 -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 8D7CF3F58C; Thu, 21 Sep 2017 05:40:58 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:31 +0100 Message-Id: <20170921124035.2410-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 12/16] 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 --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 611a087855..0dd0f0a083 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 Thu Sep 21 12:40: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: 113240 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845836edb; Thu, 21 Sep 2017 05:42:44 -0700 (PDT) X-Google-Smtp-Source: AOwi7QA2ZCyQPvkR4B+wjDu+RgYEhmN+Phk1n9rA9bTpqE12txtWXHYOS3erXVUpQu8zFfyOgPYa X-Received: by 10.36.117.150 with SMTP id y144mr1308771itc.60.1505997764302; Thu, 21 Sep 2017 05:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997764; cv=none; d=google.com; s=arc-20160816; b=f0iXjCEzu0UsWe+fJeGnwdzkwxkfe0wvFwZq5vwanFDckE7RfFq14FyQaTrfifADOV i4bzyXiO5r+1kvirnL25TzcLbEhRFpvQA489acUURqRVmtQB+fWc5+IydWAWSeniqYYy QyXeMTRcaVxA0MAB8M8Mps5gwah+kUF0J0zdiUjcJMn20Br9bieg4eYw6sb87tAkbH3w 52iRk6niBjfaOZ+Vmt8cGSq9EqD/3HMNo30gtVsxziW0xJLxB31x7i0RV6z+mltBjXe6 HgPip8EhbCOZJoH1C91ERyPpBqp2HHpFqBPeia/8UI8WVtmYdhXFZ+sPu24Q3BfHQvMk pDYw== 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=YIUPPcqpzizVjGsPZ6uExuYmXDwa2Q57/KL+RBVZ1c8=; b=XWLw8xcec/2gogiIRoEZQD9zjAJj1TTAj46IEx5Hw7stZxdLS7kNh6nXQlHfCdx5Sr Eq194c0gPnIrH49FXU65WbXaG0G34YD9fc/Av28ZjUY7MfW1wDrxLtMZFLCBSWg58J3p Ji5PN4esnYQ2l4nIrE1KKYskBI1IfrbprHF48keoKBVnboIwkk6NDGyjtq/KSTFe4NZ5 0GJjGlMZr1suqdzHMY3sVN5UAsvrMXRE4W9UIiBVS2rOl2L9bRfCaNInNrx5yC/Mcv3o p3nPPYzBbOiFaeE1EGmVc/cXEp0y9e4UK1K9HVPR6XppNw0yLMuwswo19g0O/kKqcKRS f6WQ== 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 f130si1110712ioe.397.2017.09.21.05.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:44 -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 1dv0n0-0001cq-1b; Thu, 21 Sep 2017 12:41: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 1dv0my-0001ad-V4 for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:09 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 9F/25-17770-463B3C95; Thu, 21 Sep 2017 12:41:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTd28+F Ig/Xv9C2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ox9H06zFZxQr1g76xVzA+NMmS5GLg4hgc2M Eh/OrWWCcE4zSty83c3WxcjJwSagKXHn8ycmEFtEQFri2ufLjCBFzAKLGSU+7+9lBkkIC4RLv Ln6E6yBRUBV4vmlTSwgNq+ApcSUdV/B4hIC8hK72i6ygticQPG2w9/AbCEBC4lfE06wTmDkXs DIsIpRozi1qCy1SNfIUC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTI9DHDECwg/H PsoBDjJIcTEqivO/WHY4U4kvKT6nMSCzOiC8qzUktPsQow8GhJMHLuQkoJ1iUmp5akZaZAww2 mLQEB4+SCK8rSJq3uCAxtzgzHSJ1ilGXo+Pm3T9MQix5+XmpUuK85iBFAiBFGaV5cCNggX+JU VZKmJcR6CghnoLUotzMElT5V4ziHIxKwrzPNwJN4cnMK4Hb9AroCCagI7I3HAA5oiQRISXVwM ig8tn3gsGEzFd9aaxzXmdx2tUanj69Ubk8o23/s3/vF3ieP1Rq86rG/e7fm//0+haJbZ9RnZG cdFZ4hx5/47+8o6FPckxrTXZeZxXI/OdywKLcwIPXhyfj1VPte2tbF2U4L33I9sNKT7jmtVT6 R5WiulvOggybr8n/CtQuyV2qm7IsxrbYSomlOCPRUIu5qDgRAJv57K53AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1505997661!117568586!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 49746 invoked from network); 21 Sep 2017 12:41:01 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-27.messagelabs.com with SMTP; 21 Sep 2017 12:41: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 EADE41529; Thu, 21 Sep 2017 05:41: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 DB6FF3F58C; Thu, 21 Sep 2017 05:40:59 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:32 +0100 Message-Id: <20170921124035.2410-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 13/16] 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 --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 0dd0f0a083..5c79444d7b 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 Thu Sep 21 12:40: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: 113254 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846153edb; Thu, 21 Sep 2017 05:43:05 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCQoEF0mb/RV+4G2/Vuf0zn+fqvzYiFV8+hhSF7wbS9cwHK3OaPJmZ6qLnY5pkxJ/V6lJzG X-Received: by 10.107.107.17 with SMTP id g17mr2673758ioc.126.1505997785486; Thu, 21 Sep 2017 05:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997785; cv=none; d=google.com; s=arc-20160816; b=ytKJdgxrHkYSpuDawCQL9jX4HAM27vMTaFdpeEIrmfmjdkEWl+KhZAqtshtNfTGZo5 qpDhLC3eg9U6DmMHtZjT+QmEs6OS5spfUj7TRfXPT3V6/YwzWstVoQL3pniShpwnZo66 V3O5YdgCLKrHMDKltv+ERXDBKy4kOze/67aPNY0OSOwtQlnescBL1v0PJ6ognahss/aR Q3v219vM8/4CRtgzIaA07XsxcybD7yPJYvmLgqK5MIC9s7yVF3ny5VGoext6p+91wyCT Jqan2nH5D56jVvBcc7cuJfA2FnlaTpbDuvz9g4ITXNHcBuZxCCytDTGHARspD+YWpNfI aFYw== 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=eZxolKHnEN0FIzbRnZVf8YYlbAmI9F3VUodb+Hq2lmo=; b=Nvti4dguXU1xz9SrLL6TTnPOCwUUpEeer242286kgM+e4WTXOejLujRbRx/G3X6qz1 px1psZrZjgX7KpmjHcd3BHRMSIcEqFAY98dXqDuNSvHprWqmuWDsOBPFWVWCwzb+H0+2 6viWBcj1sAbSyBnnONd1l8xJOHBVPXH6nb+61p7z0+XD8QyILz8Yc25GTw1NgcbLm9tr dwar1EXq/GIxBVIa/Po5Pj1oxTNIQTooJ1NQdiyYhJz90RKlbVkzNfGp15AdcLBlGApo 98nSJB84IL5eIoASML1Yc/ynJn5eVGeJD3ZsF9aEhl0QZPEohyZk0s7xodyfUR3smjLg +b8Q== 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 b1si1073351iog.131.2017.09.21.05.43.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:43: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 1dv0mw-0001Wk-E4; Thu, 21 Sep 2017 12:41:06 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0mv-0001Uy-Br for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:05 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 59/5D-02226-063B3C95; Thu, 21 Sep 2017 12:41:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTd+8+F Ig64TjBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a3S43sBR/EKn5/Ps/UwDhDsIuRi0NIYDOj xOfPh9ggnNOMEpf7XjJ1MXJysAloStz5/AnMFhGQlrj2+TIjSBGzwGKgjv29zCAJYYEMiTunH 7KD2CwCqhItjzoYQWxeAUuJ453dbCC2hIC8xK62i6wgNidQvO3wNzBbSMBC4teEE6wTGLkXMD KsYtQoTi0qSy3SNTLWSyrKTM8oyU3MzNE1NDDWy00tLk5MT81JTCrWS87P3cQI9HE9AwPjDsa +vX6HGCU5mJREed+tOxwpxJeUn1KZkVicEV9UmpNafIhRhoNDSYI3YBNQTrAoNT21Ii0zBxhs MGkJDh4lEd4mkDRvcUFibnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR5zUGKBECKMkrz4EbAAv8So 6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeZZApPJl5JXCbXgEdwQR0RPaGAyBHlCQipKQaGK d6Opya1FK1JcBR9uzH2Z8ttxya0HbGeWbbvJofCxouri18df1H1pPqoxGhrjf615+zvqC5cGP I3Z2Ti1OO/RLw8X6jqyEU4edUO3PaubYYM0OBpncFguHCu1/ZrredKr/pRayAKve1j4dcD19Q yPSuMuM43fHnhdT5yrCL0Q0LJuxramlvZlBiKc5INNRiLipOBAClw8tsdwIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1505997662!99078187!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 30416 invoked from network); 21 Sep 2017 12:41:02 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 21 Sep 2017 12:41: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 44E1B1682; Thu, 21 Sep 2017 05:41: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 359E53F58C; Thu, 21 Sep 2017 05:41:01 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:33 +0100 Message-Id: <20170921124035.2410-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 14/16] 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 --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 5c79444d7b..311762b1ce 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 Thu Sep 21 12:40: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: 113247 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1846011edb; Thu, 21 Sep 2017 05:42:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDUzG83mI5Klby0UGC/QiVxw6mJYunR4u6f9m2mTIgJJpae38AaW5GkfE+VKA63HxUcCuye X-Received: by 10.36.58.149 with SMTP id m143mr1351952itm.4.1505997776962; Thu, 21 Sep 2017 05:42:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997776; cv=none; d=google.com; s=arc-20160816; b=JgcA9bQQma2LsdFYO2ovgs7LOQoIVHUd53LQnQrNEM0jQQXMXicF4Sv+DRsRqHWXpo Lx5WFgxXUMgxr73I0RXmqLoodYmlZbtqcFdH3KWtTB5CiHIiBN5SEQVmV7pqa2DHjfSW t8kT3uLgtPlEoZyHd7u4oMmvM9+ZYP8g4pKD1UrxrCQq9IoFID4rqBtUo6XdiGYPUnp0 bsIQuEUx6v1md2fdkFxicVoep8HhU9rAGLMrDhS6kIUP8asbGlI/1imsHCpk4zXg8JZ6 2eGvGlheJ5LK6ChhQBIRIjQnjOCHYZvu4/LlZR6fTFr0tpXQXNhalZTLsz1ixFtEX36q 2ldw== 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=GvTfBOprxfa7sbX0X2+TJ0SxFhucPpUMNie5/Hth55E=; b=QZCsb//y3fbt77OUId1CAN5wPxoti8AS57OlptRsqM+gi1Oy4zyJrTqklSNK1gEbJE h6urHxZWCDQZYLqCshPVzYGOe/lyd+jxZhmy4J2go9Ozpwt9n5Fa/t8iintcLND9zNog 6rwipcxtAHSk00PQkmERW4sMTkVcavQsVt9CdLmqQjDHh6sx4RP7lB/u+GCGhua1PzbO vAp7VIUPbBv8YQOrAuIJ7DiDJ2gXsIQ4rnGbXLoxUDl9ev9JPUFcIRvvhr/M/6Yk1w+N KccY5Ub7St+VmNIJ31N//kfrY5YsDiYs7P59pfQeuy/HgR/5pQvq508xnWM6jNG0xSXq 6mjA== 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 h130si1130754ioa.94.2017.09.21.05.42.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:56 -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 1dv0mx-0001ZT-QT; Thu, 21 Sep 2017 12:41: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 1dv0mw-0001W9-Ma for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:06 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 89/3A-16615-163B3C95; Thu, 21 Sep 2017 12:41:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCLMWRWlGSWpSXmKPExsVysyfVTTdh8+F Ig6ktUhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8benk/MBSfVK04euMvYwHhbpouRi0NIYDOj xIfLV9ghnNOMEscm/AVyODnYBDQl7nz+xARiiwhIS1z7fJkRpIhZYDGjxOf9vcwgCWGBcImfi 9aBFbEIqEpMnNwL1swrYCkxa/5NsLiEgLzErraLrCA2J1C87fA3MFtIwELi14QTrBMYuRcwMq xi1ChOLSpLLdI1NNBLKspMzyjJTczMAfLM9HJTi4sT01NzEpOK9ZLzczcxAn3MAAQ7GI+/jzv EKMnBpCTKq8N1OFKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG85L1BOsCg1PbUiLTMHGGwwaQkO HiURXm4+oDRvcUFibnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR5e0FmCIAUZZTmwY2ABf4lRlkpY V5GoKOEeApSi3IzS1DlXzGKczAqCfPeApnCk5lXArfpFdARTEBHZG84AHJESSJCSqqBMead1D WvsNk5p3/kaB3nyyoIaPfTVlI6b7lD/1CiWmdnfNdD/sa1KVIsuWXale+mvkz5GaLxLOvU7rR Zq5ubDN98OGP7jk3+7gXjLXqpPCemsR3iXtYn+KfpY/1+h+l50hVWfCJCMk/ZpNhufzXhyd6t XM9dd9moLGiCzOvHF2LuqxblrM1UYinOSDTUYi4qTgQAQlf5THcCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1505997663!117078355!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 61698 invoked from network); 21 Sep 2017 12:41:04 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-4.tower-27.messagelabs.com with SMTP; 21 Sep 2017 12:41:04 -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 9315D1684; Thu, 21 Sep 2017 05:41: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 83CA93F58C; Thu, 21 Sep 2017 05:41:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:34 +0100 Message-Id: <20170921124035.2410-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 15/16] 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 --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper 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 311762b1ce..89b7dc949d 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 From patchwork Thu Sep 21 12:40: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: 113239 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp1845818edb; Thu, 21 Sep 2017 05:42:42 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDt4PTkTCzb6tnga0l5Xs33oadq0DsW6QZu7Jf2gMBbFm2pkQPZ16eJELqZQiE1ImnffUds X-Received: by 10.107.30.77 with SMTP id e74mr2701578ioe.277.1505997762707; Thu, 21 Sep 2017 05:42:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505997762; cv=none; d=google.com; s=arc-20160816; b=AL1XWdSCPnADzwM9t7ObIMI1c2pkgCdPSOOghOrdbnLDdmErOdOCkB3kECRd+nY+6V nUWXqBWIgKbuU2147UKdRuDj9EyZ+gvFND/LjOdhVczDo6P1G4VTkSrU6AnsYiUs0dZW tH8tO5fdQ57cagNLfpMqZwFQLmItaTQjfYYYyfnfKUpUVHOm9tgLz4Kaz3ZeO3Kxrtbi gqfKDAfPDzxY3luamL83jvIqihBDAUuUHWUgPq2weyDFks/QbihBqhoDQd2FPIe0EpZ9 Szn/pwnqY+86E8TYHiAyZUvq1ziA/j+dKCaMgHBy6rtsyk9WTNE4AmSo1ses24eUmblY RP2Q== 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=siMcxVkqcJeNGRCluSZWrme+k13ceKTTu3M5yXKhTd8=; b=Oe3DUNbz8Wbhxd4CQ/d60mRDyakLF+B/XUYt9dSoN8GjX2fBg8TgN6krpD5fog09sb LsAffT9uj/EBADmQcI7aJiD0idFeiiO7ljvdVd5OCpy3ZDW8pQVQe34pxuqvCDgwko34 rZSabU7miCUT5L+J9Jrv0xn1JlX+NAtMbRgfCGHBYVLHGkoD8nf/nJ9E1hEoL4WtrwcD RWiAwSN57RfTb6nbkGdiRovf/qPpnbH/WFKKQO6RuaYPMtE/IGumGhkRL7KBxSC+oE9x cJInGKTVmf8ZTX34Wvppfp1V8p7rh7QRW1P6O+CO485/yop77xeNwDxuvEW3tTf+LM0P vRDQ== 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 k34si1126890iod.151.2017.09.21.05.42.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 05:42:42 -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 1dv0n1-0001f5-8Q; Thu, 21 Sep 2017 12:41:11 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dv0n0-0001cV-Bk for xen-devel@lists.xen.org; Thu, 21 Sep 2017 12:41:10 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 44/EA-30935-563B3C95; Thu, 21 Sep 2017 12:41:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrFLMWRWlGSWpSXmKPExsVysyfVTTdp8+F Ig4fnWCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oyplw4zF2xgr5j3czZbA+Nf1i5GLg4hgc2M Eu0vFjJCOKcZJboeLWLuYuTkYBPQlLjz+RMTiC0iIC1x7fNlsCJmgZ+MEoc/v2IBSQgLuEgsO XMRzGYRUJWY2XIAzOYVsJQ4cvkb2CAJAXmJXW0XWUFsTqB42+FvYLaQgIXErwknWCcwci9gZF jFqFGcWlSWWqRraKKXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iRHoYwYg2MF49rT nIUZJDiYlUd4A98ORQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR45/oA5QSLUtNTK9Iyc4DBBpOW 4OBREuFlAUnzFhck5hZnpkOkTjEac9x4eP0PE0fHzbt/mIRY8vLzUqXEeZeClAqAlGaU5sENg kXBJUZZKWFeRqDThHgKUotyM0tQ5V8xinMwKgnz7gaZwpOZVwK37xXQKUxAp2RvOABySkkiQk qqgXF69Hb7wOkFR0T6L0tveCx59OuM65zTbX6qrVV486DGZF//y/zu1QIMYbqR0mVfF5YKXxK QWRH9KebS25VOd09E2Eb8+BT+3PTokewgtcOPDu86qhIvrNpb9rU1aVpyntbZCzfjnJfen8s/ d6X+UtvW3z7LpgesEnhgXbQrrz3V29twb9itmUFKLMUZiYZazEXFiQDIhwbBfQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-206.messagelabs.com!1505997665!97126729!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 43454 invoked from network); 21 Sep 2017 12:41:05 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-206.messagelabs.com with SMTP; 21 Sep 2017 12:41: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 346471682; Thu, 21 Sep 2017 05:41:05 -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 D22473F58C; Thu, 21 Sep 2017 05:41:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 21 Sep 2017 13:40:35 +0100 Message-Id: <20170921124035.2410-17-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170921124035.2410-1-julien.grall@arm.com> References: <20170921124035.2410-1-julien.grall@arm.com> Cc: Tamas K Lengyel , Razvan Cojocaru , George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 16/16] xen/x86: mem_access: Fix mis-indented line 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: Razvan Cojocaru --- Cc: Razvan Cojocaru Cc: Tamas K Lengyel Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Changes in v2: - Patch added --- xen/arch/x86/mm/mem_access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c index 948e377e69..5c1008890e 100644 --- a/xen/arch/x86/mm/mem_access.c +++ b/xen/arch/x86/mm/mem_access.c @@ -274,7 +274,7 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m, } return ap2m->set_entry(ap2m, gfn, mfn, PAGE_ORDER_4K, t, a, - (current->domain != d)); + (current->domain != d)); } static int set_mem_access(struct domain *d, struct p2m_domain *p2m,