xen/arm: p2m: Reduce the locking section in get_page_from_gva
authorJulien Grall <julien.grall@arm.com>
Mon, 16 Jul 2018 17:27:01 +0000 (18:27 +0100)
committerJulien Grall <julien.grall@arm.com>
Wed, 22 Aug 2018 15:32:02 +0000 (16:32 +0100)
The p2m lock is only necessary to prevent gvirt_to_maddr failing when
break-before-make sequence is used in the P2M update concurrently on
another pCPU. So reduce the locking section.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/arch/arm/p2m.c

index 14791388add96736c9a7fa6983f7897105468d73..5ca7ffe41bfdd57168455986ffb4fc191a45d4ec 100644 (file)
@@ -1415,9 +1415,13 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
     if ( v != current )
         return NULL;
 
+    /*
+     * The lock is here to protect us against the break-before-make
+     * sequence used when updating the entry.
+     */
     p2m_read_lock(p2m);
-
     par = gvirt_to_maddr(va, &maddr, flags);
+    p2m_read_unlock(p2m);
 
     if ( par )
     {
@@ -1445,8 +1449,6 @@ struct page_info *get_page_from_gva(struct vcpu *v, vaddr_t va,
     }
 
 err:
-    p2m_read_unlock(p2m);
-
     if ( !page && p2m->mem_access_enabled )
         page = p2m_mem_access_check_and_get_page(va, flags, v);