From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai7sg-00038B-7U for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:00:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ai7sb-0005ZI-7P for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:00:58 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47207) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ai7sb-0005ZE-1o for qemu-devel@nongnu.org; Mon, 21 Mar 2016 18:00:53 -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 8EE8E6445E for ; Mon, 21 Mar 2016 22:00:51 +0000 (UTC) From: Bandan Das Date: Mon, 21 Mar 2016 18:00:50 -0400 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH] vfio: add check for memory region overflow condition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel , Alex Williamson 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" -- 2.7.0