]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/mm: Put the gfn on all paths after get_gfn_query()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 20 Nov 2018 13:58:10 +0000 (14:58 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Nov 2018 13:58:10 +0000 (14:58 +0100)
c/s 7867181b2 "x86/PoD: correctly handle non-order-0 decrease-reservation
requests" introduced an early exit in guest_remove_page() for unexpected p2m
types.  However, get_gfn_query() internally takes the p2m lock, and must be
matched with a put_gfn() call later.

Fix the erroneous comment beside the declaration of get_gfn_query().

This is XSA-277.

Reported-by: Paul Durrant <paul.durrant@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/memory.c
xen/include/asm-x86/p2m.h

index b68efd4d9fe240a3f05390f12387a994a270d2cb..e894eba672c8a02ff1a3c72ad50bf176050db396 100644 (file)
@@ -305,7 +305,11 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
 #ifdef CONFIG_X86
     mfn = get_gfn_query(d, gmfn, &p2mt);
     if ( unlikely(p2mt == p2m_invalid) || unlikely(p2mt == p2m_mmio_dm) )
+    {
+        put_gfn(d, gmfn);
+
         return -ENOENT;
+    }
 
     if ( unlikely(p2m_is_paging(p2mt)) )
     {
index ac33f5086b6cb3e884b680318cad1860089201d0..6d849a5ebdeef9e78392544fb9b10fe66ff32a9d 100644 (file)
@@ -448,10 +448,7 @@ static inline mfn_t __nonnull(3) get_gfn_type(
     return get_gfn_type_access(p2m_get_hostp2m(d), gfn, t, &a, q, NULL);
 }
 
-/* Syntactic sugar: most callers will use one of these. 
- * N.B. get_gfn_query() is the _only_ one guaranteed not to take the
- * p2m lock; none of the others can be called with the p2m or paging
- * lock held. */
+/* Syntactic sugar: most callers will use one of these. */
 #define get_gfn(d, g, t)         get_gfn_type((d), (g), (t), P2M_ALLOC)
 #define get_gfn_query(d, g, t)   get_gfn_type((d), (g), (t), 0)
 #define get_gfn_unshare(d, g, t) get_gfn_type((d), (g), (t), \