From patchwork Wed Apr 25 09:13:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alon Levy X-Patchwork-Id: 154837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 48252B6FC4 for ; Wed, 25 Apr 2012 19:14:04 +1000 (EST) Received: from localhost ([::1]:54843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMyIT-0007zi-Uq for incoming@patchwork.ozlabs.org; Wed, 25 Apr 2012 05:14:01 -0400 Received: from eggs.gnu.org ([208.118.235.92]:44100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMyII-0007zB-0y for qemu-devel@nongnu.org; Wed, 25 Apr 2012 05:13:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SMyIB-0001cs-3a for qemu-devel@nongnu.org; Wed, 25 Apr 2012 05:13:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SMyIA-0001cb-SN for qemu-devel@nongnu.org; Wed, 25 Apr 2012 05:13:43 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3P9Dfbn013612 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 25 Apr 2012 05:13:41 -0400 Received: from garlic.redhat.com (vpn-202-70.tlv.redhat.com [10.35.202.70]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3P9DVQs024620; Wed, 25 Apr 2012 05:13:37 -0400 From: Alon Levy To: qemu-devel@nongnu.org, kraxel@redhat.com Date: Wed, 25 Apr 2012 12:13:17 +0300 Message-Id: <1335345205-8908-1-git-send-email-alevy@redhat.com> In-Reply-To: <4F967EEA.6000302@redhat.com> References: <4F967EEA.6000302@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/9] hw/qxl.c: qxl_phys2virt: replace panics with guest_bug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Alon Levy --- hw/qxl.c | 25 +++++++++++++++++++------ 1 file 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)