From: Aravindh Puthiyaparambil <aravindp@cisco.com>
To: xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Aravindh Puthiyaprambil <aravindp@cisco.com>
Subject: [PATCH RFC v2 4/4] tool/xen-access: Add support for PV domains
Date: Mon, 7 Jul 2014 19:50:05 -0700 [thread overview]
Message-ID: <1404787805-4540-5-git-send-email-aravindp@cisco.com> (raw)
In-Reply-To: <1404787805-4540-1-git-send-email-aravindp@cisco.com>
Add support to the xen-access test program for it to work with PV domains.
Signed-off-by: Aravindh Puthiyaprambil <aravindp@cisco.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Ian Campbell <ian.campbell@citrix.com>
---
Changes from RFC v1:
Add call to xc_set_mem_access_default().
PV ring page setup is now done as part of xc_mem_access_enable() due to
xsa-99.
tools/tests/xen-access/xen-access.c | 104 +++++++++++++++++++++---------------
1 file changed, 62 insertions(+), 42 deletions(-)
diff --git a/tools/tests/xen-access/xen-access.c b/tools/tests/xen-access/xen-access.c
index 090df5f..02ea0c9 100644
--- a/tools/tests/xen-access/xen-access.c
+++ b/tools/tests/xen-access/xen-access.c
@@ -114,7 +114,8 @@ typedef struct xenaccess {
} xenaccess_t;
static int interrupted;
-bool evtchn_bind = 0, evtchn_open = 0, mem_access_enable = 0;
+static bool evtchn_bind = 0, evtchn_open = 0, mem_access_enable = 0, hvm = 0,
+ pv_cleanup = 0;
static void close_handler(int sig)
{
@@ -173,7 +174,7 @@ int xenaccess_teardown(xc_interface *xch, xenaccess_t *xenaccess)
if ( xenaccess->mem_event.ring_page )
munmap(xenaccess->mem_event.ring_page, XC_PAGE_SIZE);
- if ( mem_access_enable )
+ if ( mem_access_enable || (!hvm && pv_cleanup) )
{
rc = xc_mem_access_disable(xenaccess->xc_handle,
xenaccess->mem_event.domain_id);
@@ -241,6 +242,27 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id)
/* Set domain id */
xenaccess->mem_event.domain_id = domain_id;
+ /* Get domaininfo */
+ xenaccess->domain_info = malloc(sizeof(xc_domaininfo_t));
+ if ( xenaccess->domain_info == NULL )
+ {
+ ERROR("Error allocating memory for domain info");
+ goto err;
+ }
+
+ rc = xc_domain_getinfolist(xenaccess->xc_handle, domain_id, 1,
+ xenaccess->domain_info);
+ if ( rc != 1 )
+ {
+ ERROR("Error getting domain info");
+ goto err;
+ }
+
+ if ( xenaccess->domain_info->flags & XEN_DOMINF_hvm_guest )
+ hvm = 1;
+ else
+ pv_cleanup = 1;
+
/* Initialise lock */
mem_event_ring_lock_init(&xenaccess->mem_event);
@@ -293,24 +315,6 @@ xenaccess_t *xenaccess_init(xc_interface **xch_r, domid_t domain_id)
(mem_event_sring_t *)xenaccess->mem_event.ring_page,
XC_PAGE_SIZE);
- /* Get domaininfo */
- xenaccess->domain_info = malloc(sizeof(xc_domaininfo_t));
- if ( xenaccess->domain_info == NULL )
- {
- ERROR("Error allocating memory for domain info");
- goto err;
- }
-
- rc = xc_domain_getinfolist(xenaccess->xc_handle, domain_id, 1,
- xenaccess->domain_info);
- if ( rc != 1 )
- {
- ERROR("Error getting domain info");
- goto err;
- }
-
- DPRINTF("max_pages = %"PRIx64"\n", xenaccess->domain_info->max_pages);
-
return xenaccess;
err:
@@ -485,30 +489,38 @@ int main(int argc, char *argv[])
}
/* Set the default access type and convert all pages to it */
- rc = xc_set_mem_access(xch, domain_id, default_access, ~0ull, 0);
- if ( rc < 0 )
- {
- ERROR("Error %d setting default mem access type\n", rc);
- goto exit;
- }
+ if ( hvm )
+ rc = xc_set_mem_access(xch, domain_id, default_access, ~0ull, 0);
+ else
+ rc = xc_set_mem_access_default(xch, domain_id, default_access);
- rc = xc_set_mem_access(xch, domain_id, default_access, 0,
- xenaccess->domain_info->max_pages);
if ( rc < 0 )
{
- ERROR("Error %d setting all memory to access type %d\n", rc,
- default_access);
+ ERROR("Error %d setting default mem access type\n", rc);
goto exit;
}
- if ( int3 )
- rc = xc_hvm_param_set(xch, domain_id, HVM_PARAM_MEMORY_EVENT_INT3, HVMPME_mode_sync);
- else
- rc = xc_hvm_param_set(xch, domain_id, HVM_PARAM_MEMORY_EVENT_INT3, HVMPME_mode_disabled);
- if ( rc < 0 )
+ if ( hvm )
{
- ERROR("Error %d setting int3 mem_event\n", rc);
- goto exit;
+ rc = xc_set_mem_access(xch, domain_id, default_access, 0,
+ xenaccess->domain_info->max_pages);
+ if ( rc < 0 )
+ {
+ ERROR("Error %d setting all memory to access type %d\n", rc,
+ default_access);
+ goto exit;
+ }
+ if ( int3 )
+ rc = xc_hvm_param_set(xch, domain_id, HVM_PARAM_MEMORY_EVENT_INT3,
+ HVMPME_mode_sync);
+ else
+ rc = xc_hvm_param_set(xch, domain_id, HVM_PARAM_MEMORY_EVENT_INT3,
+ HVMPME_mode_disabled);
+ if ( rc < 0 )
+ {
+ ERROR("Error %d setting int3 mem_event\n", rc);
+ goto exit;
+ }
}
/* Wait for access */
@@ -519,11 +531,19 @@ int main(int argc, char *argv[])
DPRINTF("xenaccess shutting down on signal %d\n", interrupted);
/* Unregister for every event */
- rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, ~0ull, 0);
- rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, 0,
- xenaccess->domain_info->max_pages);
- rc = xc_hvm_param_set(xch, domain_id, HVM_PARAM_MEMORY_EVENT_INT3, HVMPME_mode_disabled);
-
+ if ( hvm )
+ {
+ rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, ~0ull,
+ 0);
+ rc = xc_set_mem_access(xch, domain_id, XENMEM_access_rwx, 0,
+ xenaccess->domain_info->max_pages);
+ rc = xc_hvm_param_set(xch, domain_id,
+ HVM_PARAM_MEMORY_EVENT_INT3,
+ HVMPME_mode_disabled);
+ }
+ else
+ rc = xc_set_mem_access_default(xch, domain_id,
+ XENMEM_access_rwx);
shutting_down = 1;
}
--
1.9.1
next prev parent reply other threads:[~2014-07-08 2:50 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-08 2:50 [PATCH RFC v2 0/4] Add mem_access support for PV domains Aravindh Puthiyaparambil
2014-07-08 2:50 ` [PATCH RFC v2 1/4] x86/mm: Shadow and p2m changes for PV mem_access Aravindh Puthiyaparambil
2014-07-24 14:29 ` Jan Beulich
2014-07-24 23:34 ` Aravindh Puthiyaparambil (aravindp)
2014-07-25 7:19 ` Jan Beulich
2014-07-25 21:39 ` Aravindh Puthiyaparambil (aravindp)
2014-07-28 6:49 ` Jan Beulich
2014-07-28 21:14 ` Aravindh Puthiyaparambil (aravindp)
2014-07-30 4:05 ` Aravindh Puthiyaparambil (aravindp)
2014-07-30 7:11 ` Jan Beulich
2014-07-30 18:35 ` Aravindh Puthiyaparambil (aravindp)
2014-08-01 6:39 ` Jan Beulich
2014-08-01 18:08 ` Aravindh Puthiyaparambil (aravindp)
2014-08-04 7:03 ` Jan Beulich
2014-08-05 0:14 ` Aravindh Puthiyaparambil (aravindp)
2014-08-05 6:33 ` Jan Beulich
2014-08-13 22:14 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 2:29 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 9:34 ` Andrew Cooper
2014-08-22 10:02 ` Jan Beulich
2014-08-22 10:14 ` Andrew Cooper
2014-08-22 18:28 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 18:52 ` Andrew Cooper
2014-08-25 12:45 ` Gianluca Guida
2014-08-25 13:01 ` Jan Beulich
2014-08-25 13:02 ` Andrew Cooper
2014-08-25 13:59 ` Gianluca Guida
2014-08-22 15:33 ` Jan Beulich
2014-08-22 19:07 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 19:24 ` Andrew Cooper
2014-08-22 19:48 ` Aravindh Puthiyaparambil (aravindp)
2014-08-22 20:02 ` Andrew Cooper
2014-08-22 20:13 ` Aravindh Puthiyaparambil (aravindp)
2014-08-25 7:34 ` Jan Beulich
2014-08-25 7:33 ` Jan Beulich
2014-08-25 12:49 ` Andrew Cooper
2014-08-25 13:09 ` Jan Beulich
2014-08-25 16:56 ` Aravindh Puthiyaparambil (aravindp)
2014-08-26 7:08 ` Jan Beulich
2014-08-26 22:27 ` Aravindh Puthiyaparambil (aravindp)
2014-08-26 23:30 ` Andrew Cooper
2014-08-28 9:34 ` Tim Deegan
2014-08-28 18:33 ` Aravindh Puthiyaparambil (aravindp)
2014-08-27 6:33 ` Jan Beulich
2014-08-27 7:49 ` Tim Deegan
2014-08-27 17:29 ` Aravindh Puthiyaparambil (aravindp)
2014-08-25 17:44 ` Andrew Cooper
2014-08-26 7:12 ` Jan Beulich
2014-08-25 7:29 ` Jan Beulich
2014-08-25 16:40 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 9:14 ` Tim Deegan
2014-08-28 18:31 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 19:00 ` Tim Deegan
2014-08-28 19:23 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 20:37 ` Tim Deegan
2014-08-28 21:35 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 22:20 ` Aravindh Puthiyaparambil (aravindp)
2014-08-29 9:52 ` Tim Deegan
2014-08-29 17:52 ` Aravindh Puthiyaparambil (aravindp)
2014-08-29 19:03 ` Aravindh Puthiyaparambil (aravindp)
2014-09-01 10:38 ` Jan Beulich
2014-09-02 21:57 ` Aravindh Puthiyaparambil (aravindp)
2014-09-03 8:31 ` Jan Beulich
2014-09-03 18:50 ` Aravindh Puthiyaparambil (aravindp)
2014-09-04 6:39 ` Jan Beulich
2014-09-04 18:24 ` Aravindh Puthiyaparambil (aravindp)
2014-09-05 8:11 ` Jan Beulich
2014-09-05 22:49 ` Aravindh Puthiyaparambil (aravindp)
[not found] ` <20140904083906.GA86555@deinos.phlegethon.org>
[not found] ` <540849430200007800030C47@mail.emea.novell.com>
2014-09-11 19:40 ` Aravindh Puthiyaparambil (aravindp)
2014-09-12 7:21 ` Jan Beulich
2014-09-12 18:01 ` Aravindh Puthiyaparambil (aravindp)
2014-08-28 9:09 ` Tim Deegan
2014-08-28 18:23 ` Aravindh Puthiyaparambil (aravindp)
2014-07-08 2:50 ` [PATCH RFC v2 2/4] x86/mem_access: mem_access and mem_event changes to support PV domains Aravindh Puthiyaparambil
2014-07-24 14:38 ` Jan Beulich
2014-07-24 23:52 ` Aravindh Puthiyaparambil (aravindp)
2014-07-25 7:23 ` Jan Beulich
2014-07-25 21:47 ` Aravindh Puthiyaparambil (aravindp)
2014-07-28 6:56 ` Jan Beulich
2014-07-28 21:16 ` Aravindh Puthiyaparambil (aravindp)
2014-07-08 2:50 ` [PATCH RFC v2 3/4] tools/libxc: Add APIs for PV mem_access Aravindh Puthiyaparambil
2014-07-08 2:50 ` Aravindh Puthiyaparambil [this message]
2014-07-08 16:27 ` [PATCH RFC v2 0/4] Add mem_access support for PV domains Konrad Rzeszutek Wilk
2014-07-08 17:57 ` Aravindh Puthiyaparambil (aravindp)
2014-07-09 0:31 ` Aravindh Puthiyaparambil (aravindp)
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=1404787805-4540-5-git-send-email-aravindp@cisco.com \
--to=aravindp@cisco.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xenproject.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).