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 07/22] Add support for transitive grants.

These allow a domain A which has been granted access on a page of
domain B's memory to issue domain C with a copy-grant on the same
page.  This is useful e.g. for forwarding packets between domains.

Signed-off-by: Steven Smith <steven.smith@xxxxxxxxxx>
---
 drivers/xen/core/gnttab.c |   32 ++++++++++++++++++++++++++++++++
 include/xen/gnttab.h      |    8 ++++++++
 2 files changed, 40 insertions(+), 0 deletions(-)

diff --git a/drivers/xen/core/gnttab.c b/drivers/xen/core/gnttab.c
index b32dd5d..02790fe 100644
--- a/drivers/xen/core/gnttab.c
+++ b/drivers/xen/core/gnttab.c
@@ -237,6 +237,38 @@ int gnttab_subpage_grants_available(void)
 }
 EXPORT_SYMBOL_GPL(gnttab_subpage_grants_available);
 
+int gnttab_grant_foreign_access_trans(domid_t domid, int flags,
+                                    domid_t trans_domid,
+                                    grant_ref_t trans_gref)
+{
+       int ref;
+
+       if (unlikely((ref = get_free_entry()) < 0))
+               return -ENOSPC;
+
+       gnttab_grant_foreign_access_ref_trans(ref, domid, flags,
+                                             trans_domid, trans_gref);
+
+       return ref;
+}
+EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_trans);
+
+void gnttab_grant_foreign_access_ref_trans(grant_ref_t ref, domid_t domid,
+                                         int flags,
+                                         domid_t trans_domid,
+                                         grant_ref_t trans_gref)
+{
+       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].transitive.trans_domid = trans_domid;
+       shared.v2[ref].transitive.gref = trans_gref;
+       shared.v2[ref].hdr.domid = domid;
+       wmb();
+       shared.v2[ref].hdr.flags = GTF_permit_access | GTF_transitive | flags;
+}
+EXPORT_SYMBOL_GPL(gnttab_grant_foreign_access_ref_trans);
+
 int gnttab_query_foreign_access(grant_ref_t ref)
 {
        u16 nflags;
diff --git a/include/xen/gnttab.h b/include/xen/gnttab.h
index 90201da..30be437 100644
--- a/include/xen/gnttab.h
+++ b/include/xen/gnttab.h
@@ -58,6 +58,10 @@ int gnttab_grant_foreign_access_subpage(domid_t domid, 
unsigned long frame,
                                        int flags, unsigned page_off,
                                        unsigned length);
 
+void gnttab_grant_foreign_access_ref_trans(grant_ref_t ref, domid_t domid,
+                                          int flags,
+                                          domid_t trans_domid,
+                                          grant_ref_t trans_gref);
 
 /*
  * Are sub-page grants available on this version of Xen?  Returns 1 if
@@ -114,6 +118,10 @@ 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_access_ref_trans(grant_ref_t ref, domid_t domid,
+                                          int flags,
+                                          domid_t trans_domid,
+                                          grant_ref_t trans_gref);
 
 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>