x86/mm: carve out replace_grant_pv_mapping
authorWei Liu <wei.liu2@citrix.com>
Fri, 7 Jul 2017 13:50:36 +0000 (14:50 +0100)
committerWei Liu <wei.liu2@citrix.com>
Fri, 18 Aug 2017 12:59:05 +0000 (13:59 +0100)
And at once make it an inline function. Add declarations of
replace_grant_{p2m,pv}_mapping to respective header files.

The code movement will be done later.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm.c
xen/include/asm-x86/grant_table.h
xen/include/asm-x86/hvm/grant_table.h
xen/include/asm-x86/pv/grant_table.h

index 7582795a9e2edb9d4f4558181096b89bb4e5be96..d31669fc3be427a65bc0d308d31c8f8f1d6a0e9c 100644 (file)
@@ -4077,7 +4077,7 @@ int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
     return create_grant_va_mapping(addr, pte, current);
 }
 
-static int replace_grant_p2m_mapping(
+int replace_grant_p2m_mapping(
     uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags)
 {
     unsigned long gfn = (unsigned long)(addr >> PAGE_SHIFT);
@@ -4107,8 +4107,8 @@ static int replace_grant_p2m_mapping(
     return GNTST_okay;
 }
 
-int replace_grant_host_mapping(
-    uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags)
+int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
+                             uint64_t new_addr, unsigned int flags)
 {
     struct vcpu *curr = current;
     l1_pgentry_t *pl1e, ol1e;
@@ -4116,9 +4116,6 @@ int replace_grant_host_mapping(
     struct page_info *l1pg;
     int rc;
 
-    if ( paging_mode_external(current->domain) )
-        return replace_grant_p2m_mapping(addr, frame, new_addr, flags);
-
     if ( flags & GNTMAP_contains_pte )
     {
         if ( !new_addr )
index 559ad2f275e3f2e4e21e76e8b7adb8198d60f219..33b2f88b96e58fb86c936e1c4627f8d19b72c64f 100644 (file)
@@ -27,8 +27,14 @@ static inline int create_grant_host_mapping(uint64_t addr, unsigned long frame,
     return create_grant_pv_mapping(addr, frame, flags, cache_flags);
 }
 
-int replace_grant_host_mapping(
-    uint64_t addr, unsigned long frame, uint64_t new_addr, unsigned int flags);
+static inline int replace_grant_host_mapping(uint64_t addr, unsigned long frame,
+                                             uint64_t new_addr,
+                                             unsigned int flags)
+{
+    if ( paging_mode_external(current->domain) )
+        return replace_grant_p2m_mapping(addr, frame, new_addr, flags);
+    return replace_grant_pv_mapping(addr, frame, new_addr, flags);
+}
 
 #define gnttab_create_shared_page(d, t, i)                               \
     do {                                                                 \
index 83202c219c55d1bf21651a36d805074bfab8e581..711ce9b56024027fe2ab243cee35438079def23f 100644 (file)
@@ -26,6 +26,8 @@
 int create_grant_p2m_mapping(uint64_t addr, unsigned long frame,
                              unsigned int flags,
                              unsigned int cache_flags);
+int replace_grant_p2m_mapping(uint64_t addr, unsigned long frame,
+                              uint64_t new_addr, unsigned int flags);
 
 #else
 
@@ -38,6 +40,12 @@ static inline int create_grant_p2m_mapping(uint64_t addr, unsigned long frame,
     return GNTST_general_error;
 }
 
+static inline int replace_grant_p2m_mapping(uint64_t addr, unsigned long frame,
+                                            uint64_t new_addr, unsigned int flags)
+{
+    return GNTST_general_error;
+}
+
 #endif
 
 #endif /* __X86_HVM_GRANT_TABLE_H__ */
index 165ebce22f873f669c8819195dcbf4e449752570..556e68f0eb4382ff10ff48d7bff3246fdb72889d 100644 (file)
@@ -25,6 +25,8 @@
 
 int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
                             unsigned int flags, unsigned int cache_flags);
+int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
+                             uint64_t new_addr, unsigned int flags);
 
 #else
 
@@ -37,6 +39,12 @@ static inline int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
     return GNTST_general_error;
 }
 
+static inline int replace_grant_pv_mapping(uint64_t addr, unsigned long frame,
+                                           uint64_t new_addr, unsigned int flags)
+{
+    return GNTST_general_error;
+}
+
 #endif
 
 #endif /* __X86_PV_GRANT_TABLE_H__ */