[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] x86/mm: carve out create_grant_pv_mapping



commit 1c1b764cbb33ff3a64e511ce87a5ffb771ed5930
Author:     Wei Liu <wei.liu2@xxxxxxxxxx>
AuthorDate: Fri Jul 7 14:04:18 2017 +0100
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Fri Aug 18 13:59:02 2017 +0100

    x86/mm: carve out create_grant_pv_mapping
    
    And at once make create_grant_host_mapping an inline function.  This
    requires making create_grant_{p2m,pv}_mapping non-static.  Provide
    {p2m,pv}/grant_table.h. Include the headers where necessary.
    
    The two functions create_grant_{p2m,pv}_mapping will be moved later in
    a dedicated patch with all their helpers.
    
    Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/mm.c                     | 16 +++++------
 xen/include/asm-x86/grant_table.h     | 16 +++++++++--
 xen/include/asm-x86/hvm/grant_table.h | 53 +++++++++++++++++++++++++++++++++++
 xen/include/asm-x86/pv/grant_table.h  | 52 ++++++++++++++++++++++++++++++++++
 4 files changed, 127 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 3677c3e..7582795 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -123,6 +123,9 @@
 #include <asm/io_apic.h>
 #include <asm/pci.h>
 
+#include <asm/hvm/grant_table.h>
+#include <asm/pv/grant_table.h>
+
 /* Override macros from asm/page.h to make them work with mfn_t */
 #undef mfn_to_page
 #define mfn_to_page(mfn) __mfn_to_page(mfn_x(mfn))
@@ -4023,9 +4026,9 @@ static int destroy_grant_va_mapping(
     return replace_grant_va_mapping(addr, frame, l1e_empty(), v);
 }
 
-static int create_grant_p2m_mapping(uint64_t addr, unsigned long frame,
-                                    unsigned int flags,
-                                    unsigned int cache_flags)
+int create_grant_p2m_mapping(uint64_t addr, unsigned long frame,
+                             unsigned int flags,
+                             unsigned int cache_flags)
 {
     p2m_type_t p2mt;
     int rc;
@@ -4046,15 +4049,12 @@ static int create_grant_p2m_mapping(uint64_t addr, 
unsigned long frame,
         return GNTST_okay;
 }
 
-int create_grant_host_mapping(uint64_t addr, unsigned long frame,
-                              unsigned int flags, unsigned int cache_flags)
+int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
+                            unsigned int flags, unsigned int cache_flags)
 {
     l1_pgentry_t pte;
     uint32_t grant_pte_flags;
 
-    if ( paging_mode_external(current->domain) )
-        return create_grant_p2m_mapping(addr, frame, flags, cache_flags);
-
     grant_pte_flags =
         _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_GNTTAB;
     if ( cpu_has_nx )
diff --git a/xen/include/asm-x86/grant_table.h 
b/xen/include/asm-x86/grant_table.h
index 1561bda..559ad2f 100644
--- a/xen/include/asm-x86/grant_table.h
+++ b/xen/include/asm-x86/grant_table.h
@@ -7,14 +7,26 @@
 #ifndef __ASM_GRANT_TABLE_H__
 #define __ASM_GRANT_TABLE_H__
 
+#include <asm/paging.h>
+
+#include <asm/hvm/grant_table.h>
+#include <asm/pv/grant_table.h>
+
 #define INITIAL_NR_GRANT_FRAMES 4
 
 /*
  * Caller must own caller's BIGLOCK, is responsible for flushing the TLB, and
  * must hold a reference to the page.
  */
-int create_grant_host_mapping(uint64_t addr, unsigned long frame,
-                             unsigned int flags, unsigned int cache_flags);
+static inline int create_grant_host_mapping(uint64_t addr, unsigned long frame,
+                                            unsigned int flags,
+                                            unsigned int cache_flags)
+{
+    if ( paging_mode_external(current->domain) )
+        return create_grant_p2m_mapping(addr, frame, flags, cache_flags);
+    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);
 
diff --git a/xen/include/asm-x86/hvm/grant_table.h 
b/xen/include/asm-x86/hvm/grant_table.h
new file mode 100644
index 0000000..83202c2
--- /dev/null
+++ b/xen/include/asm-x86/hvm/grant_table.h
@@ -0,0 +1,53 @@
+/*
+ * asm-x86/hvm/grant_table.h
+ *
+ * Grant table interfaces for HVM guests
+ *
+ * Copyright (C) 2017 Wei Liu <wei.liu2@xxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __X86_HVM_GRANT_TABLE_H__
+#define __X86_HVM_GRANT_TABLE_H__
+
+#ifdef CONFIG_HVM
+
+int create_grant_p2m_mapping(uint64_t addr, unsigned long frame,
+                             unsigned int flags,
+                             unsigned int cache_flags);
+
+#else
+
+#include <public/grant_table.h>
+
+static inline int create_grant_p2m_mapping(uint64_t addr, unsigned long frame,
+                                           unsigned int flags,
+                                           unsigned int cache_flags)
+{
+    return GNTST_general_error;
+}
+
+#endif
+
+#endif /* __X86_HVM_GRANT_TABLE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-x86/pv/grant_table.h 
b/xen/include/asm-x86/pv/grant_table.h
new file mode 100644
index 0000000..165ebce
--- /dev/null
+++ b/xen/include/asm-x86/pv/grant_table.h
@@ -0,0 +1,52 @@
+/*
+ * asm-x86/pv/grant_table.h
+ *
+ * Grant table interfaces for PV guests
+ *
+ * Copyright (C) 2017 Wei Liu <wei.liu2@xxxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms and conditions of the GNU General Public
+ * License, version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __X86_PV_GRANT_TABLE_H__
+#define __X86_PV_GRANT_TABLE_H__
+
+#ifdef CONFIG_PV
+
+int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
+                            unsigned int flags, unsigned int cache_flags);
+
+#else
+
+#include <public/grant_table.h>
+
+static inline int create_grant_pv_mapping(uint64_t addr, unsigned long frame,
+                                          unsigned int flags,
+                                          unsigned int cache_flags)
+{
+    return GNTST_general_error;
+}
+
+#endif
+
+#endif /* __X86_PV_GRANT_TABLE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.