From: Julien Grall <julien.grall@linaro.org>
To: xen-devel@lists.xen.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Julien Grall <julien.grall@linaro.org>,
Ian Jackson <ian.jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v2 7/9] xen/xenoprof: Convert the file to use typesafe MFN
Date: Thu, 5 Oct 2017 18:42:20 +0100 [thread overview]
Message-ID: <20171005174222.29161-8-julien.grall@linaro.org> (raw)
In-Reply-To: <20171005174222.29161-1-julien.grall@linaro.org>
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.
Also, add a couple of missing newlines in the code modified.
Signed-off-by: Julien Grall <julien.grall@linaro.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: George Dunlap <George.Dunlap@eu.citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Tim Deegan <tim@xen.org>
Cc: Wei Liu <wei.liu2@citrix.com>
Changes in v2:
- Add missing newlines
- Add Andrew's reviewed-by
---
xen/common/xenoprof.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c
index a5fe6204a5..5acdde5691 100644
--- a/xen/common/xenoprof.c
+++ b/xen/common/xenoprof.c
@@ -19,6 +19,12 @@
#include <xsm/xsm.h>
#include <xen/hypercall.h>
+/* 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,27 @@ 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 +169,12 @@ 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);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-10-05 17:42 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-05 17:42 [PATCH v2 0/9] xen: Convert __page_to_mfn and __mfn_to_page to use typesafe MFN Julien Grall
2017-10-05 17:42 ` [PATCH v2 1/9] xen/arm: domain_build: Clean-up insert_11_bank Julien Grall
2017-10-05 17:42 ` [PATCH v2 2/9] xen/arm32: mm: Rework is_xen_heap_page to avoid nameclash Julien Grall
2017-10-05 17:42 ` [PATCH v2 3/9] xen/x86: mem_sharing: Use copy_domain_page in __mem_sharing_unshare_page Julien Grall
2017-10-05 17:49 ` Andrew Cooper
2017-10-05 17:52 ` Tamas K Lengyel
2017-10-05 17:42 ` [PATCH v2 4/9] xen/x86: Use maddr_to_page and maddr_to_mfn to avoid open-coded >> PAGE_SHIFT Julien Grall
2017-10-05 17:42 ` [PATCH v2 5/9] xen/kimage: Remove defined but unused variables Julien Grall
2017-10-05 17:42 ` [PATCH v2 6/9] xen/kexec, kimage: Convert kexec and kimage to use typesafe mfn_t Julien Grall
2017-10-05 17:51 ` Andrew Cooper
2017-10-05 17:42 ` Julien Grall [this message]
2017-10-05 17:42 ` [PATCH v2 8/9] xen/tmem: Convert the file common/tmem_xen.c to use typesafe MFN Julien Grall
2017-10-05 17:42 ` [PATCH v2 9/9] xen: Convert __page_to_mfn and __mfn_to_page " Julien Grall
2017-10-05 17:59 ` Andrew Cooper
2017-10-05 18:31 ` Razvan Cojocaru
2017-10-06 9:11 ` Paul Durrant
2017-10-06 10:49 ` Julien Grall
2017-10-06 10:55 ` Paul Durrant
2017-10-06 11:00 ` Julien Grall
2017-10-06 11:44 ` Paul Durrant
2017-10-06 13:02 ` Boris Ostrovsky
2017-10-09 11:42 ` Jan Beulich
2017-10-09 12:20 ` Julien Grall
2017-10-09 13:40 ` Jan Beulich
2017-10-09 13:48 ` Julien Grall
2017-10-09 14:07 ` Jan Beulich
2017-10-10 5:18 ` Tian, Kevin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171005174222.29161-8-julien.grall@linaro.org \
--to=julien.grall@linaro.org \
--cc=George.Dunlap@eu.citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=jbeulich@suse.com \
--cc=konrad.wilk@oracle.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).