Received: from eggs.gnu.org ([2001:4830:134:3::10]:45396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWEYv-0001ka-Hv for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:38:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YWEYq-0004aH-JT for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:38:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44430) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YWEYq-0004a9-Bu for qemu-devel@nongnu.org; Thu, 12 Mar 2015 21:38:48 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2D1clpC022086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 12 Mar 2015 21:38:47 -0400 From: Fam Zheng Date: Fri, 13 Mar 2015 09:38:39 +0800 Message-Id: <1426210723-16735-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v2 0/4] exec: Make bounce buffer thread safe List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini The global bounce buffer used for non-direct memory access is not thread-safe: 1) Access to "bounce" is not atomic. 2) Access to "map_client_list" is not atomic. 3) In dma_blk_cb, there is a race condition between: mem = dma_memory_map(dbs->sg->as, cur_addr, &cur_len, dbs->dir); /* ... */ cpu_register_map_client(dbs, continue_after_map_failure); Bounce may become available after dma_memory_map failed but before cpu_register_map_client is called. 4) The callback registered by cpu_register_map_client is not called in the right AioContext. This series fixes these issues respectively. Fam Zheng (4): exec: Atomic access to bounce buffer exec: Atomic access to map_client_list exec: Notify cpu_register_map_client caller if the bounce buffer is available dma-helpers: Move reschedule_dma BH to blk's AioContext dma-helpers.c | 4 +++- exec.c | 35 +++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 17 deletions(-) -- 1.9.3