xen/arm: implement gnttab_create_shared_page and gnttab_shared_gmfn
authorStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 15 Feb 2013 13:32:21 +0000 (13:32 +0000)
committerStefano Stabellini <stefano.stabellini@eu.citrix.com>
Fri, 15 Feb 2013 13:32:21 +0000 (13:32 +0000)
Introduce a simple pfn array, grant_table_gpfn, to keep track of the
grant table pages mapped in guest gpfn space.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Campbell <ian.campbell@citrix.com>
xen/arch/arm/domain.c
xen/arch/arm/mm.c
xen/include/asm-arm/domain.h
xen/include/asm-arm/grant_table.h

index 0aa261abde6b43ee552c3a5d929f2b5ba3b89f88..e37ec5498daf4146aaaa25c30e23b35accab6291 100644 (file)
@@ -6,6 +6,7 @@
 #include <xen/wait.h>
 #include <xen/errno.h>
 #include <xen/bitops.h>
+#include <xen/grant_table.h>
 
 #include <asm/current.h>
 #include <asm/event.h>
@@ -329,11 +330,13 @@ struct domain *alloc_domain_struct(void)
     d = alloc_xenheap_pages(0, 0);
     if ( d != NULL )
         clear_page(d);
+    d->arch.grant_table_gpfn = xmalloc_array(xen_pfn_t, max_nr_grant_frames);
     return d;
 }
 
 void free_domain_struct(struct domain *d)
 {
+    xfree(d->arch.grant_table_gpfn);
     free_xenheap_page(d);
 }
 
index 1c78d034b389edd728ce7adf2f6aeade7be9da46..6b2d2b54e983967d112c60d5a6e3fae16971193f 100644 (file)
@@ -595,6 +595,8 @@ static int xenmem_add_to_physmap_one(
             if ( idx < nr_grant_frames(d->grant_table) )
                 mfn = virt_to_mfn(d->grant_table->shared_raw[idx]);
         }
+        
+        d->arch.grant_table_gpfn[idx] = gpfn;
 
         spin_unlock(&d->grant_table->lock);
         break;
index 577ad1969a1c22f254463624cdef06b5b99bb24c..29fe80821e9cd89334eabd133efecee7062f6655 100644 (file)
@@ -39,6 +39,7 @@ struct arch_domain
 {
     struct p2m_domain p2m;
     struct hvm_domain hvm_domain;
+    xen_pfn_t *grant_table_gpfn;
 
     struct {
         /*
index e49aa8d1157d70cb456c54fa752c85e2fa7f5a25..3fa270d8590e2f04e89ced45df34b17157f69c1d 100644 (file)
@@ -15,8 +15,6 @@ int replace_grant_host_mapping(unsigned long gpaddr, unsigned long mfn,
         unsigned long new_gpaddr, unsigned int flags);
 void gnttab_mark_dirty(struct domain *d, unsigned long l);
 #define gnttab_create_status_page(d, t, i) do {} while (0)
-#define gnttab_create_shared_page(d, t, i) do {} while (0)
-#define gnttab_shared_gmfn(d, t, i) (0)
 #define gnttab_status_gmfn(d, t, i) (0)
 #define gnttab_release_host_mappings(domain) 1
 static inline int replace_grant_supported(void)
@@ -24,6 +22,17 @@ static inline int replace_grant_supported(void)
     return 1;
 }
 
+#define gnttab_create_shared_page(d, t, i)                               \
+    do {                                                                 \
+        share_xen_page_with_guest(                                       \
+            virt_to_page((char *)(t)->shared_raw[i]),                    \
+            (d), XENSHARE_writable);                                     \
+    } while ( 0 )
+
+#define gnttab_shared_gmfn(d, t, i)                                      \
+    ( ((i >= nr_grant_frames(d->grant_table)) &&                         \
+     (i < max_nr_grant_frames)) ? 0 : (d->arch.grant_table_gpfn[i]))
+
 #endif /* __ASM_GRANT_TABLE_H__ */
 /*
  * Local variables: