Skip to contentSkip to conversation

xen/altp2m: set access_required properly for all altp2ms

PATCH In review Razvan Cojocaru 5 participants 8 messages Jun 28, 2018 – Jul 23, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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.

---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Tamas K Lengyel <[email protected]>
---
Changes since V2:
- Renamed arch_domain_set_access_required() to arch_p2m_set_access_required() (requested by Wei Liu).
- Added ASSERT(atomic_read(&d->pause_count)) to arch_p2m_set_access_required() (requested by Wei Liu).

---
 xen/arch/arm/mem_access.c    |  6 ++++++
 xen/arch/x86/mm/mem_access.c | 20 ++++++++++++++++++++
 xen/arch/x86/mm/p2m.c        |  3 ++-
 xen/common/domctl.c          |  4 ++--
 xen/include/xen/domain.h     |  2 ++
 5 files changed, 32 insertions(+), 3 deletions(-)
xen/arch/arm/mem_access.c +6 -0
index ae2686f..ba4ec78 100644
@@ -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
xen/arch/x86/mm/mem_access.c +20 -0
index c0cd017..464be49 100644
@@ -465,6 +465,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
xen/arch/x86/mm/p2m.c +2 -1
index c53cab4..8e9fbb5 100644
@@ -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);
     }
 
xen/common/domctl.c +2 -2
index 9b7bc08..789b30d 100644
@@ -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;
xen/include/xen/domain.h +2 -0
index 177cb35..f35e360 100644
@@ -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);
 
Signature · 7 lines
2.7.4


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Acked-by on v3 1/1
#1 lore raw
Quoted 9 lines · Razvan Cojocaru

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.

LGTM

Quoted 125 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Tamas K Lengyel <[email protected]>
---
Changes since V2:
- Renamed arch_domain_set_access_required() to arch_p2m_set_access_required() (requested by Wei Liu).
- Added ASSERT(atomic_read(&d->pause_count)) to arch_p2m_set_access_required() (requested by Wei Liu).

---
 xen/arch/arm/mem_access.c    |  6 ++++++
 xen/arch/x86/mm/mem_access.c | 20 ++++++++++++++++++++
 xen/arch/x86/mm/p2m.c        |  3 ++-
 xen/common/domctl.c          |  4 ++--
 xen/include/xen/domain.h     |  2 ++
 5 files changed, 32 insertions(+), 3 deletions(-)
xen/arch/arm/mem_access.c +6 -0
index ae2686f..ba4ec78 100644
@@ -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
xen/arch/x86/mm/mem_access.c +20 -0
index c0cd017..464be49 100644
@@ -465,6 +465,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
xen/arch/x86/mm/p2m.c +2 -1
index c53cab4..8e9fbb5 100644
@@ -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);
     }
 
xen/common/domctl.c +2 -2
index 9b7bc08..789b30d 100644
@@ -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;
xen/include/xen/domain.h +2 -1
index 177cb35..f35e360 100644
@@ -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);
 
--
Quoted 1 line

2.7.4

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#2 lore raw
Quoted 10 lines · Tamas K Lengyel
Quoted 8 lines · Razvan Cojocaru

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.

Quoted 5 lines
Quoted 1 line

LGTM

Thanks Tamas!

Does the patch need additional action before it can go in (sorry for the noise if it only hasn't gone in because it at the back of the queue).

Thanks,
Razvan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#3 lore raw
Quoted 14 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:35, <[email protected]> wrote:
Quoted 12 lines · Tamas K Lengyel
Quoted 9 lines · Razvan Cojocaru

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.

Quoted 8 lines
Quoted 3 lines

LGTM

Thanks Tamas!

Does the patch need additional action before it can go in (sorry for the noise if it only hasn't gone in because it at the back of the queue).

Once again - George's ack is missing. Please remember that generally it's the submitter to chase ack-s, not reviewers or committers.

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#4 lore raw
Quoted 18 lines · Jan Beulich
Quoted 18 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:35, <[email protected]> wrote:
Quoted 15 lines · Tamas K Lengyel
Quoted 9 lines · Razvan Cojocaru

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.

LGTM

Quoted 7 lines
Quoted 4 lines

Thanks Tamas!

Does the patch need additional action before it can go in (sorry for the noise if it only hasn't gone in because it at the back of the queue).

Once again - George's ack is missing. Please remember that generally it's the submitter to chase ack-s, not reviewers or committers.

Do we need Julien's ack too?

-George

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Acked-by
#5 lore raw

Hi,

Quoted 21 lines · George Dunlap
Quoted 20 lines · Jan Beulich
Quoted 20 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:35, <[email protected]> wrote:
Quoted 10 lines · Tamas K Lengyel
Quoted 8 lines · Razvan Cojocaru

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.

Quoted 5 lines
Quoted 1 line

LGTM

Thanks Tamas!

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Does the patch need additional action before it can go in (sorry for the noise if it only hasn't gone in because it at the back of the queue).

Once again - George's ack is missing. Please remember that generally it's the submitter to chase ack-s, not reviewers or committers.

Do we need Julien's ack too?

Ravzan and Tamas are maintaining arm/mem_access.c. So Tamas's ack should be enough here. Just in case:

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#6 lore raw
Quoted 28 lines · Julien Grall

Hi,

Quoted 25 lines · George Dunlap
Quoted 24 lines · Jan Beulich
Quoted 23 lines
Quoted 1 line
Quoted 1 line · On 16.07.18 at 10:35, <[email protected]> wrote:
Quoted 10 lines · Tamas K Lengyel
Quoted 8 lines · Razvan Cojocaru

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.

Quoted 5 lines
Quoted 1 line

LGTM

Thanks Tamas!

Does the patch need additional action before it can go in (sorry for the
noise if it only hasn't gone in because it at the back of the queue).

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Once again - George's ack is missing. Please remember that generally it's the submitter to chase ack-s, not reviewers or committers.

Do we need Julien's ack too?

Ravzan and Tamas are maintaining arm/mem_access.c. So Tamas's ack should be enough here.

Ah, got it.

Quoted 3 lines

Just in case:

Thanks.
-G

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v3 1/1
#7 lore raw
In reply to Razvan Cojocaru
Quoted 8 lines · Razvan Cojocaru

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.

Quoted 117 lines

---
Cc: Stefano Stabellini <[email protected]>
Cc: Julien Grall <[email protected]>
Cc: Andrew Cooper <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Ian Jackson <[email protected]>
Cc: Jan Beulich <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: Tim Deegan <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: George Dunlap <[email protected]>
Cc: Tamas K Lengyel <[email protected]>
---
Changes since V2:
- Renamed arch_domain_set_access_required() to arch_p2m_set_access_required() (requested by Wei Liu).
- Added ASSERT(atomic_read(&d->pause_count)) to arch_p2m_set_access_required() (requested by Wei Liu).

---
 xen/arch/arm/mem_access.c    |  6 ++++++
 xen/arch/x86/mm/mem_access.c | 20 ++++++++++++++++++++
 xen/arch/x86/mm/p2m.c        |  3 ++-
 xen/common/domctl.c          |  4 ++--
 xen/include/xen/domain.h     |  2 ++
 5 files changed, 32 insertions(+), 3 deletions(-)
xen/arch/arm/mem_access.c +6 -0
index ae2686f..ba4ec78 100644
@@ -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
xen/arch/x86/mm/mem_access.c +20 -0
index c0cd017..464be49 100644
@@ -465,6 +465,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
xen/arch/x86/mm/p2m.c +2 -1
index c53cab4..8e9fbb5 100644
@@ -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);
     }
 
xen/common/domctl.c +2 -2
index 9b7bc08..789b30d 100644
@@ -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;
xen/include/xen/domain.h +0 -0
index 177cb35..f35e360 100644

xen/include/xen/domain.h void arch_domain_unpause(struct domain *d); · line 73

Quoted 8 lines
xen/include/xen/domain.h +2 -0
@@ -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);
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel