All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] x86/altp2m: use __get_gfn_type_access to avoid lock conflicts
@ 2016-08-10 15:00 Tamas K Lengyel
  2016-08-10 15:00 ` [PATCH v2 2/2] x86/altp2m: allow specifying external-only use-case Tamas K Lengyel
                   ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Tamas K Lengyel @ 2016-08-10 15:00 UTC (permalink / raw)
  To: xen-devel
  Cc: George Dunlap, Tamas K Lengyel, Tamas K Lengyel, Jan Beulich,
	Andrew Cooper

From: Tamas K Lengyel <tamas@tklengyel.com>

Use __get_gfn_type_access instead of get_gfn_type_access when checking
the hostp2m entries during altp2m mem_access setting and gfn remapping
to avoid a lock conflict which can make dom0 freeze. During mem_access
setting the hp2m is already locked. For gfn remapping we change the flow
to lock the hp2m before locking the ap2m.

Signed-off-by: Tamas K Lengyel <tamas.lengyel@zentific.com>
Reviewed-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
---
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>

v2: Lock the hp2m during gfn remapping
---
 xen/arch/x86/mm/p2m.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 812dbf6..1eeb934 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1787,8 +1787,8 @@ int p2m_set_altp2m_mem_access(struct domain *d, struct p2m_domain *hp2m,
     if ( !mfn_valid(mfn) )
     {
 
-        mfn = get_gfn_type_access(hp2m, gfn_l, &t, &old_a,
-                                  P2M_ALLOC | P2M_UNSHARE, &page_order);
+        mfn = __get_gfn_type_access(hp2m, gfn_l, &t, &old_a,
+                                    P2M_ALLOC | P2M_UNSHARE, &page_order, 0);
 
         rc = -ESRCH;
         if ( !mfn_valid(mfn) || t != p2m_ram_rw )
@@ -2548,6 +2548,7 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx,
     hp2m = p2m_get_hostp2m(d);
     ap2m = d->arch.altp2m_p2m[idx];
 
+    p2m_lock(hp2m);
     p2m_lock(ap2m);
 
     mfn = ap2m->get_entry(ap2m, gfn_x(old_gfn), &t, &a, 0, NULL, NULL);
@@ -2563,8 +2564,8 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx,
     /* Check host p2m if no valid entry in alternate */
     if ( !mfn_valid(mfn) )
     {
-        mfn = get_gfn_type_access(hp2m, gfn_x(old_gfn), &t, &a,
-                                  P2M_ALLOC | P2M_UNSHARE, &page_order);
+        mfn = __get_gfn_type_access(hp2m, gfn_x(old_gfn), &t, &a,
+                                    P2M_ALLOC | P2M_UNSHARE, &page_order, 0);
 
         if ( !mfn_valid(mfn) || t != p2m_ram_rw )
             goto out;
@@ -2606,6 +2607,7 @@ int p2m_change_altp2m_gfn(struct domain *d, unsigned int idx,
 
  out:
     p2m_unlock(ap2m);
+    p2m_unlock(hp2m);
     return rc;
 }
 
-- 
2.8.1


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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-09-06 17:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10 15:00 [PATCH v2 1/2] x86/altp2m: use __get_gfn_type_access to avoid lock conflicts Tamas K Lengyel
2016-08-10 15:00 ` [PATCH v2 2/2] x86/altp2m: allow specifying external-only use-case Tamas K Lengyel
2016-08-11 12:02   ` Jan Beulich
2016-08-11 14:37     ` Tamas K Lengyel
2016-08-11 14:51       ` Jan Beulich
2016-08-16 21:23         ` Daniel De Graaf
2016-08-11 17:17   ` Wei Liu
2016-08-11 17:50     ` Tamas K Lengyel
2016-08-11 17:57       ` Wei Liu
2016-08-12 11:24   ` Julien Grall
2016-08-12 14:51     ` Tamas K Lengyel
2016-08-12 15:02       ` Wei Liu
2016-08-11 11:57 ` [PATCH v2 1/2] x86/altp2m: use __get_gfn_type_access to avoid lock conflicts Jan Beulich
2016-08-31 21:02   ` Tamas K Lengyel
2016-09-06 17:02 ` George Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.