xen/altp2m: set access_required properly for all altp2ms
authorRazvan Cojocaru <rcojocaru@bitdefender.com>
Thu, 28 Jun 2018 07:54:01 +0000 (10:54 +0300)
committerGeorge Dunlap <george.dunlap@citrix.com>
Mon, 23 Jul 2018 11:15:09 +0000 (12:15 +0100)
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@bitdefender.com>
Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/mem_access.c
xen/arch/x86/mm/mem_access.c
xen/arch/x86/mm/p2m.c
xen/common/domctl.c
xen/include/xen/domain.h

index ae2686ffa23b6bf0e32b6caa6f0192b75d5a96bb..ba4ec780fd1549f34ae85be7e2625b80194a0e05 100644 (file)
@@ -453,6 +453,12 @@ int p2m_get_mem_access(struct domain *d, gfn_t gfn,
     return ret;
 }
 
+void arch_p2m_set_access_required(struct domain *d, bool access_required)
+{
+    ASSERT(atomic_read(&d->pause_count));
+    p2m_get_hostp2m(d)->access_required = access_required;
+}
+
 /*
  * Local variables:
  * mode: C
index febe38d8df026beb43e898162304558a4fa69e47..03a8641569590b20beefdb336576f1484eab64d9 100644 (file)
@@ -474,6 +474,26 @@ 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_p2m_set_access_required(struct domain *d, bool access_required)
+{
+    unsigned int i;
+
+    ASSERT(atomic_read(&d->pause_count));
+
+    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
index c53cab44d95945648c17d6dbcb396afc8daaa495..8e9fbb5a146fa0bcc7164021e94e066e80aac166 100644 (file)
@@ -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);
     }
 
index 39eb819ce11e5b990ab8b7b07be53297e5259b4c..a1d727091045a8529b6a9343bbf0021b5c2cf1a0 100644 (file)
@@ -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_p2m_set_access_required(d,
+                op->u.access_required.access_required);
             domain_unpause(d);
         }
         break;
index 177cb3521a8477e77deeaae22f39e21c89ee19f3..f35e3607d375de53811cc8c53f8f4dbd8b0f521b 100644 (file)
@@ -66,6 +66,8 @@ void arch_domain_unpause(struct domain *d);
 
 int arch_domain_soft_reset(struct domain *d);
 
+void arch_p2m_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);