From patchwork Thu May 10 20:08:24 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kiszka X-Patchwork-Id: 158394 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 F0526B6FED for ; Fri, 11 May 2012 07:03:14 +1000 (EST) Received: from localhost ([::1]:55469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSZg7-0004dI-Dp for incoming@patchwork.ozlabs.org; Thu, 10 May 2012 16:09:35 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSZfR-0002d2-6g for qemu-devel@nongnu.org; Thu, 10 May 2012 16:08:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SSZfO-0003s7-OI for qemu-devel@nongnu.org; Thu, 10 May 2012 16:08:52 -0400 Received: from goliath.siemens.de ([192.35.17.28]:18149) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SSZfO-0003rc-Eb for qemu-devel@nongnu.org; Thu, 10 May 2012 16:08:50 -0400 Received: from mail1.siemens.de (localhost [127.0.0.1]) by goliath.siemens.de (8.13.6/8.13.6) with ESMTP id q4AK8lCV016355; Thu, 10 May 2012 22:08:47 +0200 Received: from mchn199C.mchp.siemens.de ([139.22.49.57]) by mail1.siemens.de (8.13.6/8.13.6) with SMTP id q4AK8Tfr009061; Thu, 10 May 2012 22:08:46 +0200 From: Jan Kiszka To: "Michael S. Tsirkin" Date: Thu, 10 May 2012 17:08:24 -0300 Message-Id: X-Mailer: git-send-email 1.7.3.4 In-Reply-To: References: In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 192.35.17.28 Cc: qemu-devel Subject: [Qemu-devel] [PATCH v2 08/10] msi: Guard msi/msix_write_config with msi_present 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 Terminate msi/msix_write_config early if support is not enabled. This allows to remove checks at the caller site if MSI is optional. Signed-off-by: Jan Kiszka --- hw/msi.c | 3 ++- hw/msix.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/msi.c b/hw/msi.c index b2903fc..da12f33 100644 --- a/hw/msi.c +++ b/hw/msi.c @@ -276,7 +276,8 @@ void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len) unsigned int vector; uint32_t pending; - if (!ranges_overlap(addr, len, dev->msi_cap, msi_cap_sizeof(flags))) { + if (!msi_present(dev) || + !ranges_overlap(addr, len, dev->msi_cap, msi_cap_sizeof(flags))) { return; } diff --git a/hw/msix.c b/hw/msix.c index 3835eaa..84915d8 100644 --- a/hw/msix.c +++ b/hw/msix.c @@ -157,7 +157,7 @@ void msix_write_config(PCIDevice *dev, uint32_t addr, int vector; bool was_masked; - if (!range_covers_byte(addr, len, enable_pos)) { + if (!msix_present(dev) || !range_covers_byte(addr, len, enable_pos)) { return; }