]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mm: move map_guest_l1e to pv/mm.c
authorWei Liu <wei.liu2@citrix.com>
Wed, 13 Sep 2017 16:18:59 +0000 (17:18 +0100)
committerWei Liu <wei.liu2@citrix.com>
Fri, 22 Sep 2017 15:31:50 +0000 (16:31 +0100)
And export the function via pv/mm.h.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/mm.c
xen/arch/x86/pv/Makefile
xen/arch/x86/pv/mm.c [new file with mode: 0644]
xen/arch/x86/pv/mm.h

index 38f079bfe388665f6d345c3e3be56c0dc252dce8..beab6065b060cffdad50a6ff51c8f5c47d868506 100644 (file)
@@ -527,35 +527,6 @@ void update_cr3(struct vcpu *v)
     make_cr3(v, cr3_mfn);
 }
 
-/*
- * Get a mapping of a PV guest's l1e for this linear address.  The return
- * pointer should be unmapped using unmap_domain_page().
- */
-static l1_pgentry_t *map_guest_l1e(unsigned long linear, mfn_t *gl1mfn)
-{
-    l2_pgentry_t l2e;
-
-    ASSERT(!paging_mode_translate(current->domain));
-    ASSERT(!paging_mode_external(current->domain));
-
-    if ( unlikely(!__addr_ok(linear)) )
-        return NULL;
-
-    /* Find this l1e and its enclosing l1mfn in the linear map. */
-    if ( __copy_from_user(&l2e,
-                          &__linear_l2_table[l2_linear_offset(linear)],
-                          sizeof(l2_pgentry_t)) )
-        return NULL;
-
-    /* Check flags that it will be safe to read the l1e. */
-    if ( (l2e_get_flags(l2e) & (_PAGE_PRESENT | _PAGE_PSE)) != _PAGE_PRESENT )
-        return NULL;
-
-    *gl1mfn = l2e_get_mfn(l2e);
-
-    return (l1_pgentry_t *)map_domain_page(*gl1mfn) + l1_table_offset(linear);
-}
-
 /*
  * Read the guest's l1e that maps this address, from the kernel-mode
  * page tables.
index 24af0b550e5a8e2c0bfbb23583e800868d26fc9c..d4fcc2ab949003c0c4ad4b13c60af70ce834620e 100644 (file)
@@ -7,6 +7,7 @@ obj-y += emul-priv-op.o
 obj-y += hypercall.o
 obj-y += iret.o
 obj-y += misc-hypercalls.o
+obj-y += mm.o
 obj-y += ro-page-fault.o
 obj-y += traps.o
 
diff --git a/xen/arch/x86/pv/mm.c b/xen/arch/x86/pv/mm.c
new file mode 100644 (file)
index 0000000..4bfa322
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * pv/mm.c
+ *
+ * Memory managment code for PV guests
+ *
+ * Copyright (c) 2002-2005 K A Fraser
+ * Copyright (c) 2004 Christian Limpach
+ *
+ * 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/>.
+ */
+
+#include <xen/guest_access.h>
+
+#include <asm/current.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))
+#undef page_to_mfn
+#define page_to_mfn(pg) _mfn(__page_to_mfn(pg))
+
+/*
+ * Get a mapping of a PV guest's l1e for this linear address.  The return
+ * pointer should be unmapped using unmap_domain_page().
+ */
+l1_pgentry_t *map_guest_l1e(unsigned long linear, mfn_t *gl1mfn)
+{
+    l2_pgentry_t l2e;
+
+    ASSERT(!paging_mode_translate(current->domain));
+    ASSERT(!paging_mode_external(current->domain));
+
+    if ( unlikely(!__addr_ok(linear)) )
+        return NULL;
+
+    /* Find this l1e and its enclosing l1mfn in the linear map. */
+    if ( __copy_from_user(&l2e,
+                          &__linear_l2_table[l2_linear_offset(linear)],
+                          sizeof(l2_pgentry_t)) )
+        return NULL;
+
+    /* Check flags that it will be safe to read the l1e. */
+    if ( (l2e_get_flags(l2e) & (_PAGE_PRESENT | _PAGE_PSE)) != _PAGE_PRESENT )
+        return NULL;
+
+    *gl1mfn = l2e_get_mfn(l2e);
+
+    return (l1_pgentry_t *)map_domain_page(*gl1mfn) + l1_table_offset(linear);
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
index ba4deee872dc59a3dd785907ca68b373f8ef1144..a494b448bfa3a5ef27993b338707e9347cd56455 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __PV_MM_H__
 #define __PV_MM_H__
 
+l1_pgentry_t *map_guest_l1e(unsigned long linear, mfn_t *gl1mfn);
+
 /* Read a PV guest's l1e that maps this linear address. */
 static inline l1_pgentry_t guest_get_eff_l1e(unsigned long linear)
 {