From patchwork Wed Sep 13 17:59:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112460 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226464qgf; Wed, 13 Sep 2017 11:02:17 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBPIgYKNtUFMGP8GURy4BRKx92pnszl+fvszX+Dp0SZPwlChqGaAd/bI/+PhLw0qMhGJzxf X-Received: by 10.107.17.39 with SMTP id z39mr26262945ioi.170.1505325737253; Wed, 13 Sep 2017 11:02:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325737; cv=none; d=google.com; s=arc-20160816; b=QZ6Pjnvjk97YtbW0EKUn6PFATat5VD5drNBteTHfsmUkEPF/KDNiHu3Ffk8zjVEtXP x0zdtbhXT9/2QLUBxJR4MbMg4hbDe9fGfWPaZb7/7Ua5bcKf+MC6cTOnOg1HBTiWRffi lUhWuMYBUjG0zAcZarZtQLi3YVLyHObtaT1Fd5PG7slDu7tw27Oi1I+Hpwli6vIcVzXL 9STBi6VoNQe+OfBEUqhiiLJjn3veQomMOgXQK5CCJELCzpiNcfgD41PzLo4sSs+TTH0A jQKpr/PKP+xLMPZvXTIyTVox1ZVPm9HrJ3WJARfRmphetuI/Uvzm2L9vktecNGJknLBb XcFg== 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=oX5kWVT0McM/qR194u8e1d0l+vzZnvnLf8Yl9xn91r8=; b=cBXDRw/OrOCyV+u7Ow/RdWcI308WBfqZohcMh24f3oHKVLMikxJyXIM2KdLOh5faaE 2r4TdgrHOYLcNYy+Q7qo5ogXS8LyA0l++PrfHzL9nIOVOewcrwesK2VS5zHuzGUgev0A +n8gqgKKe771Ud54V2qNWNfcQqNARaHxSvbtcF0efwYihW0rxUTi8wCqtWyW4EHhN0IA v5VjF/Dcw0W9Z4lSmfXdk+gRj5Z0tS3U1ghCO/yD4BNZ6jKEmUmFV6vtaUx7rVYm0aUb b6pxx1YSeDH0MSibX/8FghRGVp2lA1SRdj5FXFauIhtNF20NyCXwba3t91ufadkTWVEj Rq5A== 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 p74si1781034ita.205.2017.09.13.11.02.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:17 -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 1dsBxF-0007mi-VG; Wed, 13 Sep 2017 18:00:05 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxE-0007XZ-4Z for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:04 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id FD/43-02224-32279B95; Wed, 13 Sep 2017 18:00:03 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrOLMWRWlGSWpSXmKPExsVysyfVTVepaGe kwZuLehZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bX33XMBTc4Kk5c7WZvYLzC3sXIySEksJlR 4tqvoC5GLiD7NKPEo7WPGUESbAKaEnc+f2ICsUUEpCWufb7MCFLELLCYUeLz/l5mkISwgJXEi b+zWUFsFgFVidvrF4HFeQUsJS4fu8ECYksIyEvsarsIVsMJVD/z6wKgoRxA2ywlTvdETWDkXs DIsIpRvTi1qCy1SNdQL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj0LsMQLCDcfl Hp0OMkhxMSqK8e3V3RgrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4JUoBMoJFqWmp1akZeYAwwwm LcHBoyTC+7YAKM1bXJCYW5yZDpE6xWjMcWDClT9MHB037/5hEmLJy89LlRLnXQ9SKgBSmlGaB zcIFv6XGGWlhHkZgU4T4ilILcrNLEGVf8UozsGoJMy7FWQKT2ZeCdy+V0CnMAGdcub0DpBTSh IRUlINjD473U/Lftxw5ewB3kM3+n4Vulp5xW++bpJcm3s6NNzs/ML9TAa9d+/MTg9NuvR8Qr0 Vf8yf2P0z1E6f7ewICkqZ/OPA1Lk5PTciVvx/GVt8SYHV9mnybmGBTonGeyLRT+4VvVE/tIbd XOP2JP6LH7o1BFe4WGtcPS98UoJ5qtST+wIVIbKrryixFGckGmoxFxUnAgCcLIeNegIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-31.messagelabs.com!1505325602!97847565!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 37533 invoked from network); 13 Sep 2017 18:00:02 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-31.messagelabs.com with SMTP; 13 Sep 2017 18:00:02 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 020F21529; Wed, 13 Sep 2017 11:00:02 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E46153F483; Wed, 13 Sep 2017 11:00:00 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:39 +0100 Message-Id: <20170913175953.16942-2-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 01/15] xen/x86: p2m-pod: Clean-up includes X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" A lot of the headers are not necessary. At the same time, order them in the alphabetical order. Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112466 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226607qgf; Wed, 13 Sep 2017 11:02:24 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCy8Es7rkLw2azlUH1tC9yqdoi7UjS69uBal4XjQShn+hvR94RijjcrKWMtwE/A/GqEVwsQ X-Received: by 10.107.46.160 with SMTP id u32mr20472898iou.291.1505325740810; Wed, 13 Sep 2017 11:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325740; cv=none; d=google.com; s=arc-20160816; b=gIe2E7kTvZfn5kn7PxkUJsLTiEKzG3AUE7oq6R/yUowL8Q5g05WjlNC+OY/LFYXBgD v4x6lvk/FBfePgp0HcPJQMnVyAmG4VTkHPdNIzyhHPg4mZxrraTcNCA8kwyQW8faJEhr WyYRhPzDagEAUhCXxuAB415dUIrF4EZHkvrIkDl4g9g4DwXQn3rdgQ1VbrNrZOLREQQZ S+tjrfkYly7XZwCrQ2VmzZmAGzXoKfznzH0+YpOdB08E0GZsVPXOIT4L6rEO1y+qEkZY AwvxYoW2SSYPZhQydVX4z3m/kLokNL1sTZI+AjXxChprnDNR3Ozl+QTz9wiSFRdnItju v5bQ== 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=0+GJ7B2w0kjrOGzRDKa0e30cl7Rsglh7cDC1tc8ZZ/4=; b=UOAZm0CdqUrinH8g8iYGIcyIYaBVVFVBC4/ZRQU1Mi0i5bLcXDdsz55dsB4dIglc+5 wzLLAls5Y9kYtU2t0OZ/2vE/XLRvMKLpVBB7j5kVYzxNAG1w19kExhdUfIH5uluM1FX7 f2z9x63df1c0eLaMxqcpf7/x2sDYxCPUKEMJ5gSLVeP1l/fTlFxEoz6PNaTQW48OgKrG apanql71+K2U4BJE74V4zdCqYEYUPI6CqiQL/DL2iJjLKnVez4DixVM5aVW23xRxMdmG 9UbD+4i0bTJqjBTezYxJGXkqxn/rOaFv8xAYE8t6jrFJvSHZ/mn07RPQAiXmDTHImZ+q NoMg== 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 o19si1834737ita.48.2017.09.13.11.02.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:20 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxL-0007r2-Vz; Wed, 13 Sep 2017 18:00:11 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxK-0007q5-NU for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:10 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 49/F5-03414-A2279B95; Wed, 13 Sep 2017 18:00:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVelaGe kwY7XwhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0ZL6xKWgntmFReerWRsYOzX6GLk4hAS2Mwo sXDXSiYI5zSjxNUFD5i7GDk52AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b1gRcICLhLT/ 7aDFbEIqErs7DnGCmLzClhKnNk2mxHElhCQl9jVdhEszilgJTHz6wKgeg6gbZYSp3uiJjByL2 BkWMWoXpxaVJZapGuql1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6F8GINjBOP2 y/yFGSQ4mJVHevbo7I4X4kvJTKjMSizPii0pzUosPMcpwcChJ8EoUAuUEi1LTUyvSMnOAgQaT luDgURLh1QZJ8xYXJOYWZ6ZDpE4x6nJ03Lz7h0mIJS8/L1VKnHd9AVCRAEhRRmke3AhY0F9il JUS5mUEOkqIpyC1KDezBFX+FaM4B6OSMK8eyCqezLwSuE2vgI5gAjrizOkdIEeUJCKkpBoYGV MuHhc4YRGQsv+GVeTVtyGLw1Z/e5V6f61lTV5p05Xf89cm7J/01u/b0pc2vSHLNl2e/GTF801 7vjA9WnKt8uhquaDHLYv5rOft2twsJ3+qWFS1+tv6ov2CB7dN8rI2f/Y8o9jGgbfwTMqviLs2 3po6FZlBEh7+i3w+76qtaz6kdORVyl/Fy0osxRmJhlrMRcWJALjVzZ11AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1505325603!76068280!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 38330 invoked from network); 13 Sep 2017 18:00:04 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-21.messagelabs.com with SMTP; 13 Sep 2017 18:00: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 4FB3215AD; Wed, 13 Sep 2017 11:00:03 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3E06F3F483; Wed, 13 Sep 2017 11:00:02 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:40 +0100 Message-Id: <20170913175953.16942-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 02/15] xen/x86: p2m-pod: Remove trailing whitespaces X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112469 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226744qgf; Wed, 13 Sep 2017 11:02:30 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCjdQlAFlpekc5E+TUCf/B5Nq3zf+gopPx95HesBywTSRNrVVLXiuEcNV9f8jSV0ATjk0tc X-Received: by 10.107.59.140 with SMTP id i134mr16074588ioa.153.1505325750222; Wed, 13 Sep 2017 11:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325750; cv=none; d=google.com; s=arc-20160816; b=UXZBTOadZd4YGHzIIQkRoShlYa967ijWowLaqj++CQZijp8j+s05jVA4jN+oZc8EvS j8ljbDU7Jw9IcXL3MdPavhBwSWVTQCsT5JqDVG/ZKu0TxE/A8OC98ZlBYQmI4Lnl2mYL 02llgPfrkZb264KA5qIhQ4BU9avqa2iWzBnTzWpRZybR0U+V8jaTO8pA4iWMF4fzg4Y7 OqoGXG60yB6PKD8fbUF7RZTiVYj3x5n+ML1eZPQm4sMoereCRqi82dYeL6W+Q3LbiYRo q7UHo3dCW1Lbgm0vKZOlwWZejDjZS9qmArLSUwwAEd8fjpgbRu8raN4NnZUljviQwPmp U2XQ== 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=1mA5CSfVWriuGrW4pSdCwmjzOPGGfnQwzA8iDWmaZ04=; b=DYhyvLjZLptGLi6LVrcDb3ML9EKSYf3wQU68qRffYq6C2DWZNjgL4VFK7QAipaB5qX pKkPA1mERi17WK0cxJxQoj5AKd2p1DzGXuCm1Tu8CvTA16EG/XfdokmqISGx8qUJRlmE 1G1ubD/TMtLqWLoPdaNBVUxFgN+cBKIO4aUbaA272YvgFrco69ECiTAP5ZQw0R+jQ0VI bM/lRIpU63faMtErCtsU6KkLcnDTgZf/UkDr/oljLF3jcTkxrpc9jwN9eS1l865TVuAS ANZfmhQcrnU2C5rvtyXq5k9dzhBn1fZHFWYrL3eE4RyfcHdore+XWHk9zPNEU5oTNpui JofA== 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 q123si1459173ita.151.2017.09.13.11.02.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:30 -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 1dsBxK-0007q7-K3; Wed, 13 Sep 2017 18:00:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxJ-0007pb-68 for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:09 +0000 Received: from [193.109.254.147] by server-10.bemta-6.messagelabs.com id 89/F3-03642-82279B95; Wed, 13 Sep 2017 18:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVysyfVTVe1aGe kQd9Tc4slHxezODB6HN39mymAMYo1My8pvyKBNePhkQPMBRNyK1q372FsYFzn38XIySEksJlR 4vw5ny5GLiD7NKPE9pet7CAJNgFNiTufPzGB2CIC0hLXPl9mBCliFljMKPF5fy8zSEJYwE3i2 vZmoCIODhYBVYlJHbUgJq+ApcTta8kgFRIC8hK72i6ygticAlYSM78uAKsWAio53RM1gZF7AS PDKkaN4tSistQiXWMDvaSizPSMktzEzBxdQwMzvdzU4uLE9NScxKRiveT83E2MQN8yAMEOxr9 rAw8xSnIwKYny7tXdGSnEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgrerECgnWJSanlqRlpkDDDKY tAQHj5II73yQNG9xQWJucWY6ROoUoy5Hx827f5iEWPLy81KlxHljQIoEQIoySvPgRsAC/hKjr JQwLyPQUUI8BalFuZklqPKvGMU5GJWEefVApvBk5pXAbXoFdAQT0BFnTu8AOaIkESEl1cA4+2 2h9Mvs/3M/XrmXKXxQaiPz6dUJlw0XZT0OPZCyK6JwS8b3m3Yfyi4J7G+Ze7kheG/lnuV9sp8 eZN/84Nwg9WLJi7XbNx7rfZrocr9mevEt5dzJ6zMvMYVwtt9+5vWqPmaLYtaj/6vDa7mCKh40 Po+f6KvHfnz6RFPerda1BzRa/51kYD/1XImlOCPRUIu5qDgRAIBmaqtzAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1505325605!116688105!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 30550 invoked from network); 13 Sep 2017 18:00:05 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:05 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C0D711435; Wed, 13 Sep 2017 11:00:04 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8BC043F483; Wed, 13 Sep 2017 11:00:03 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:41 +0100 Message-Id: <20170913175953.16942-4-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 03/15] xen/x86: p2m-pod: Fix coding style for comments X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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: 112471 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226784qgf; Wed, 13 Sep 2017 11:02:32 -0700 (PDT) X-Google-Smtp-Source: AOwi7QD3CtWFHfsflg6PdgeCo7TSB5k//MVRKS5QCUtEo72eYuzy5011WjfmqN+PPnV09A/Fr2oG X-Received: by 10.107.134.229 with SMTP id q98mr25711801ioi.262.1505325752307; Wed, 13 Sep 2017 11:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325752; cv=none; d=google.com; s=arc-20160816; b=XWeeXyRq3kpwpDq7skutpn6+7EIqfRVPZ6tfZehy1RbOd3ZBi1RjYaaZt1FteuYm+5 ukh/GnzlSGtj4uInSDosZZwZ6T+RLdgCjZqvwMXBH9wOaWEjrKC7AMClavUfP7Kg++zZ ZSwh+hDuFy0HMEKwVMPmvF0p7MMQDka0p9+6qUS4mXYNW8fCcFX3cQUz46vBWuS16S4C 57hsibsROQyZWpVEdKEnzqFo0+a9RyIy7uB15ja+LymF3AgMrs12CMrcMYe4LYBL6Bcp V27mEr2/TVeCvwxiVyzEE3rrIXkzV4y3Pgmcsnu+YwEdCvuSMZVT7WlLYJV4s+XQdeE4 Hv1Q== 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=b5xhzfLees1nz1PrN5MjgZYp8xCht0S/Z8cIoT9u3T0=; b=AYgdK9y0oOvFYtBjpQ7RwB0vDLMkbEz56W0LrlBzdqFmlJiSUs5Ou0wsW5+RlOoE2e JqQbOozzm+/DavlAJtkUnS6hCzXTMW050xPVs10yPeSVps1LLq/jvgegENigFDCn60TQ sK9fC1vxlCV3RbSuJ+1vSs6yi9yfRATdTUPsmSKRNHvm2A8eJwj24QAlLf3APv0j+m5m GEVGMzZ8TTsdMi9ngzw06vojqkVE8AKAqT4UEtJPKDKtoN6XflOEkZdPoQtK3ChBget9 ZI1yxW+nVdkXfPMmECCxVxzO/XMxQnDXj69EouE+vTfYaQqMdW5XuI0u855URN0AKGiu jgHQ== 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 q128si12484865iof.333.2017.09.13.11.02.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:32 -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 1dsBxJ-0007pk-D6; Wed, 13 Sep 2017 18:00:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxJ-0007pa-0C for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:09 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id BD/3B-03616-82279B95; Wed, 13 Sep 2017 18:00:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRWlGSWpSXmKPExsVysyfVTVe9aGe kQdtWcYslHxezODB6HN39mymAMYo1My8pvyKBNePut0ksBX3pFd8Ob2RuYDzu3sXIxSEksJlR YuPCWWwQzmlGie9r1jF1MXJysAloStz5/AnMFhGQlrj2+TIjSBGzwGJGic/7e5m7GDk4hAUsJ Y4dZAExWQRUJZpbdEBMXqDopDNKIJ0SAvISu9ousoLYnAJWEjO/LmACKRECKjndEzWBkXsBI8 MqRo3i1KKy1CJdQ1O9pKLM9IyS3MTMHF1DAzO93NTi4sT01JzEpGK95PzcTYxA3zIAwQ7Gb8s CDjFKcjApifLu1d0ZKcSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCV6IQKCdYlJqeWpGWmQMMMpi0 BAePkgjv2wKgNG9xQWJucWY6ROoUoy5Hx827f5iEWPLy81KlxHnXgxQJgBRllObBjYAF/CVGW SlhXkago4R4ClKLcjNLUOVfMYpzMCoJ834DmcKTmVcCt+kV0BFMQEecOb0D5IiSRISUVANjse qX1XIP5I/5+wVq6YvrWn3PmiGQmCZb8eCnvcqHFb673dJ/tht3nza1eHz3/rQZ0k8Frs5PXz/ zxwJX4YlRnGF7b4ifNDR6nLhjnSzPE6fnMd953dsMf+/80++YucPs9jP3XxWact7eRWWmc9re H3m4PG/Sk08H4k++Ybq4eN7kUy0P75ffVmIpzkg01GIuKk4EAMVmGxlzAgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1505325606!116688111!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 31118 invoked from network); 13 Sep 2017 18:00:06 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:06 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1AEF8165C; Wed, 13 Sep 2017 11:00:06 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 08AE83F483; Wed, 13 Sep 2017 11:00:04 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:42 +0100 Message-Id: <20170913175953.16942-5-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 04/15] xen/x86: p2m-pod: Fix coding style X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Also take the opportunity to: - move from 1 << * to 1UL << *. - use unsigned when possible - move from unsigned int -> unsigned long for some induction variables Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112465 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226595qgf; Wed, 13 Sep 2017 11:02:23 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCjZR4GetusZLzfA/KvHFsp44kG1I/Brgpsdr7irYj/DR+wa2gRyLx3+8YW39v+oi/0Vt3E X-Received: by 10.107.167.129 with SMTP id q123mr7458405ioe.90.1505325743683; Wed, 13 Sep 2017 11:02:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325743; cv=none; d=google.com; s=arc-20160816; b=UU/+MTxgoQ/wCcMN3eWorH0f3xfcmveUrMNHyN7V2ed0qgigludzob45CsBcBcHjDL hx/DCrHWHnncTE4VBs3WoHR0noiK2hSTh3serVbbrjs9Mw/TkyC2Ijmji2kV2P8lDuYn qxzWEIA18liUBbjn7JXVSnuvhmpggdB8lhdC/nxYZWZUxwxp23PQeYlhdNyeMKjJpnPi v7wtXVqNb+3tL7pq/aE+zk/V0f6UaqEczYTae0jDqsdpWwRJLFKJslNA5OG8IZpSpny9 GqbPJ4uATMyXJg2yS1pIJ72eIsLuCAoxGNddIdozrRVAIGzVNS5FgDlowASwGTJmdprj h/lw== 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=cA8RINJNvCgPxQeKyTDPiYL5ZaziesHbDw2yhqxhbpY=; b=FNCn2xTJsASEKXbgMbrTEJS38S62pfklQdPuUGFjfItkkIxZEsq15DhU4D6GKvIUJp hKRSUzFHaMyuR0oLMgSWrzepxSLyd83qFNx8QByyeRY1SDEPWmFU9fnt/mz58y3l94U8 i+/8le5y7Ds+2AOWg1ZU3jW2ZC8rnLX1pHCvawIONX6NdoW+d2vUSDWPMpDoN0Wg0UEm MGd9Xgk8BH4pBRlCC7ApIAsfqSfIetpd9ivYr0nm4YQaWCKmEWgo+5QEUcDN9vST+m5M MJBszu4B4h+volOLJ21RBRXMi8veULpkzpkYVlMCRiEHOP8Co9PLqqXtQcabTaZf+lm9 Vc0A== 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 w8si432869ite.79.2017.09.13.11.02.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:23 -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 1dsBxM-0007rF-6Y; Wed, 13 Sep 2017 18:00:12 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxL-0007qG-4l for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:11 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 81/76-17770-A2279B95; Wed, 13 Sep 2017 18:00:10 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVejaGe kwYEuDoslHxezODB6HN39mymAMYo1My8pvyKBNePD/7vMBQ/5K3p2X2BrYFzK08XIxSEksJlR 4vyvtSwQzmlGiSvrOxi7GDk52AQ0Je58/sQEYosISEtc+3yZEaSIWWAxo8Tn/b3MXYwcHMIC8 RIH1pWA1LAIqEoc2nAOrJ5XwFLi1JYPbCC2hIC8xK62i6wgNqeAlcTMrwuYQFqFgGpO90RNYO RewMiwilGjOLWoLLVI18hUL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMj0L8MQLC DcdWCwEOMkhxMSqK8e3V3RgrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4JUoBMoJFqWmp1akZeYA Aw0mLcHBoyTCqw2S5i0uSMwtzkyHSJ1i1OXouHn3D5MQS15+XqqUOO/6AqAiAZCijNI8uBGwo L/EKCslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYd5vIFN4MvNK4Da9AjqCCeiIM6d3gBxRkoiQkm pgLKvbc10o1l3tfmrSta4r8c9bWde3SancsS+ICpBdLmAvetjl91G2368vhhwqDT7wXeVnbPz Jztwa6TkmFx75/nbXZuyTahXSrme8fdH7ItuD/b03FvIXWvN4HX9S6CZy8eN0jQieXikVqdV8 RjmNxeoR2s5R645MMXJqN/iZYNy190FmUrASS3FGoqEWc1FxIgA91wS4dQIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-9.tower-27.messagelabs.com!1505325607!116688117!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 31535 invoked from network); 13 Sep 2017 18:00:07 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-9.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:07 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68ED8169E; Wed, 13 Sep 2017 11:00:07 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 567643F587; Wed, 13 Sep 2017 11:00:06 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:43 +0100 Message-Id: <20170913175953.16942-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 05/15] xen/x86: p2m-pod: Avoid redundant assignments in p2m_pod_demand_populate X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" gfn_aligned is assigned 3 times with the exact same formula. All the variables used are not modified, so consolidate in a single assignment at the beginning of the function. Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112464 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226577qgf; Wed, 13 Sep 2017 11:02:22 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBDo95aYZVHfnrGPWHmChLKY6u5qzDJfShU2t7brg3H70PynVYb4v78rSgd9PD1vGpba7/W X-Received: by 10.107.47.11 with SMTP id j11mr15332100ioo.217.1505325742724; Wed, 13 Sep 2017 11:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325742; cv=none; d=google.com; s=arc-20160816; b=KRfQFuaSJypdD0mFl6B4n2LNf4HwI7urE0xTcS3Wj5HrAdYsj/IR4ZnB0Gd4JNwK+9 VPgpiwJ/V4Nv2hi2N//Eg38Y/hdXi5zghdeb5w1PH2Vba6G+9dJ60jgP7Hau0rwrLlgF 34SsmOSJ6Psulstw1m/SHb8LcFS8JTuAGk8PZP/ZZO6DQfynuN/HIJCRsWpZC2OsvdR+ Amwa8DtChAGEvC1aF2VMrT7tHcym1d0Dto3QpnSaVEm2lFV9moWXX0ikkBUPcun3sA6E 6X8vIC6JM4D4ft1OUWxMlEaLjlChcNaGPwf9TTLc+6Ic9B9Megsy+l/xEoqwfA1JqSMN JU6g== 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=MYQJL4yYp/QQdVyNvCJPcX9/fwrlOxaqZVk4Cy9exIs=; b=pu/gmlPOBMl5yUjetVz0JDE6yAGXacIWPsoQzxzrlTjKcRzk3qw0Uyzxpej4rWaVwU mtojXNmKVfB2RYPs/XIWqPGwbMnX93kA2BFyJzQ+aGcORUsJ/IzKt96UActrTh0Yw5X4 uYEj+NEf2/elF6U0AAxTcAHu8fXEPCWClm+MC1GhCvtIR5S7JU/f5841DbAhgeLoKA9p O9xO0WIKfNlj1jSZxC2CkTMF7cMrrA1O/8ac2c6aTK6ISziKmQ8BuSdpTePaBOKFQJx7 a4RmvY2bleyV8DTzV5JZ0tIC62RCBfubejc1mexAvghq3jID+cb/+uq4d+cP2GYzlUZ+ 9LSQ== 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 m13si4978212iob.280.2017.09.13.11.02.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:22 -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 1dsBxO-0007t0-Li; Wed, 13 Sep 2017 18:00:14 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxM-0007rU-Rn for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:12 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id 34/94-15060-C2279B95; Wed, 13 Sep 2017 18:00:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTVezaGe kQd9maYslHxezODB6HN39mymAMYo1My8pvyKBNePm18tMBfuFKv6c2svSwPiIt4uRi0NIYDOj xKVjNxghnNOMElOXLmbqYuTkYBPQlLjz+ROYLSIgLXHt82WwImaBxYwSn/f3MoMkhAVcJVZPm sIGYrMIqErc/74XLM4rYClx4NphdhBbQkBeYlfbRVYQm1PASmLm1wVAQzmAtllKnO6JmsDIvY CRYRWjenFqUVlqka6JXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGoH8ZgGAHY/d l/0OMkhxMSqK8e3V3RgrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4JUoBMoJFqWmp1akZeYAAw0m LcHBoyTC+7YAKM1bXJCYW5yZDpE6xWjM8WPSlT9MHB037/5hEmLJy89LlRLnXQ9SKgBSmlGaB zcIFgGXGGWlhHkZgU4T4ilILcrNLEGVf8UozsGoJMz7DWQKT2ZeCdy+V0CnMAGdcub0DpBTSh IRUlINjJLi67zsJ80RMj4TNOtpyY8Z/q5rGl5WvPR7ePxSXV7Suyz72R8mXz3PtaWmx1R7t+H nU7Jrl6XUsL62dPNersLa/GjzTa5+k1mbMw/emZ1a7igg+9iQb9eyteHuV1NyVDdbyj0NS3g3 g2XTrcKNvEznIzbMc1X75soVsu3upMsFx6P8GA/GTVNiKc5INNRiLipOBAC0s28QewIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-12.tower-27.messagelabs.com!1505325609!115149528!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 27693 invoked from network); 13 Sep 2017 18:00:09 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-12.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:09 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B6AC81435; Wed, 13 Sep 2017 11:00:08 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A4F593F483; Wed, 13 Sep 2017 11:00:07 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:44 +0100 Message-Id: <20170913175953.16942-7-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 06/15] xen/x86: p2m-pod: Clean-up use of typesafe MFN X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Some unboxing/boxing can be avoided by using mfn_add(...) instead. Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112457 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226258qgf; Wed, 13 Sep 2017 11:02:07 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDGiCMFCvToVrNFP1hJg88XDYJZdxGOnQuOlJwlvwH4mcU/c6jVpZZfYa/YDG9Fmjgu9AyD X-Received: by 10.36.217.201 with SMTP id p192mr6522105itg.28.1505325727314; Wed, 13 Sep 2017 11:02:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325727; cv=none; d=google.com; s=arc-20160816; b=Z0wfYKCYzxlMoL4zN0s7/Gt03Q20af8vImiw1ULrdVQtBszxGUMQiM5r3GhkN59TxI oEd02zdI7u/lqmDpYMMMiir2lEeBbY+XIuTxnZ/xRwLgLrhrwL/mfD+83eKBXeqCgJ4j jDtUeb5oBl45ux10UxMUCvsWyuPY6qcszqc1t3pwWfZPVbzWK7yijY1DT89ejOcFtsZ0 x/rvOBrPAK2OjJ36yjNpbAhSNIX/B9+NaEBlB3YO3IaxxyJ3Hqi2rCsF1MJaGQpRaJCQ U7NIBu25P+TrNEz1iToR5ngaM8J0UXwNYH43H0hq8L/AlNrIlIUlGmaBKVL42gXFbPQ+ FRgA== 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=5DfXc3NyDsP+29Z8TpNGvhVLFA5wDa4UK73Zek8OGnw=; b=oWIOArYiWO/SZnhNfRQ2x2K7IHoTqfKDLnOnJVWRQT6zeSAgat2f8LYUVHnE8o5fTV eCNdmgGvJADF+HPAxDD5jvSOguIOYUG993J6FfIyMjij0Hu0ywvFEAlajJ1GMwryP3s3 KiACR77EaxiTGWDR8u3Nvo7Fg+/MLQEhhWCqendva9M+TRC12mepDCATWaXAHaFYCnRj qi/Qe6pchD/IjMWxwn3WL0Rn43wq1BvBCOybSegX8IAWzwxF35M1XPZsK6vIHa/uMum0 hL6O+DM4kjHqUG2baTq8aybe9BP2HlRayYf1/Ftah/dnuOxxqL3FgbjR2oRwR8YyAqed 62wA== 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 l22si13863690ioi.353.2017.09.13.11.02.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:07 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxO-0007s4-DO; Wed, 13 Sep 2017 18:00:14 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxM-0007qz-E1 for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:12 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 84/A1-02224-B2279B95; Wed, 13 Sep 2017 18:00:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTVeraGe kwfJV1hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aX3l3MBQ8sKo5t3MHUwHhWq4uRi0NIYDOj xLVdn1khnNOMEj03b7F0MXJysAloStz5/IkJxBYRkJa49vkyI0gRs8BiRonP+3uZQRLCApESy y/8AmtgEVCVeP/4LzuIzStgKfF23z5WEFtCQF5iV9tFMJtTwEpi5tcFQEM5gLZZSpzuiZrAyL 2AkWEVo0ZxalFZapGukYleUlFmekZJbmJmjq6hgbFebmpxcWJ6ak5iUrFecn7uJkagh+sZGBh 3ML467neIUZKDSUmUd6/uzkghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErwShUA5waLU9NSKtMwc YKjBpCU4eJREeN8WAKV5iwsSc4sz0yFSpxh1OTpu3v3DJMSSl5+XKiXOux6kSACkKKM0D24EL OwvMcpKCfMyMjAwCPEUpBblZpagyr9iFOdgVBLm/QYyhSczrwRu0yugI5iAjjhzegfIESWJCC mpBsboJ0uN1u94b5ClF9ibdy19l7jo1K73fwoLqkpkVvZovN7SYlLQUpNX/d20szzuu3OB1tR Mx0DLLDauK+WLDnq61TMr2i61bGLIMOtS+iFiYLb/Dq/zVjWBm99u3FQ5pFT1nbtmsfYRz1ix 9MP/62V3zE8oOXZt5+t2tvAdyUxHOq+VaDEuVGIpzkg01GIuKk4EAGFAb5J2AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1505325610!76107293!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 61644 invoked from network); 13 Sep 2017 18:00:10 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-31.messagelabs.com with SMTP; 13 Sep 2017 18:00:10 -0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 10216169F; Wed, 13 Sep 2017 11:00:10 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F29CA3F483; Wed, 13 Sep 2017 11:00:08 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:45 +0100 Message-Id: <20170913175953.16942-8-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 07/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_decrease_reservation X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 c484469e6c..e321d78818 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 aa0d60ae3a..3c511feee5 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 Wed Sep 13 17:59:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112472 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226985qgf; Wed, 13 Sep 2017 11:02:40 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCQPfH9axNq9qhzNmVYms2L7/9Uljmr/0oJdndfLVfQP4svdc5kEScOqLpDVF27GuwyRxfS X-Received: by 10.107.222.3 with SMTP id v3mr25885510iog.20.1505325760843; Wed, 13 Sep 2017 11:02:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325760; cv=none; d=google.com; s=arc-20160816; b=EKQ7Fuo0VWGUonZjn/tBO+6LHAYSYoKKwGTxg6NJEgolArnKzdpaA4oSsRT2IpQI72 24CjGqDuB+0Yv5Lqnm4EXeAghc9KHJfjPl0jj+EC95GXWgVdRppukrazUrV/anSORaNo Itb5ucT5/HEOcbhq3stlO9AjEYxqiIzuhX+zKkj+E+OZUZsgAsHhGXTv8L3Ncbf9TdLt AkTQYLxlx2MYiEny2SEfeTkWQE7x8eJQYXcI7hAXfYzVka9r0o26ej5/bvXYEJTU7iuD UGenosdA5KEtjAkasDc6IyRXRhcjNuj1963JB3vLc0qBnkiitksKEaFQCiIP9bNmxV8F axTA== 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=V5aj6yF6F/9ZwvLYFwDUn1j45JBur9xy3LcxKPx+QRE=; b=y6FWrldLOoOd2wEjZMWaeAMJLCaU7ERmtSoStc70MaL7/v0DMzThWOQVfEMpgwvkTD SZNyiGX0DJq3dnoeATUZdTNlKIidLLRRVSaQs7ZlNcxzEePOyzdOu78s70FC4/21s5pF hvdyMkghv90/g7MtvZS6XbX5gCCBEdR/KHqZA7X71Bw01ixfiPaeB4ubyQh+c+5Z7mM9 t9o1cSThP2GDsc4CtLypg/0v1LPN/SguqeaOMfR9yLEV6MVogJ9mljNwCWlmF7T/JIhQ hEgnJsUEIYwkTzjk/adJLJWb9sW6QI62m+RonmGQLBb3lINS0IW7P7OFvVyr3KV/NP0w aCKg== 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 y140si1782689itb.88.2017.09.13.11.02.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:40 -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 1dsBxR-0007v1-09; Wed, 13 Sep 2017 18:00:17 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxP-0007t9-87 for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:15 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id A0/48-01916-E2279B95; Wed, 13 Sep 2017 18:00:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTVe3aGe kweuFohZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8biaSfZC2ZsY6z41f+XvYGxq4mxi5GLQ0hg M6PEqhV7mCGc04wSu48cYO9i5ORgE9CUuPP5ExOILSIgLXHt82WwDmaBo0wSe1p2sIIkhAWSJ R5Mmwdkc3CwCKhKTO2tBzF5BSwlLnbagFRICMhL7Gq7CFbNKWAlMfPrAiaQEiGgktM9URMYuR cwMqxiVC9OLSpLLdK10EsqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECPQvAxDsYLz Q7nyIUZKDSUmUd6/uzkghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxdhUA5waLU9NSKtMwcYKDB pCU4eJREeLVB0rzFBYm5xZnpEKlTjLocHTfv/mESYsnLz0uVEueNASkSACnKKM2DGwEL+kuMs lLCvIxARwnxFKQW5WaWoMq/YhTnYFQS5tUDmcKTmVcCt+kV0BFMQEecOb0D5IiSRISUVAPj5v drmuSTT2UvW8GeqKMVOKnhZk8dX9x9Nfmfsndurz6+4e7JKdd+sz7VFytsuNyXeZo/aO++NVJ /tm1I5LkTofj/hQpDofTzmfop/i1/U6bZxi+Nipm2eNrKH9fM3e+WxKTVmzoHzH0sobeKwSKK Z27svrcbUx6KJxcYrQhfVn/5/6TZ2+OElFiKMxINtZiLihMB1lHg8nUCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1505325612!107038294!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 36674 invoked from network); 13 Sep 2017 18:00:12 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-16.tower-31.messagelabs.com with SMTP; 13 Sep 2017 18:00:12 -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 1C0FA1435; Wed, 13 Sep 2017 11:00:12 -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 4D25A3F483; Wed, 13 Sep 2017 11:00:10 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:46 +0100 Message-Id: <20170913175953.16942-9-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-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 08/15] xen/x86: p2m: Use typesafe gfn for the P2M callbacks get_entry and set_entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Cc: Jan Beulich Cc: Andrew Cooper Cc: Razvan Cojocaru Cc: Tamas K Lengyel Cc: George Dunlap Cc: Jun Nakajima Cc: Kevin Tian Acked-by: Razvan Cojocaru Reviewed-by: Kevin Tian for 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 6cb903def5..53be8c093c 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 12fb9cc51f..4c1ace9b21 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..dff214cf7b 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_t, 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_t); 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_t, 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_t); 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..57878b1886 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_t, 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_t); 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_t, 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_t); 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 Wed Sep 13 17:59:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112470 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226770qgf; Wed, 13 Sep 2017 11:02:31 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDhyHIi54/4Yc2fgWljmUoOV86JDECCtC/ai5IEIfs+0OFbpQmkn2+w34UdTJ5OTWJcleqf X-Received: by 10.36.125.75 with SMTP id b72mr6149290itc.80.1505325751309; Wed, 13 Sep 2017 11:02:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325751; cv=none; d=google.com; s=arc-20160816; b=Zp/I9ucdFiRPYfBc1UQU9FOMPeSlR25YUbceDGlkW5zMpMeh7hyjlH82yXqcZ4sbgI UwgmB9zaze8mihOpnyyPOgPbBQNtoLMji0SlvsQ1+W6ITPCvaKCz8DXt8mw9xYvs47+A 2KFJtL46YwrhXWtClJa/Q4MYM81v9UeM8xktnDB6vhNgwXmdUXYI/5jvG51MhaSZVwL1 Augpd5TjvAdf/riWekioz3AVBR9GjPzWAwyKkhjKlT3zLyn8CJBv/6VN1s4grczJl+kQ hwXHW4r3wCgdfUwdSOUp1IQk0DvUOFsdffAHOhnBe+NldyTy2HQGuBbVZiJfBWQ0McKT wl4A== 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=2zSImo9Vib+PQq+tVsKu/kgt36gsn1lNdcjDpQkOK0E=; b=ceIWcltQKAV8aV2g3cNSanugazILj9slkYMlvdrepfGneUR+qOt8IqfJzILZfWJm6R X2Ki00jzS/z1HqzpfkEmMI8VeaYua3IZ1mezr2dvYMLyZwsWwXVO9LRBCn3B6oVz7PSB PvXuvl5CbU5c3klgZ6zm4tNVnZSXKP2m68SMCgzr0dRp6NBpoAUhEXKv7Q2SvdUHBiWK q+63tgcyoFMv0N0Qt9PMWZ9C5zYfHQz6ruPS+1S6urpKqDJKuT/KlTzLw9qbY743LsPJ 3OrKlArf01Be2+WpZFHv6d/yMdYXjevs+Dtx328b2OBg4w59Sfa54rkEaClhfC/3e+eh z18w== 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 e123si3644482ioe.220.2017.09.13.11.02.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:31 -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 1dsBxS-0007vq-72; Wed, 13 Sep 2017 18:00:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxQ-0007uP-Ck for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:16 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 9A/32-03093-F2279B95; Wed, 13 Sep 2017 18:00:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrNLMWRWlGSWpSXmKPExsVysyfVTVevaGe kwYwdWhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aDzvtMBbuvMlZ82nedsYFx5VzGLkYuDiGB zYwSTQ9PM0E4pxkl7n15xdzFyMnBJqApcefzJyYQW0RAWuLa58tgHcwgRf0X9rKDJIQF3CQOf msEa2ARUJX4PPsLWJxXwEpi3/lesLiEgLzErraLrCA2J1B85tcFQEM5gLZZSpzuiZrAyL2AkW EVo0ZxalFZapGukbFeUlFmekZJbmJmjq6hgZlebmpxcWJ6ak5iUrFecn7uJkaglxmAYAfjn/m BhxglOZiURHn36u6MFOJLyk+pzEgszogvKs1JLT7EKMPBoSTBK1EIlBMsSk1PrUjLzAGGG0xa goNHSYT3bQFQmre4IDG3ODMdInWK0Zjjx6Qrf5g4Om7e/cMkxJKXn5cqJc67HqRUAKQ0ozQPb hAsDi4xykoJ8zICnSbEU5BalJtZgir/ilGcg1FJmPcbyBSezLwSuH2vgE5hAjrlzOkdIKeUJC KkpBoY5Wfy9PDf2KRvs3bzgjnz5mTM6zx3eQ7fdma1M5Xy5uG7g54JvJqzPjx1SfDnX8ukXlT y+jkvZHj969QylcUbJtY8VlBKl9/Pfi7zXnzmB7v7ObLn71Y/izvZcHkiS6qO3bmNl76cb1Xc dJH/cqZZ9tTQ897hu26f0JYqm23Woy7KIVroW9h4WomlOCPRUIu5qDgRAJmFNJl+AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-13.tower-27.messagelabs.com!1505325613!107089188!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 64764 invoked from network); 13 Sep 2017 18:00:14 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-13.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:14 -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 8D146169E; Wed, 13 Sep 2017 11:00:13 -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 582FD3F483; Wed, 13 Sep 2017 11:00:12 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:47 +0100 Message-Id: <20170913175953.16942-10-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Tamas K Lengyel , Jan Beulich Subject: [Xen-devel] [PATCH 09/15] xen/x86: p2m: Use typesafe GFN in p2m_set_entry X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall Acked-by: Tamas K Lengyel --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Tamas K Lengyel --- 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 4c1ace9b21..2f8c6fa746 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 Wed Sep 13 17:59:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112461 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226504qgf; Wed, 13 Sep 2017 11:02:19 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAF9sB4v33Z7pSqgZ5boYjuPG1YPEdO5OoOfEtulNCo7cz1MEfD1DbrYGP468jZmdktDUqC X-Received: by 10.107.33.149 with SMTP id h143mr27680194ioh.167.1505325739699; Wed, 13 Sep 2017 11:02:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325739; cv=none; d=google.com; s=arc-20160816; b=AmvGD4Cm3reLtNGWhKx9Gs/1elt3IdWjNu+hMIgdeeH/cDS0dFjHxcn2Nwmu8amG+l GBTXEQR4njpOsC6YEEZFQ/nwvBLNigk+zfYr0UnWW7/pqSIDOD1T6hRG36EdQYxZFYvy 0Jdhzxyi2qKWX0mznI6qLn2/ZKaPqzBxwhY6E01q8+3dCAmWFZz5Tg2rbzP97eCSac6h qnvwz4XqwxwdwZSUkVnpQSw45C64s4ovX0KCGh56JN5TrE+HSF80AM4EagwaHVc9JLDT zX6wxWrW10UYkdoDyXGI+seGGKYpGGcI1ybyiN/JfY6s6gG9odBF8KKXzkg3vGmNQQkd EWNw== 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=K1eZck89WAv5Cru1gqhZZR+vJ8/wXPw2EWRPdbRVkTA=; b=J1Shy5mLPotpf/+LVhcGifXxjnVnHOEqgDt5ctsPNB4NZy8u6ovCI+3ozFCG29EUGq Ivp86dwFStvuYdJW56xvOcToBaZ2v6BC9huvHec1HZWqFlUCxeJyBumxqQImI0sOnF/z /mbqhgEJ1jOnqTZtgOMoLodV6S5eih0cerXxbpjYko4zC4Rr+lhoswnnhFPj//0z/Vaa zEZJhe5n1xpKWkzZzz9c6L99ukEVg84eT4KN1pe3jmoj6gEavdhVVKWOu2VcEEJCY7DI wji66ZDIcQejAGu+PvdiaZH0e2lrboIhxekWj+Y001g8WzNMgLASqhL6aTTrMvHsBNP0 132w== 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 g2si13463872ioa.80.2017.09.13.11.02.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:19 -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 1dsBxS-0007wG-EY; Wed, 13 Sep 2017 18:00:18 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxQ-0007uV-Ke for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:16 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 83/44-03642-03279B95; Wed, 13 Sep 2017 18:00:16 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTVe/aGe kwbu3yhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8br2zdZC15xV0yeupCtgXEfZxcjF4eQwGZG iUU7pjFCOKcZJVZMeMvSxcjJwSagKXHn8ycmEFtEQFri2ufLYEXMAosZJT7v72UGSQgL+Eocf 3eNDcRmEVCVaHy1C8zmFbCS+H7rD1izhIC8xK62i6wgNidQfObXBUBxDqBtlhKne6ImMHIvYG RYxahRnFpUllqka2iil1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFSsl5yfu4kR6GEGINjBeH1 jwCFGSQ4mJVHevbo7I4X4kvJTKjMSizPii0pzUosPMcpwcChJ8EoUAuUEi1LTUyvSMnOAoQaT luDgURLhfVsAlOYtLkjMLc5Mh0idYtTl6Lh59w+TEEtefl6qlDhvDMgMAZCijNI8uBGwsL/EK CslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYV49kCk8mXklcJteAR3BBHTEmdM7QI4oSURISTUwrv SXn5g5XSp4gXTSx6t+8SdDfijbi23uuGt35828RBMfFea5vFzeakXZcSqaS3qcuO5cujbzylK XZVJH/+2Zbuj23tltyfGKJ5tav28zYDQqD/oqePNC+AqpTwJMk3zjGqfNOPlmUuu/E9vvn1ty y1E7vCDH7XO7t+39u91ZDx5NsHJ/eE6/VImlOCPRUIu5qDgRAMdnaVd2AgAA X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1505325615!59645702!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 23765 invoked from network); 13 Sep 2017 18:00:15 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-6.tower-21.messagelabs.com with SMTP; 13 Sep 2017 18:00:15 -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 DA9E71435; Wed, 13 Sep 2017 11:00:14 -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 C91F03F483; Wed, 13 Sep 2017 11:00:13 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:48 +0100 Message-Id: <20170913175953.16942-11-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 10/15] xen/x86: p2m-pod: Use typesafe GFN in pod_eager_record X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112459 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226438qgf; Wed, 13 Sep 2017 11:02:16 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCFVGov+jyVdvEpcoy+PwEqQaS9nmbnEsQshpwU/ejzOytbOGTnBb7kK+HuMeks9Ni+bs/H X-Received: by 10.107.7.159 with SMTP id g31mr25751412ioi.250.1505325735931; Wed, 13 Sep 2017 11:02:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325735; cv=none; d=google.com; s=arc-20160816; b=B1CnBmXkX/PnrzzL698L587iQPMjKEu7G7hR2zovkxRhiH4dwkhbGwx6L7RwoXs/qx 45xVFdD0O8A+L7mgHJzhfagGIuPgVPN8jkPlqEvFw23C3dhMLIqhrtyw/DmdNX2l5IF1 IG2ECmRrrUN7jvDtF+0PaHEBpxXV2sP+0XAcuSrYbjdp1OXsT1X7tPV9EQ2/R8k4zpEb NDXqchv0Dhno17R+NU7x7RIBcEaEbCJiv7NwyGTOcl1CtjBOHCAb/vWZkEmmb8M6kqzW 88DE5s0CfSISf9Q3+UKkljGkVgGILNxTYEeUqAT9b14zgHnHM84s8rpMS9YELFHfwqKY zxHQ== 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=tvAVRk7VkTEaEehPOvL5+8uAAC5Iu0yiFmUQpU0/ifc=; b=QyKQmlOmw2hEJOxW9cuQ0CTIZ424fiXu3UHj9LDseyl2iB3V+zLW20FwQORljzyOqf uxjKuxH2PPhMuVmsJT9V5u6XYQHROM9K27e+dq40pIlt/l+99vWvNOefU4Je8RdQ7vbZ DPBjFAk1XSCk6mTsCAoT3MJKF/zr4DGxf4Kk2BAD/5PLNQRIqdY/HcmXMr7rf5E7eWYy pCrCdE2H9PMFPNT8TE9kaiEFjdnB0a4xMDcZoCFHix5osZghagKIZLEYLsGOvPDfUn0H JNgahXe+VUwftVjzl2yFeoFfTy7m1FwEdGO0AgXV5FRPCoYzP/l4svwGLFNoXZVplhxu JbfQ== 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 l18si1679627iti.94.2017.09.13.11.02.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:15 -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 1dsBxS-0007xV-Rv; Wed, 13 Sep 2017 18:00:18 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxS-0007vb-CP for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:18 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id 88/F3-09852-13279B95; Wed, 13 Sep 2017 18:00:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdegaGe kwazrNhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8ajk5eYClbzVBy/tYKxgXEiZxcjF4eQwGZG iXsHL7BDOKcZJXZ92cbcxcjJwSagKXHn8ycmEFtEQFri2ufLjCBFzAKLGSU+7+8FKxIWcJE4M qEPzGYRUJU492MOI4jNK2AlcfjrVDBbQkBeYlfbRVYQmxMoPvPrAqChHEDbLCVO90RNYORewM iwilGjOLWoLLVI18hAL6koMz2jJDcxM0fX0MBULze1uDgxPTUnMalYLzk/dxMj0MP1DAyMOxg bZ/sdYpTkYFIS5d2ruzNSiC8pP6UyI7E4I76oNCe1+BCjDAeHkgSvRCFQTrAoNT21Ii0zBxhq MGkJDh4lEV5tkDRvcUFibnFmOkTqFKMuR8fNu3+YhFjy8vNSpcR5Y0CKBECKMkrz4EbAwv4So 6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFePZApPJl5JXCbXgEdwQR0xJnTO0COKElESEk1MA otUzFQyNqWc6faTLNg77G3YnfXRxn1qW92bJ3gvH37ir2binlnu7wy1HqlpfFk6YYlW9zktut PenCSJf9Fi+Kzqa4zNvpGvl+x2mzixANL0p90n130fv39BvHu/TWMVnsYvQwN2x1e1P1+yPx3 /tolzoIO+x5W2X9/lcEZEfRPo+/m9hNmXzyUWIozEg21mIuKEwGRz3wIdgIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1505325616!111266319!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 1917 invoked from network); 13 Sep 2017 18:00:16 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-8.tower-206.messagelabs.com with SMTP; 13 Sep 2017 18:00:16 -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 33EF1169F; Wed, 13 Sep 2017 11:00:16 -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 227833F483; Wed, 13 Sep 2017 11:00:14 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:49 +0100 Message-Id: <20170913175953.16942-12-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 11/15] xen/x86: p2m-pod: Clean-up p2m_pod_zero_check X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112458 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226409qgf; Wed, 13 Sep 2017 11:02:14 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDOdh/c9tXvHLfGEiWgSGsg3R7ADM+2jcuG26lBCyr6HzwAUOTeWY8cE7+1vjzAmiQpam7o X-Received: by 10.36.3.145 with SMTP id e139mr6031478ite.18.1505325734787; Wed, 13 Sep 2017 11:02:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325734; cv=none; d=google.com; s=arc-20160816; b=G+4X4JMwiuYDaRiRflLvXSpIHrHU3K5vTugWXpChHXGs2wqhOmD24fsZC+88bILPu1 C8JXN7V3iwHHUeIznmTCybv6fbSGASeN59NEo9vFFE2umBwchQjq+38D/3cQCul6tmBq I1SiCP2hFCOlb6POpJqxFgRmXrIwwquzJraCNA1pLsJ7qcg2lAVTlVfnCnMQ1GTEHL8O mmoqiN5LjP2usRfvRDdcDvOF55OApqPeowb8knzoeJeGBQhV6RQ0rZn4DVMxeUcKvZJ/ xF5o+l5iA7gxQpi1a7+ebNm9buZXMfkwgnA6/wVJ9WtKFzvj1LfUXJm38TE+MmixuVZU 2gbw== 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=UjtlYWBcYYibqVwOwXJ6ahWGMzLpiPvb2r2CuvRyvok=; b=KHPgRBdYXfe1dYmboRPmxllQl5T8wQqXB1xd3lN1E6i7eoT++WJ0Hg1G1FuxHjiKL6 XcpLlbS/falr6DTNlowtoG63JgAFPS/WtRZu2AWKBTdPbH4ix90T7IbaEsanSAfOpR54 k9nsdHtvBtaR8S2uGPkYJgG6lRjWzfogAV4JGTsNNtVw2KZtcnDmfUHHmEs4cEXdIE2Y GgDmeieFXr6vilpHkz0EVjvChLKfzl3wZf3MJW6WW/MNgzyKocXCDSYeuCjCQX7dNRN4 IOMZVHTLSZe7mjkLERePItaAiD9XPgmT7cvHOdRnguZ6l8ebDy5oUqrnM/K7+agECgum ojRg== 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 c65si541876itg.124.2017.09.13.11.02.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:14 -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 1dsBxV-00082C-32; Wed, 13 Sep 2017 18:00:21 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxT-0007y5-KD for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:19 +0000 Received: from [85.158.143.35] by server-1.bemta-6.messagelabs.com id 98/46-03414-33279B95; Wed, 13 Sep 2017 18:00:19 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrBLMWRWlGSWpSXmKPExsVysyfVTdeoaGe kwa25YhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b1g2vYC1r1K/oW72JsYLyr2MXIxSEksJlR 4lzLelYI5zSjxMHJX5i6GDk52AQ0Je58/gRmiwhIS1z7fJkRpIhZYDGjxOf9vcwgCWEBf4mNK 5axg9gsAqoSSw+vZwGxeQWsJG5/uAsWlxCQl9jVdpEVxOYEis/8ugBoKAfQNkuJ0z1RExi5Fz AyrGJUL04tKkst0jXTSyrKTM8oyU3MzNE1NDDTy00tLk5MT81JTCrWS87P3cQI9C8DEOxgnHf C/xCjJAeTkijvXt2dkUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeCUKgXKCRanpqRVpmTnAQINJ S3DwKInwaoOkeYsLEnOLM9MhUqcYjTl+TLryh4mj4+bdP0xCLHn5ealS4rzrC4BKBUBKM0rz4 AbBIuASo6yUMC8j0GlCPAWpRbmZJajyrxjFORiVhHn1QBbyZOaVwO17BXQKE9ApZ07vADmlJB EhJdXAyFL9+8Anw2lnrSf+X3GX2V461z1+rerpnde74/cXCa6Umba87sXN9Q+uXNnXtJtljcB xEcejKVo+WXvOSc0MW7m9rmTDpAP/96fWts/80vrpc3bDd7n0t6qbdbWSd210nb1PkUHoo8DM 7wkrpwbsasjh33g056nu98ffSo+pPswJPMEQvipn5l4lluKMREMt5qLiRAA5ES6QewIAAA== X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1505325617!82745263!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 35541 invoked from network); 13 Sep 2017 18:00:18 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-7.tower-21.messagelabs.com with SMTP; 13 Sep 2017 18:00:18 -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 8184516A0; Wed, 13 Sep 2017 11:00:17 -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 6FEF03F483; Wed, 13 Sep 2017 11:00:16 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:50 +0100 Message-Id: <20170913175953.16942-13-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 12/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_zero_check X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" At the same time make the array gfns const has it is not modified within the function. Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112467 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226666qgf; Wed, 13 Sep 2017 11:02:27 -0700 (PDT) X-Google-Smtp-Source: AOwi7QApD/rc6E7ArFUJL0FIg/zP+bhRS6wWcjCn8dj5bGN+gyZi2uGncA2A/EbcnNtyd2uj4vKS X-Received: by 10.36.29.199 with SMTP id 190mr5737211itj.78.1505325746979; Wed, 13 Sep 2017 11:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325746; cv=none; d=google.com; s=arc-20160816; b=wS3rj6y6yeZhmpAL7RGYqWbpwH7h9QfRuZqub5nN/hjh+JDHby+3MqLvQVzA9NmgYN tqpQoGUNiv2+vaFPniCYG1e+h6fPqvuw/Emy9Z9q+2YbZSOEC80LCKZNu7cZ8nuLgDOy xp6avn4bwTmWMj4ERWTlvvAyGpbNNBWxIv3dLMEGQUPHUq5hxg/PjknInZfbWwz5eZrZ HkMG3CB1MPVLDcZ5/NF6oUPT6aCi82h/u4KG9l2Wpwm8hoYnYJk+fIJGsJktY5USuOnY DmaZ/uzuj9PyFW+HUpNDznfxKUfn8h47IRVt7F5XbceJV2+lmuumNfXa4NZGpVe6Zs2B AlMA== 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=1m7QtIW/P0a+2BGWL3YTve7VgCEjsUa71IJ/pBuP/1s=; b=qDmI7TA9pyMjhe0H95FjBUThNCS/mV4s5iSKfqckReJHEk+s9KxoxDyN1K8Vq1YKIJ 0vV36EHMxDunQAhKFpY+Ctj0+OP3tFoDK5Zyp1NRdi++KNQUPvECrKBj3Y4dsbL1Nbhz a/olcU+YE1gwz099jRy5iq56aAaOxSZZlKW7pXMWl7xg7SQUK/lYKLFC4+WmuDDKToDp DvkBcwWj5YuBhRJeohzFvVIYAJ1vOGT8HUicUKeAio2kWxwgEZetj9ydvMjraWMq780E sp2uJ/swoPHc4H0FFp4EwA0mRPB9s2HoLbE7lPkHTH464sxGHifkKAk4wnTkBB8smCc4 qXNg== 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 m202si2676202iom.191.2017.09.13.11.02.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:26 -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 1dsBxW-00083z-Am; Wed, 13 Sep 2017 18:00:22 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxV-00081U-BV for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:21 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 58/06-02226-43279B95; Wed, 13 Sep 2017 18:00:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTde4aGe kwaRrphZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aKq9NYCz6oVrxe/4O5gfGvVBcjF4eQwGZG iR3dFxkhnNOMEjtPbGLuYuTkYBPQlLjz+RMTiC0iIC1x7fNlsCJmgcWMEp/394IVCQuESPybu pkRxGYRUJXYsfw4O4jNK2Al8Xj1LbBmCQF5iV1tF1lBbE6g+MyvC4DiHEDbLCVO90RNYORewM iwilGjOLWoLLVI19BUL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj0MMMQLCDcc1 2z0OMkhxMSqK8e3V3RgrxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4J1dAJQTLEpNT61Iy8wBhhpM WoKDR0mE9y1Imre4IDG3ODMdInWKUZej4+bdP0xCLHn5ealS4rzrQYoEQIoySvPgRsDC/hKjr JQwLyPQUUI8BalFuZklqPKvGMU5GJWEedMKgabwZOaVwG16BXQEE9ARZ07vADmiJBEhJdXA2C l/7OC5Akanh7wMT4r/iM0J//jfNqm3TPmVqtANnU61i8VT+wo2Z1ayb1+zS8IzWD0kSvN6olt EX91LlThLj13ax9RfsZ45uGfdm53znrpoP/95+OCJN+Znr00XY5N70pcrdM9PTk9NQYV5zd66 Tafu97ZvCFw0pbfJb4mEr9M5y63PHdk1lFiKMxINtZiLihMB0vMLgnYCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1505325619!114657001!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 57962 invoked from network); 13 Sep 2017 18:00:19 -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; 13 Sep 2017 18:00:19 -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 D081A1435; Wed, 13 Sep 2017 11:00:18 -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 BD9253F483; Wed, 13 Sep 2017 11:00:17 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:51 +0100 Message-Id: <20170913175953.16942-14-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 13/15] xen/x86: p2m-pod: Use typesafe gfn in p2m_pod_demand_populate X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/mm/p2m-ept.c | 4 ++-- 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(+), 12 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index dff214cf7b..36627f1ce0 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_t, i * EPT_TABLE_ORDER, q) ) 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, + if ( p2m_pod_demand_populate(p2m, gfn_t, 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 57878b1886..3dd4bef66e 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_t, 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_t, 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_t, 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 Wed Sep 13 17:59:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112463 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226564qgf; Wed, 13 Sep 2017 11:02:22 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAUxbRAQPJrlH9W5vG45pTd1S1WtQODRZlN9kNNBt90RPNHPPd2Ta8sWP8BdhyAHkmQbMZp X-Received: by 10.107.84.3 with SMTP id i3mr9360854iob.52.1505325742173; Wed, 13 Sep 2017 11:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325742; cv=none; d=google.com; s=arc-20160816; b=iw4ehr8qcMUOIzwW/ewbAbalUSRAaL7qrITR4kYlFEIm2r2GK2duM6nuYXZLlJkAIB njjrJNQaWxX/SVYVNDjwN+z+D/GUvoXHrHXhBrXkqRpb1M0rgpQuRf65QaOvlFM0WHBr a7pLJIF2AEw8M27B2BuDKo79n3UUDFPWKF+0NZh+dCPrZCR3seY+po6YPGwkn/JHduTo vyuizp/V62ZefCv7V0S1KsqK7ZWvFEOofJ1r9KwsZyksTqNbpptQQ6RajM2VijsfNYTF d28/lMgUg6Fwkp+T0ykJQG3zLNeGC80b7KRy3tdCSMcQIskikGTKy9DzIGzn7JQw9XlS an4Q== 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=pPsEzHvPRQ9dzvF0hdh7eNjZr5zK+WTPSSm1XQ34L1c=; b=Zwp3yrJvmfPWmETdmn9hL0z6mnoKwN2fA3vDF6CyrTvEX32rIjUquB/lYLI7y1ZTLk L0MykJkntScrMx5Rh/ZfDJGj031gwDWgWL3NYKcYr3Hwff8z1FpSSuGZrqzBNTc6CULt X08bx8ucTjTQD+KWU74WrWsmk8vQEuVS+vDLxmT9jVF+x0fVoYmP96VIGKEmqR3tfp4P 3bV6DqMbnbYIGVo5fAFC8/3hWKhYb6Y2nkgGaak86clShEGj6q0HAwLqunPKFcWsi49m txWQBFDF9T47o3QWBemcyxnRnCbmpk4mVUX7yevHJyp8VknTByHZQcZYZshLh5vsl47X /yrQ== 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 l71si13587331iol.121.2017.09.13.11.02.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:22 -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 1dsBxX-00086B-IC; Wed, 13 Sep 2017 18:00:23 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxV-000833-VD for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:22 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id 13/09-03610-53279B95; Wed, 13 Sep 2017 18:00:21 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMLMWRWlGSWpSXmKPExsVysyfVTdekaGe kwbX1phZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8aDZWfZCzrEKtrblrI1MJ4Q6GLk4hAS2Mwo cWfGP3YI5zSjxN8Z05m6GDk52AQ0Je58/gRmiwhIS1z7fJkRpIhZYDGjxOf9vcwgCWGBVImZ/ 5sYQWwWAVWJ1TensoPYvAJWEgt3dIHZEgLyErvaLrKC2JxA8ZlfFwAN5QDaZilxuidqAiP3Ak aGVYwaxalFZalFuoZGeklFmekZJbmJmTm6hgZmermpxcWJ6ak5iUnFesn5uZsYgR5mAIIdjJc 3BhxilORgUhLl3au7M1KILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK9EIVBOsCg1PbUiLTMHGGow aQkOHiURXm2QNG9xQWJucWY6ROoUoy5Hx827f5iEWPLy81KlxHljQIoEQIoySvPgRsDC/hKjr JQwLyPQUUI8BalFuZklqPKvGMU5GJWEeb8VAE3hycwrgdv0CugIJqAjzpzeAXJESSJCSqqBcd qSNe/5LYO7J2U/3/MwZ3+MRk19pUyntq+n6ZLX+T8kUuN3zbW5M42naJvSypy639MrXXbobPl /ueQlk3eKXJ+VX+NKJ36ByKvN3Ny+e2ZHvslK2/9aQHxBvsokl4OmTpN7Q27EesyvVTLg33N1 3Trltha9uRv2+795ad9weaHKafnT+S9KlViKMxINtZiLihMBl6Q/S3YCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1505325620!93412729!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 31042 invoked from network); 13 Sep 2017 18:00:20 -0000 Received: from usa-sjc-mx-foss1.foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-10.tower-27.messagelabs.com with SMTP; 13 Sep 2017 18:00:20 -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 2B483169F; Wed, 13 Sep 2017 11:00:20 -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 1858A3F483; Wed, 13 Sep 2017 11:00:18 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:52 +0100 Message-Id: <20170913175953.16942-15-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 14/15] xen/x86: p2m-pod: Use typesafe gfn for the fields reclaim_single and max_guest X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- 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 Wed Sep 13 17:59:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 112468 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp1226687qgf; Wed, 13 Sep 2017 11:02:27 -0700 (PDT) X-Google-Smtp-Source: AOwi7QCc4M7/0U1SDUrpt/Pep0wMJ8ygQLaIR9ruPXXjvvrNxeWQCEQETTe47z9d/jlDN78D0OkJ X-Received: by 10.107.200.86 with SMTP id y83mr26430451iof.24.1505325747810; Wed, 13 Sep 2017 11:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505325747; cv=none; d=google.com; s=arc-20160816; b=GOgaGmrsTN8h5P6KjP3FlXAwZHOjkgNfJP8HFXjNCdWhAEJs+wnqi62fuVVLQbJmvV eRf5dr2/afN3j2SA83AE/+57tihTd0j99kkKpmbb69gzdG80wOtAuMb29tgTnUPaJSQs 85ZC6y5Q5p2X94PdCLtYJ6+rR8OqymK+j/oG/QIHtJFOx+K6/LeaWslxnWghSfsn6Jn2 zJspTr+TkgvIEIBoCrfLDOt7NISbctRpH86r4TpeT9lGe0D6KNmrLEhkh78yfbY3cSBZ SiR0QSNl+VQdPg/Ln9IgFsZ1EEPkjIydy9kSLb38CBVsQ8kBEm2sOTMpTYTDlbhPqV+3 Ijbw== 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=0RtFrkEev/aHUl2fibG6tyk8PfrdS5oIo4KHLfOl6zE=; b=KuUVsPnRYtIqNPHM90f0CHyrW/4s4le0x/QZLhPPf9QgDGpJPZcaJ4EF71TIzz9GLT 1evHUt7Qmx0DMlH2H6iGIWNY/abdu9YVajXlk4gG63O1H2Gf2xqgkl8Ms1vw3QRozLSj FxWXzz2TYOD/07p2tdhS4fDparLN5B1GuHwG97trd2wK4t1xrGFgn7x//IAOU/CPpC21 prmD5krd991cwq4ketTaCOlPkTVXuL1LbPIoMPwA/YEQ1nH8ZkYji/79PSG3+Ho4Ee6f HLLwRQlCarTN4JMjH+BB8/2lgApISwRSJVDVNdo8dWUPY0bwIPtCz3n3+CjihnfDkETW +VuA== 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 t10si9986214iod.3.2017.09.13.11.02.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 11:02:27 -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 1dsBxY-000891-TB; Wed, 13 Sep 2017 18:00:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dsBxX-00085f-ML for xen-devel@lists.xen.org; Wed, 13 Sep 2017 18:00:23 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id E1/50-01910-63279B95; Wed, 13 Sep 2017 18:00:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrELMWRWlGSWpSXmKPExsVysyfVTdesaGe kwa9GCYslHxezODB6HN39mymAMYo1My8pvyKBNeNi+y72gqnqFZN+TmJsYJwu08XIxSEksJlR 4nfjF9YuRk4g5zSjxI2lzCA2m4CmxJ3Pn5hAbBEBaYlrny8zgjQwCyxmlPi8vxesSFggROJD1 1WwIhYBVYlTa7aCDeIVsJLYcvEhWFxCQF5iV9tFsDgnUHzm1wVAcQ6gZZYSp3uiJjByL2BkWM WoUZxaVJZapGtkpJdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJEejfegYGxh2MU0/ 4HWKU5GBSEuXdq7szUogvKT+lMiOxOCO+qDQntfgQowwHh5IEr0QhUE6wKDU9tSItMwcYaDBp CQ4eJRFebZA0b3FBYm5xZjpE6hSjLkfHzbt/mIRY8vLzUqXEeWNAigRAijJK8+BGwIL+EqOsl DAvIwMDgxBPQWpRbmYJqvwrRnEORiVhXj2QKTyZeSVwm14BHcEEdMSZ0ztAjihJREhJNTDOdM ly4oncH5FzUGbL9Keq0hNUC9xCeOvWbLHxfD/pqnhS4b/vqse+Z27QufnxHPdB11+SThPaJji 8XD/rpHGo28X6ru4ZHWIan89Pv8vYXN/12UDEelGxdtukncm7bWx+imvU8AgtluLeVLeoWv3g vTdP1x4p+X1MaH+ITet6+yLdGWl/FuoosRRnJBpqMRcVJwIA22Ob8HUCAAA= X-Env-Sender: julien.grall@arm.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1505325621!114657007!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 58388 invoked from network); 13 Sep 2017 18:00:22 -0000 Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by server-3.tower-31.messagelabs.com with SMTP; 13 Sep 2017 18:00:22 -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 789271435; Wed, 13 Sep 2017 11:00:21 -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 673443F483; Wed, 13 Sep 2017 11:00:20 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 13 Sep 2017 18:59:53 +0100 Message-Id: <20170913175953.16942-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170913175953.16942-1-julien.grall@arm.com> References: <20170913175953.16942-1-julien.grall@arm.com> Cc: George Dunlap , Andrew Cooper , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH 15/15] xen/x86: p2m-pod: Rework prototype of p2m_pod_demand_populate X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" - Switch the return type to bool - Remove the parameter p2m_query_t q as it is not used Signed-off-by: Julien Grall --- Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/mm/p2m-ept.c | 5 ++--- 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(+), 18 deletions(-) diff --git a/xen/arch/x86/mm/p2m-ept.c b/xen/arch/x86/mm/p2m-ept.c index 36627f1ce0..641b90ec07 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_t, i * EPT_TABLE_ORDER, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_t, i * EPT_TABLE_ORDER) ) 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_t, - PAGE_ORDER_4K, q) ) + if ( !p2m_pod_demand_populate(p2m, gfn_t, 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 3dd4bef66e..86946a09db 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_t, PAGE_ORDER_1G, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_t, 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_t, PAGE_ORDER_2M, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_t, 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_t, PAGE_ORDER_4K, q) ) + if ( p2m_pod_demand_populate(p2m, gfn_t, 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