From 589671038593953215e303f6f44480a64c33d47b Mon Sep 17 00:00:00 2001 Message-Id: <589671038593953215e303f6f44480a64c33d47b.1350312451.git.minovotn@redhat.com> In-Reply-To: References: From: Alon Levy Date: Sun, 7 Oct 2012 15:31:47 +0200 Subject: [PATCH 10/27] hw/qxl.c: qxl_phys2virt: replace panics with guest_bug RH-Author: Alon Levy Message-id: <1349623920-19894-4-git-send-email-alevy@redhat.com> Patchwork-id: 42778 O-Subject: [PATCH RHEL-6.4 v2 03/16] hw/qxl.c: qxl_phys2virt: replace panics with guest_bug Bugzilla: 770842 RH-Acked-by: Gerd Hoffmann RH-Acked-by: Paolo Bonzini RH-Acked-by: Arnon Gilboa Signed-off-by: Alon Levy Signed-off-by: Gerd Hoffmann Upstream: 4b635c59b04cae594f49d9aa45d31b3f318def8f --- hw/qxl.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) Signed-off-by: Michal Novotny --- hw/qxl.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/hw/qxl.c b/hw/qxl.c index aef3486..41b55f3 100644 --- a/hw/qxl.c +++ b/hw/qxl.c @@ -1160,15 +1160,28 @@ void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL pqxl, int group_id) case MEMSLOT_GROUP_HOST: return (void*)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.11.7