WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 06/22] Add support for copy only (sub-page) grants. T

To: <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 06/22] Add support for copy only (sub-page) grants. These are like normal access grants, except:
From: <steven.smith@xxxxxxxxxx>
Date: Sun, 4 Oct 2009 16:03:59 +0100
Cc: keir.fraser@xxxxxxxxxx, Steven Smith <steven.smith@xxxxxxxxxx>, jean.guyader@xxxxxxxxxx
Delivery-date: Sun, 04 Oct 2009 08:13:45 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <cover.1254666837.git.ssmith@xxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <cover.1254666837.git.ssmith@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
-- 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

<Prev in Thread] Current Thread [Next in Thread>