From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPrnP-0007eJ-Df for qemu-devel@nongnu.org; Thu, 03 May 2012 04:54:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SPrnJ-0005BT-Tk for qemu-devel@nongnu.org; Thu, 03 May 2012 04:53:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31237) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SPrnJ-000589-Kr for qemu-devel@nongnu.org; Thu, 03 May 2012 04:53:49 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q438rlO0015561 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 3 May 2012 04:53:48 -0400 From: Gerd Hoffmann Date: Thu, 3 May 2012 10:53:37 +0200 Message-Id: <1336035226-9174-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1336035226-9174-1-git-send-email-kraxel@redhat.com> References: <1336035226-9174-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 03/12] hw/qxl.c: qxl_phys2virt: replace panics with guest_bug List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Alon Levy , Gerd Hoffmann From: Alon Levy Signed-off-by: Alon Levy Signed-off-by: Gerd Hoffmann --- hw/qxl.c | 25 +++++++++++++++++++------ 1 files changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index c3540c3..9e8cdf3 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1097,15 +1097,28 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id) case MEMSLOT_GROUP_HOST: return (void *)(intptr_t)offset; case MEMSLOT_GROUP_GUEST: - PANIC_ON(slot >= NUM_MEMSLOTS); - PANIC_ON(!qxl->guest_slots[slot].active); - PANIC_ON(offset < qxl->guest_slots[slot].delta); + if (slot >= NUM_MEMSLOTS) { + qxl_guest_bug(qxl, "slot too large %d >= %d", slot, NUM_MEMSLOTS); + return NULL; + } + if (!qxl->guest_slots[slot].active) { + qxl_guest_bug(qxl, "inactive slot %d\n", slot); + return NULL; + } + if (offset < qxl->guest_slots[slot].delta) { + qxl_guest_bug(qxl, "slot %d offset %"PRIu64" < delta %"PRIu64"\n", + slot, offset, qxl->guest_slots[slot].delta); + return NULL; + } offset -= qxl->guest_slots[slot].delta; - PANIC_ON(offset > qxl->guest_slots[slot].size) + if (offset > qxl->guest_slots[slot].size) { + qxl_guest_bug(qxl, "slot %d offset %"PRIu64" > size %"PRIu64"\n", + slot, offset, qxl->guest_slots[slot].size); + return NULL; + } return qxl->guest_slots[slot].ptr + offset; - default: - PANIC_ON(1); } + return NULL; } static void qxl_create_guest_primary_complete(PCIQXLDevice *qxl) -- 1.7.1