From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai8PQ-0003oF-Kk for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:34:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai8PN-0004Cd-EO for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:34:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60668) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai8PN-0004CZ-9J for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:34:45 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id B4A1746210 for ; Mon, 21 Mar 2016 22:34:44 +0000 (UTC) Date: Mon, 21 Mar 2016 16:34:41 -0600 From: Alex Williamson Message-ID: <20160321163441.29684cbf@t450s.home> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vfio: add check for memory region overflow condition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bandan Das Cc: qemu-devel On Mon, 21 Mar 2016 18:00:50 -0400 Bandan Das wrote: > vfio_listener_region_add for a iommu mr results in > an overflow assert since emulated iommu memory region is initialized > with UINT64_MAX. Add a check just like memory_region_size() > does. > > Signed-off-by: Bandan Das > --- > hw/vfio/common.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/hw/vfio/common.c b/hw/vfio/common.c > index fb588d8..269244b 100644 > --- a/hw/vfio/common.c > +++ b/hw/vfio/common.c > @@ -349,7 +349,12 @@ static void vfio_listener_region_add(MemoryListener *listener, > if (int128_ge(int128_make64(iova), llend)) { > return; > } > - end = int128_get64(llend); > + > + if (int128_eq(llend, int128_2_64())) { > + end = UINT64_MAX; > + } else { > + end = int128_get64(llend); > + } > > if ((iova < container->min_iova) || ((end - 1) > container->max_iova)) { > error_report("vfio: IOMMU container %p can't map guest IOVA region" But now all the calculations where we use end-1 are wrong. See the discussion with Pierre Morel in the January qemu-devel archives. There's a solution in there, but I never saw a follow-up from Pierre with a revised patch. Thanks, Alex