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

[Xen-devel] [PATCH v4 21/31] x86/mm: add "pv_" prefix to new_guest_cr3



Also take the chance to change d to currd. This function can't be
moved yet. It can only be moved with other functions.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 xen/arch/x86/mm.c              | 19 ++++++++++---------
 xen/arch/x86/pv/emul-priv-op.c |  3 ++-
 xen/include/asm-x86/mm.h       |  1 -
 xen/include/asm-x86/pv/mm.h    |  7 +++++++
 4 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index ec523a4f51..928f4330e7 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2469,14 +2469,14 @@ int vcpu_destroy_pagetables(struct vcpu *v)
     return rc != -EINTR ? rc : -ERESTART;
 }
 
-int new_guest_cr3(unsigned long mfn)
+int pv_new_guest_cr3(unsigned long mfn)
 {
     struct vcpu *curr = current;
-    struct domain *d = curr->domain;
+    struct domain *currd = curr->domain;
     int rc;
     unsigned long old_base_mfn;
 
-    if ( is_pv_32bit_domain(d) )
+    if ( is_pv_32bit_domain(currd) )
     {
         unsigned long gt_mfn = pagetable_get_pfn(curr->arch.guest_table);
         l4_pgentry_t *pl4e = map_domain_page(_mfn(gt_mfn));
@@ -2522,9 +2522,10 @@ int new_guest_cr3(unsigned long mfn)
         return 0;
     }
 
-    rc = paging_mode_refcounts(d)
-         ? (get_page_from_mfn(_mfn(mfn), d) ? 0 : -EINVAL)
-         : get_page_and_type_from_mfn(_mfn(mfn), PGT_root_page_table, d, 0, 1);
+    rc = paging_mode_refcounts(currd)
+         ? (get_page_from_mfn(_mfn(mfn), currd) ? 0 : -EINVAL)
+         : get_page_and_type_from_mfn(_mfn(mfn), PGT_root_page_table,
+                                      currd, 0, 1);
     switch ( rc )
     {
     case 0:
@@ -2540,7 +2541,7 @@ int new_guest_cr3(unsigned long mfn)
 
     invalidate_shadow_ldt(curr, 0);
 
-    if ( !VM_ASSIST(d, m2p_strict) && !paging_mode_refcounts(d) )
+    if ( !VM_ASSIST(currd, m2p_strict) && !paging_mode_refcounts(currd) )
         fill_ro_mpt(mfn);
     curr->arch.guest_table = pagetable_from_pfn(mfn);
     update_cr3(curr);
@@ -2551,7 +2552,7 @@ int new_guest_cr3(unsigned long mfn)
     {
         struct page_info *page = mfn_to_page(old_base_mfn);
 
-        if ( paging_mode_refcounts(d) )
+        if ( paging_mode_refcounts(currd) )
             put_page(page);
         else
             switch ( rc = put_page_and_type_preemptible(page) )
@@ -2876,7 +2877,7 @@ long do_mmuext_op(
             else if ( unlikely(paging_mode_translate(currd)) )
                 rc = -EINVAL;
             else
-                rc = new_guest_cr3(op.arg1.mfn);
+                rc = pv_new_guest_cr3(op.arg1.mfn);
             break;
 
         case MMUEXT_NEW_USER_BASEPTR: {
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index d50f51944f..d549c7ce1f 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -32,6 +32,7 @@
 #include <asm/hypercall.h>
 #include <asm/mc146818rtc.h>
 #include <asm/p2m.h>
+#include <asm/pv/mm.h>
 #include <asm/pv/traps.h>
 #include <asm/shared.h>
 #include <asm/traps.h>
@@ -768,7 +769,7 @@ static int priv_op_write_cr(unsigned int reg, unsigned long 
val,
         page = get_page_from_gfn(currd, gfn, NULL, P2M_ALLOC);
         if ( !page )
             break;
-        rc = new_guest_cr3(page_to_mfn(page));
+        rc = pv_new_guest_cr3(page_to_mfn(page));
         put_page(page);
 
         switch ( rc )
diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h
index a6352e6fc9..521a8b1b7b 100644
--- a/xen/include/asm-x86/mm.h
+++ b/xen/include/asm-x86/mm.h
@@ -514,7 +514,6 @@ void audit_domains(void);
 
 #endif
 
-int new_guest_cr3(unsigned long pfn);
 void make_cr3(struct vcpu *v, unsigned long mfn);
 void update_cr3(struct vcpu *v);
 int vcpu_destroy_pagetables(struct vcpu *);
diff --git a/xen/include/asm-x86/pv/mm.h b/xen/include/asm-x86/pv/mm.h
index 4ecbf50b18..648b26d7d0 100644
--- a/xen/include/asm-x86/pv/mm.h
+++ b/xen/include/asm-x86/pv/mm.h
@@ -93,8 +93,12 @@ void pv_init_guest_l4_table(l4_pgentry_t[], const struct 
domain *,
                             bool zap_ro_mpt);
 void pv_arch_init_memory(void);
 
+int pv_new_guest_cr3(unsigned long pfn);
+
 #else
 
+#include <xen/errno.h>
+
 static inline void pv_get_guest_eff_l1e(unsigned long addr,
                                         l1_pgentry_t *eff_l1e)
 {}
@@ -118,6 +122,9 @@ static inline void pv_init_guest_l4_table(l4_pgentry_t[],
                                           const struct domain *,
                                           bool zap_ro_mpt) {}
 static inline void pv_arch_init_memory(void) {}
+
+static inline int pv_new_guest_cr3(unsigned long pfn) { return -EINVAL; }
+
 #endif
 
 #endif /* __X86_PV_MM_H__ */
-- 
2.11.0


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

 


Rackspace

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