From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:38450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su1b0-0000WZ-Bz for qemu-devel@nongnu.org; Wed, 25 Jul 2012 09:25:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su1av-0001F7-QO for qemu-devel@nongnu.org; Wed, 25 Jul 2012 09:25:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su1av-0001F0-Fz for qemu-devel@nongnu.org; Wed, 25 Jul 2012 09:25:41 -0400 Message-ID: <500FE623.8060304@redhat.com> Date: Wed, 25 Jul 2012 15:27:15 +0300 From: Avi Kivity MIME-Version: 1.0 References: <1343187070-27371-1-git-send-email-qemulist@gmail.com> <1343187070-27371-3-git-send-email-qemulist@gmail.com> <500FD13B.7040108@redhat.com> In-Reply-To: <500FD13B.7040108@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/5] exec.c: use refcnt to protect device during dispatching List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Liu Ping Fan Cc: kvm@vger.kernel.org, Jan Kiszka , Marcelo Tosatti , qemu-devel@nongnu.org, Anthony Liguori , Stefan Hajnoczi On 07/25/2012 01:58 PM, Avi Kivity wrote: >> while (len > 0) { >> page = addr & TARGET_PAGE_MASK; >> l = (page + TARGET_PAGE_SIZE) - addr; >> if (l > len) >> l = len; >> + >> + qemu_rwlock_rdlock_devtree(); >> section = phys_page_find(page >> TARGET_PAGE_BITS); > > Does the devtree lock also protect the data structures accessed by > phys_page_find()? Seems wrong. The right way is to object_ref() in core_region_add() and object_unref() in core_region_del(). We're guaranteed that mr->object is alive during _add(), and DeviceClass::unmap() ensures that the extra ref doesn't block destruction. -- error compiling committee.c: too many arguments to function