From patchwork Wed Oct 4 18:15:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9985283 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 84D5B60586 for ; Wed, 4 Oct 2017 18:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B95E28BD4 for ; Wed, 4 Oct 2017 18:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7044C28BD8; Wed, 4 Oct 2017 18:17:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1428628BD4 for ; Wed, 4 Oct 2017 18:17:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzoCw-00024b-6S; Wed, 04 Oct 2017 18:15:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dzoCv-00023L-A0 for xen-devel@lists.xen.org; Wed, 04 Oct 2017 18:15:45 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id 56/77-03642-05525D95; Wed, 04 Oct 2017 18:15:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVyMfTOGl0/1au RBnduM1os+biYxYHR4+ju30wBjFGsmXlJ+RUJrBmH9x1kLNgmVnF02zrWBsbLgl2MnBxCApMY JdqfsXcxcnGwCMxjllj4bSIriCMh0M8qsbZxNXMXIweQkydxd6M/SIOEQJrEhKUfWCHsaolnK x+wgZQICahJrHkTBdIqJNDPJNG4YAErSJxNQEdi3YxakHIRAWmJa58vM4LUMAu8YpJofb6AHS QhLOAuce3BdUYQm0VAVeJK1w+wOK+AtcT2jXuYIXbJS+xquwi2l1PARmLWlHZGiAesJfraT7N OYBRcwMiwilGjOLWoLLVI19BQL6koMz2jJDcxM0fX0MBMLze1uDgxPTUnMalYLzk/dxMjMNwY gGAH46dlAYcYJTmYlER5Z8lfjRTiS8pPqcxILM6ILyrNSS0+xCjDwaEkwXtFBSgnWJSanlqRl pkDDHyYtAQHj5II7wOQNG9xQWJucWY6ROoUoyXHhTuX/jBxHNhzC0h23Lz7h0mIJS8/L1VKnL cVpEEApCGjNA9uHCw6LzHKSgnzMgIdKMRTkFqUm1mCKv+KUZyDUUmY1xRkCk9mXgnc1ldABzE BHTSn6QrIQSWJCCmpBka3qJcK7bxpGWu0ppjNM52T/G5WEmdRzMz8qq3BQScin/GfWbD488Yb drtDxTrtXid0VRoJrzzkVS6trWYtKbtZeUnZ43m19nvnbLuvrPTm6S3bWsca0SJZx41rLjilS V6qsGVecpbh66ndx+dG7ukv4tn0wtM8yttlaWif52/Wn57OgW+WZSmxFGckGmoxFxUnAgBspN NLyQIAAA== X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-16.tower-21.messagelabs.com!1507140941!64405399!1 X-Originating-IP: [209.85.220.172] 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 62712 invoked from network); 4 Oct 2017 18:15:41 -0000 Received: from mail-qk0-f172.google.com (HELO mail-qk0-f172.google.com) (209.85.220.172) by server-16.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 4 Oct 2017 18:15:41 -0000 Received: by mail-qk0-f172.google.com with SMTP id u67so12398661qkg.6 for ; Wed, 04 Oct 2017 11:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GWzPyfooDUJpVZ3QwpsioFkJz/D+fNR5Z/Li220Dzt0=; b=fk+npxgwzLUtjXx4xNSoMUUhazR7c6uNh6CXbo0a4uULOGQI6w9Gz+BcuN12J7KUtB 8bW3gBLwRM+faix7kelUGvHG6Gspxi5nSCzllCz7aPCoRWVdv2JLNtBuagszfoyKfVQv VMdYwbDNl9WhKeZ3z0eOqzsrwZPcirAV7INzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GWzPyfooDUJpVZ3QwpsioFkJz/D+fNR5Z/Li220Dzt0=; b=QdjOaK+QUMumu3pVJK8TJyyVpviF9cKZQmmoZgM0iX50mlXWw1xaB0Gk/k4t8XtMCt 5y7nFQIs2EcA2lJci+/PEwChvs5KZOxm9BFrdHNst/yDBI2DpGUxy3xLBuUD9kiyTtE6 qY5MjSIQdmQcp2+gF9SS7CZsz7OgTuBVeH0gctfWoRzAc55JQgpu/4TJLsuuW/Cjnm8a jHjaSWTyVSMd/JwnIkeujfTfC57MuBqbKt4cbHvRNHjHZnG7Rh+u8BadPlIQicNkbt1p rRLcnWYmY28KfBP62mlN7B7a9K6mlJUT5TQemmVtEaf9zkiFNYKR+gRt3195cAYcwjHt bXHA== X-Gm-Message-State: AMCzsaXQNFncWkfAQPX6OLxYJzSIKki9tFmhje/m+sVCcqgAXtz2uSj1 cCFzTi4riEIXpbBgZpIQC6kcx+qYtzY= X-Google-Smtp-Source: AOwi7QDMA6iS0KT+Qpxo14tvzBO1fh7A35kkxPirWu2HZMrZOxwWCN65lQD4S/xL2jubTpg/Mb+ANw== X-Received: by 10.55.187.133 with SMTP id l127mr24739245qkf.94.1507140940776; Wed, 04 Oct 2017 11:15:40 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com ([2001:41d0:1:6c23::1]) by smtp.gmail.com with ESMTPSA id l188sm10210622qkd.43.2017.10.04.11.15.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 11:15:40 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 4 Oct 2017 19:15:24 +0100 Message-Id: <20171004181526.9405-6-julien.grall@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171004181526.9405-1-julien.grall@linaro.org> References: <20171004181526.9405-1-julien.grall@linaro.org> Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Julien Grall , Ian Jackson , Tim Deegan , Jan Beulich Subject: [Xen-devel] [PATCH 5/7] xen/xenoprof: Convert the file to use 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" X-Virus-Scanned: ClamAV using ClamSMTP The file common/xenoprof.c is now converted to use typesafe. This is requiring to override the macros virt_to_mfn and mfn_to_page to make them work with mfn_t. Signed-off-by: Julien Grall --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu --- xen/common/xenoprof.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index a5fe6204a5..98937c9ac6 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -19,6 +19,12 @@ #include #include +/* Override macros from asm/page.h to make them work with mfn_t */ +#undef virt_to_mfn +#define virt_to_mfn(va) _mfn(__virt_to_mfn(va)) +#undef mfn_to_page +#define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn)) + /* Limit amount of pages used for shared buffer (per domain) */ #define MAX_OPROF_SHARED_PAGES 32 @@ -134,25 +140,26 @@ static void xenoprof_reset_buf(struct domain *d) } static int -share_xenoprof_page_with_guest(struct domain *d, unsigned long mfn, int npages) +share_xenoprof_page_with_guest(struct domain *d, mfn_t mfn, int npages) { int i; /* Check if previous page owner has released the page. */ for ( i = 0; i < npages; i++ ) { - struct page_info *page = mfn_to_page(mfn + i); + struct page_info *page = mfn_to_page(mfn_add(mfn, i)); if ( (page->count_info & (PGC_allocated|PGC_count_mask)) != 0 ) { printk(XENLOG_G_INFO "dom%d mfn %#lx page->count_info %#lx\n", - d->domain_id, mfn + i, page->count_info); + d->domain_id, mfn_x(mfn_add(mfn, i)), page->count_info); return -EBUSY; } page_set_owner(page, NULL); } for ( i = 0; i < npages; i++ ) - share_xen_page_with_guest(mfn_to_page(mfn + i), d, XENSHARE_writable); + share_xen_page_with_guest(mfn_to_page(mfn_add(mfn, i)), + d, XENSHARE_writable); return 0; } @@ -161,11 +168,11 @@ static void unshare_xenoprof_page_with_guest(struct xenoprof *x) { int i, npages = x->npages; - unsigned long mfn = virt_to_mfn(x->rawbuf); + mfn_t mfn = virt_to_mfn(x->rawbuf); for ( i = 0; i < npages; i++ ) { - struct page_info *page = mfn_to_page(mfn + i); + struct page_info *page = mfn_to_page(mfn_add(mfn, i)); BUG_ON(page_get_owner(page) != current->domain); if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) put_page(page);