xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gnttab: lock the left grant table earlier in __gnttab_unmap_common()
@ 2013-11-11  2:07 Matt Wilson
  2013-11-11  2:14 ` Anthony Liguori
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Matt Wilson @ 2013-11-11  2:07 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, Keir Fraser, Jan Beulich, Matt Wilson,
	Anthony Liguori

From: Matt Wilson <msw@amazon.com>

Luckily today maptrack_limit never shrinks. But if at some point in
the future this were to change, checking maptrack_limit without
holding the grant table spinlock would no longer be safe.

Cc: xen-devel@lists.xenproject.org
Cc: Keir Fraser <keir@xen.org>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Anthony Liguori <aliguori@amazon.com>
Signed-off-by: Matt Wilson <msw@amazon.com>
---
 xen/common/grant_table.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 21c6a14..ef10ff4 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -842,15 +842,16 @@ __gnttab_unmap_common(
 
     op->frame = (unsigned long)(op->dev_bus_addr >> PAGE_SHIFT);
 
+    spin_lock(&lgt->lock);
     if ( unlikely(op->handle >= lgt->maptrack_limit) )
     {
+        spin_unlock(&lgt->lock);
         gdprintk(XENLOG_INFO, "Bad handle (%d).\n", op->handle);
         op->status = GNTST_bad_handle;
         return;
     }
 
     op->map = &maptrack_entry(lgt, op->handle);
-    spin_lock(&lgt->lock);
 
     if ( unlikely(!op->map->flags) )
     {
-- 
1.7.9.5

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

end of thread, other threads:[~2013-11-11 19:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-11  2:07 [PATCH] gnttab: lock the left grant table earlier in __gnttab_unmap_common() Matt Wilson
2013-11-11  2:14 ` Anthony Liguori
2013-11-11  9:58   ` Jan Beulich
2013-11-11 14:52     ` Anthony Liguori
2013-11-11 16:23       ` Jan Beulich
2013-11-11 16:45         ` Anthony Liguori
2013-11-11  9:53 ` Andrew Cooper
2013-11-11  9:53 ` Jan Beulich
2013-11-11 10:53 ` David Vrabel
2013-11-11 14:48   ` Anthony Liguori
2013-11-11 16:29     ` David Vrabel
2013-11-11 17:21   ` Matt Wilson
2013-11-11 19:56     ` [PATCH v2] gnttab: lock the local " Matt Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).