-- They can't be used to map the page (so can only be used in a
GNTTABOP_copy hypercall).
-- It's possible to grant access with a finer granularity than whole
pages.
-- Xen guarantees that they can be revoked quickly (a normal map
grant can only be revoked with the cooperation of the domain which
has been granted access).
Signed-off-by: Steven Smith <steven.smith@xxxxxxxxxx>
---
drivers/xen/core/gnttab.c | 38 ++++++++++++++++++++++++++++++++++++++
include/xen/gnttab.h | 16 ++++++++++++++++
2 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/drivers/xen/core/gnttab.c b/drivers/xen/core/gnttab.c
index 5484e7e..b32dd5d 100644
--- a/drivers/xen/core/gnttab.c
+++ b/drivers/xen/core/gnttab.c
@@ -198,6 +198,44 @@ void gnttab_grant_foreign_access_ref(grant_ref_t ref,
domid_t domid,
}
EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref);
+int gnttab_grant_foreign_access_subpage(domid_t domid, unsigned long frame,
+ int flags, unsigned page_off,
+ unsigned length)
+{
+ int ref;
+
+ if (unlikely((ref = get_free_entry()) < 0))
+ return -ENOSPC;
+
+ gnttab_grant_foreign_access_ref_subpage(ref, domid, frame, flags,
+ page_off, length);
+
+ return ref;
+}
+EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_subpage);
+
+void gnttab_grant_foreign_access_ref_subpage(grant_ref_t ref, domid_t domid,
+ unsigned long frame, int flags,
+ unsigned page_off,
+ unsigned length)
+{
+ BUG_ON(flags & (GTF_accept_transfer | GTF_reading |
+ GTF_writing | GTF_sub_page | GTF_permit_access));
+ BUG_ON(grant_table_version == 1);
+ shared.v2[ref].sub_page.frame = frame;
+ shared.v2[ref].sub_page.page_off = page_off;
+ shared.v2[ref].sub_page.length = length;
+ shared.v2[ref].hdr.domid = domid;
+ wmb();
+ shared.v2[ref].hdr.flags = GTF_permit_access | GTF_sub_page | flags;
+}
+EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref_subpage);
+
+int gnttab_subpage_grants_available(void)
+{
+ return grant_table_version == 2;
+}
+EXPORT_SYMBOL_GPL(gnttab_subpage_grants_available);
int gnttab_query_foreign_access(grant_ref_t ref)
{
diff --git a/include/xen/gnttab.h b/include/xen/gnttab.h
index bde65fd..90201da 100644
--- a/include/xen/gnttab.h
+++ b/include/xen/gnttab.h
@@ -54,6 +54,18 @@ struct gnttab_free_callback {
int gnttab_grant_foreign_access(domid_t domid, unsigned long frame,
int flags);
+int gnttab_grant_foreign_access_subpage(domid_t domid, unsigned long frame,
+ int flags, unsigned page_off,
+ unsigned length);
+
+
+/*
+ * Are sub-page grants available on this version of Xen? Returns 1 if
+ * they are, and 0 if they're not.
+ */
+int gnttab_subpage_grants_available(void);
+
+
/*
* End access through the given grant reference, iff the grant entry is no
* longer in use. Return 1 if the grant entry was freed, 0 if it is still in
@@ -98,6 +110,10 @@ void gnttab_cancel_free_callback(struct
gnttab_free_callback *callback);
void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
unsigned long frame, int flags);
+void gnttab_grant_foreign_access_ref_subpage(grant_ref_t ref, domid_t domid,
+ unsigned long frame, int flags,
+ unsigned page_off,
+ unsigned length);
void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid,
unsigned long pfn);
--
1.6.3.1
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|