From patchwork Tue Apr 23 16:27:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 238958 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 EDECC2C00D3 for ; Wed, 24 Apr 2013 02:28:31 +1000 (EST) Received: from localhost ([::1]:49471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUg50-0001Au-6g for incoming@patchwork.ozlabs.org; Tue, 23 Apr 2013 12:28:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:58147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUg4a-00013F-2t for qemu-devel@nongnu.org; Tue, 23 Apr 2013 12:28:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUg4Y-0001YL-3U for qemu-devel@nongnu.org; Tue, 23 Apr 2013 12:28:03 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:34975) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUg4X-0001Y4-R7 for qemu-devel@nongnu.org; Tue, 23 Apr 2013 12:28:02 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 23 Apr 2013 17:22:50 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 23 Apr 2013 17:22:48 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id DAEAB2190023; Tue, 23 Apr 2013 17:30:21 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3NGRmrJ55771160; Tue, 23 Apr 2013 16:27:48 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3NFBt6E005375; Tue, 23 Apr 2013 11:11:56 -0400 Received: from gondolin.boeblingen.de.ibm.com (dyn-9-152-224-122.boeblingen.de.ibm.com [9.152.224.122]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3NFBrkE005306; Tue, 23 Apr 2013 11:11:55 -0400 From: Cornelia Huck To: qemu-devel Date: Tue, 23 Apr 2013 18:27:49 +0200 Message-Id: <1366734469-23795-2-git-send-email-cornelia.huck@de.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1366734469-23795-1-git-send-email-cornelia.huck@de.ibm.com> References: <1366734469-23795-1-git-send-email-cornelia.huck@de.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13042316-1948-0000-0000-000004F4373B X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.110 Cc: Cornelia Huck , qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH] virtio-ccw: Check indicators location. 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 If a guest neglected to register (secondary) indicators but still runs with notifications enabled, we might end up writing to guest zero; avoid this by checking for valid indicators and only writing to the guest and generating an interrupt if indicators have been setup. Cc: qemu-stable@nongnu.org Signed-off-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 56539d3..1c6bd21 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -752,10 +752,16 @@ static void virtio_ccw_notify(DeviceState *d, uint16_t vector) } if (vector < VIRTIO_PCI_QUEUE_MAX) { + if (!dev->indicators) { + return; + } indicators = ldq_phys(dev->indicators); indicators |= 1ULL << vector; stq_phys(dev->indicators, indicators); } else { + if (!dev->indicators2) { + return; + } vector = 0; indicators = ldq_phys(dev->indicators2); indicators |= 1ULL << vector;