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

[Xen-devel] [PATCH V2 1/2] xen/altp2m: set access_required properly for all altp2ms



For the hostp2m, access_required starts off as 0, then it can be
set with xc_domain_set_access_required(). However, all the altp2ms
set it to 1 on init, and ignore both the hostp2m and the hypercall.
This patch sets access_required to the value from the hostp2m
on altp2m init, and propagates the values received via hypercall
to all the active altp2ms, when applicable.

Signed-off-by: Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>

---
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Julien Grall <julien.grall@xxxxxxx>
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: George Dunlap <George.Dunlap@xxxxxxxxxxxxx>
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Cc: Tim Deegan <tim@xxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
Cc: George Dunlap <george.dunlap@xxxxxxxxxxxxx>
Cc: Tamas K Lengyel <tamas@xxxxxxxxxxxxx>
---
Changes since V1:
 - Corrected typos in the commit message.
 - Moved arch_domain_set_access_required() to x86/mm/mem_access.c
   and arm/mem_access.c.
 - Fixed wrong tab type.
 - Removed the d->arch.altp2m_eptp[i] == mfn_x(INVALID_MFN) check.
 - Moved the setting of p2m_get_hostp2m(d)->access_required to
   the arch_domain_set_access_required() function.
---
 xen/arch/arm/mem_access.c    |  5 +++++
 xen/arch/x86/mm/mem_access.c | 18 ++++++++++++++++++
 xen/arch/x86/mm/p2m.c        |  3 ++-
 xen/common/domctl.c          |  4 ++--
 xen/include/xen/domain.h     |  2 ++
 5 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/mem_access.c b/xen/arch/arm/mem_access.c
index ae2686f..a59c6ef 100644
--- a/xen/arch/arm/mem_access.c
+++ b/xen/arch/arm/mem_access.c
@@ -453,6 +453,11 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn,
     return ret;
 }
 
+void arch_domain_set_access_required(struct domain *d, bool access_required)
+{
+    p2m_get_hostp2m(d)->access_required = access_required;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/mm/mem_access.c b/xen/arch/x86/mm/mem_access.c
index c0cd017..6811572 100644
--- a/xen/arch/x86/mm/mem_access.c
+++ b/xen/arch/x86/mm/mem_access.c
@@ -465,6 +465,24 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn, 
xenmem_access_t *access)
     return _p2m_get_mem_access(p2m, gfn, access);
 }
 
+void arch_domain_set_access_required(struct domain *d, bool access_required)
+{
+    unsigned int i;
+
+    p2m_get_hostp2m(d)->access_required = access_required;
+
+    if ( !altp2m_active(d) )
+        return;
+
+    for ( i = 0; i < MAX_ALTP2M; i++ )
+    {
+        struct p2m_domain *p2m = d->arch.altp2m_p2m[i];
+
+        if ( p2m )
+            p2m->access_required = access_required;
+    }
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index c53cab4..8e9fbb5 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -199,6 +199,7 @@ static int p2m_init_altp2m(struct domain *d)
 {
     unsigned int i;
     struct p2m_domain *p2m;
+    struct p2m_domain *hostp2m = p2m_get_hostp2m(d);
 
     mm_lock_init(&d->arch.altp2m_list_lock);
     for ( i = 0; i < MAX_ALTP2M; i++ )
@@ -210,7 +211,7 @@ static int p2m_init_altp2m(struct domain *d)
             return -ENOMEM;
         }
         p2m->p2m_class = p2m_alternate;
-        p2m->access_required = 1;
+        p2m->access_required = hostp2m->access_required;
         _atomic_set(&p2m->active_vcpus, 0);
     }
 
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 9b7bc08..37f174f 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -1092,8 +1092,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) 
u_domctl)
         else
         {
             domain_pause(d);
-            p2m_get_hostp2m(d)->access_required =
-                op->u.access_required.access_required;
+            arch_domain_set_access_required(d,
+                op->u.access_required.access_required);
             domain_unpause(d);
         }
         break;
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index 177cb35..9df53a6 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -66,6 +66,8 @@ void arch_domain_unpause(struct domain *d);
 
 int arch_domain_soft_reset(struct domain *d);
 
+void arch_domain_set_access_required(struct domain *d, bool access_required);
+
 int arch_set_info_guest(struct vcpu *, vcpu_guest_context_u);
 void arch_get_info_guest(struct vcpu *, vcpu_guest_context_u);
 
-- 
2.7.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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