From: Aravindh Puthiyaparambil <aravindp@cisco.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v3 2/5] tools/libxc: Make the mem_access APIs generic
Date: Tue, 15 Apr 2014 17:25:23 -0700 [thread overview]
Message-ID: <1397607926-15298-3-git-send-email-aravindp@cisco.com> (raw)
In-Reply-To: <1397607926-15298-1-git-send-email-aravindp@cisco.com>
Add new xc_[sg]et_mem_access() APIs.
Signed-off-by: Aravindh Puthiyaparambil <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 version 2 of the patch:
1. Move removal of xc_hvm_[sg]et_mem_access() APIs into a seperate
patch.
Changes from version 1 of the patch:
1. Remove unused "gfn" from the parameter list of
xc_mem_access_resume().
2. Use structure initialisation.
3. Write "access" back only in the case of do_memory_op returning
success.
4. Fix formatting.
Changes from the RFC version of the patch:
1. Remove xc_mem_access_memop() wrapper.
2. Remove xc_hvm_[sg]et_mem_access() APIs.
diff --git a/tools/libxc/xc_mem_access.c b/tools/libxc/xc_mem_access.c
index a50c145..f436e69 100644
--- a/tools/libxc/xc_mem_access.c
+++ b/tools/libxc/xc_mem_access.c
@@ -22,7 +22,7 @@
*/
#include "xc_private.h"
-
+#include <xen/memory.h>
int xc_mem_access_enable(xc_interface *xch, domid_t domain_id,
uint32_t *port)
@@ -47,12 +47,54 @@ int xc_mem_access_disable(xc_interface *xch, domid_t domain_id)
NULL);
}
-int xc_mem_access_resume(xc_interface *xch, domid_t domain_id, unsigned long gfn)
+int xc_mem_access_resume(xc_interface *xch, domid_t domain_id)
+{
+ xen_mem_access_op_t mao =
+ {
+ .op = XENMEM_access_op_resume,
+ .domid = domain_id
+ };
+
+ return do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao));
+}
+
+int xc_set_mem_access(xc_interface *xch,
+ domid_t domain_id,
+ xenmem_access_t access,
+ uint64_t first_pfn,
+ uint32_t nr)
{
- return xc_mem_event_memop(xch, domain_id,
- XENMEM_access_op_resume,
- XENMEM_access_op,
- gfn, NULL);
+ xen_mem_access_op_t mao =
+ {
+ .op = XENMEM_access_op_set_access,
+ .domid = domain_id,
+ .access = access,
+ .pfn = first_pfn,
+ .nr = nr
+ };
+
+ return do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao));
+}
+
+int xc_get_mem_access(xc_interface *xch,
+ domid_t domain_id,
+ uint64_t pfn,
+ xenmem_access_t *access)
+{
+ int rc;
+ xen_mem_access_op_t mao =
+ {
+ .op = XENMEM_access_op_get_access,
+ .domid = domain_id,
+ .pfn = pfn
+ };
+
+ rc = do_memory_op(xch, XENMEM_access_op, &mao, sizeof(mao));
+
+ if ( rc == 0 )
+ *access = mao.access;
+
+ return rc;
}
/*
diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h
index e3a32f2..3513ddb 100644
--- a/tools/libxc/xenctrl.h
+++ b/tools/libxc/xenctrl.h
@@ -2059,8 +2059,22 @@ int xc_mem_paging_load(xc_interface *xch, domid_t domain_id,
*/
int xc_mem_access_enable(xc_interface *xch, domid_t domain_id, uint32_t *port);
int xc_mem_access_disable(xc_interface *xch, domid_t domain_id);
-int xc_mem_access_resume(xc_interface *xch, domid_t domain_id,
- unsigned long gfn);
+int xc_mem_access_resume(xc_interface *xch, domid_t domain_id);
+
+/*
+ * Set a range of memory to a specific access.
+ * Allowed types are XENMEM_access_default, XENMEM_access_n, any combination of
+ * XENMEM_access_ + (rwx), and XENMEM_access_rx2rw
+ */
+int xc_set_mem_access(xc_interface *xch, domid_t domain_id,
+ xenmem_access_t access, uint64_t first_pfn,
+ uint32_t nr);
+
+/*
+ * Gets the mem access for the given page (returned in access on success)
+ */
+int xc_get_mem_access(xc_interface *xch, domid_t domain_id,
+ uint64_t pfn, xenmem_access_t *access);
/***
* Memory sharing operations.
--
1.8.3.2
next prev parent reply other threads:[~2014-04-16 0:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-16 0:25 [PATCH v3 0/5] Make mem_access APIs and hypercalls generic Aravindh Puthiyaparambil
2014-04-16 0:25 ` [PATCH v3 1/5] x86/mem_access: Make the mem_access ops generic Aravindh Puthiyaparambil
2014-04-16 9:24 ` Jan Beulich
2014-04-16 0:25 ` Aravindh Puthiyaparambil [this message]
2014-04-16 15:58 ` [PATCH v3 2/5] tools/libxc: Make the mem_access APIs generic Ian Campbell
2014-04-17 9:46 ` Tamas Lengyel
2014-04-17 15:52 ` Aravindh Puthiyaparambil (aravindp)
2014-04-17 20:50 ` Tamas Lengyel
2014-04-16 0:25 ` [PATCH v3 3/5] tools/xen-access: Use the new mem_access APIs Aravindh Puthiyaparambil
2014-04-16 15:58 ` Ian Campbell
2014-04-16 0:25 ` [PATCH v3 4/5] tools/libxc: Remove xc_hvm_[sg]et_mem_access() APIs Aravindh Puthiyaparambil
2014-04-16 15:59 ` Ian Campbell
2014-04-16 0:25 ` [PATCH v3 5/5] x86/mem_access: Deprecate the HVM mem_access ops Aravindh Puthiyaparambil
2014-04-16 9:28 ` Jan Beulich
2014-04-16 15:18 ` Aravindh Puthiyaparambil (aravindp)
2014-04-16 16:11 ` Jan Beulich
2014-04-24 11:13 ` [PATCH v3 0/5] Make mem_access APIs and hypercalls generic Tim Deegan
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=1397607926-15298-3-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).