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: 114785 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp3428439qgn; Wed, 4 Oct 2017 11:17:29 -0700 (PDT) X-Received: by 10.36.173.78 with SMTP id a14mr27844879itj.4.1507141049801; Wed, 04 Oct 2017 11:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507141049; cv=none; d=google.com; s=arc-20160816; b=LNAPKixLubb+fEtG67Q+zxpSeA9Dw/QhDLTjO+z2TiKa8ly+d6R21XA+sYjq37J5iW TEJkKpoNqeMPzl3YOT7SMVgRacjINDwMzkTO32bJrNi1i4CJH9hBdEMzVfTFHwc3dgSi uRAuwYH+1EatLvv4kF0H6FUnrytvpyJBdwGiKUJ3D2p7cZxKQOS7eUN51iSFSaCJgSJA McoOPFtYQ6V6nL3Dc0DJGC9AssD71DX9o6nAZoA+bbhWEovjY9rayn7zCfDoRifuJGXg Zd2R3L9iadTS4ph2KD48aJBttI8mbs1UUhovw+mgPtMVHR/6o6DNZr+Wk7qyLQzpA0Co iggg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=IGSxNRCX4JEyBpcRvZx44oiag8AvK8UiGhfD6tVLJgA=; b=zp1AeEhmCXo2oHhM0Gi4VMwkyAQWQHW3A7Q1BoVBsASa2PhZG8zgAjdM3zY8N4dduI rIJjWdZJuNPTgxjG9IqQzVTlRk6+W6B2q5e4JD7zm+XI3qQhAvLtt6gdlhuSVolikWSV NscagIAh77zuu2sdft4DjLcdjg4GuwxakMmlFCthmwRSmROK/VgCphF6Dqquu6t42fGF 2wntqeKVw/1RAB3VX8xrXjIqgW1lAetRsC3kbHemlVzni3o30KvfLhEqh0InlmNjX277 Ixz+5Dx0Fm45aPWgvz8uAuAnd499GoB75sIuM3x/mzyfP+lS/1iW5QULp0XVnUNtVI00 c/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fk+npxgw; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 79si6285412itf.46.2017.10.04.11.17.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 11:17:29 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=fk+npxgw; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 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" 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);