From patchwork Mon Oct 3 12:41:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 677718 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3snhlL1TT1z9ryv for ; Mon, 3 Oct 2016 23:52:13 +1100 (AEDT) Received: from localhost ([::1]:36941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br2j4-0006fM-F0 for incoming@patchwork.ozlabs.org; Mon, 03 Oct 2016 08:52:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br2Yk-0005yQ-LQ for qemu-devel@nongnu.org; Mon, 03 Oct 2016 08:41:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1br2Yi-0006wh-LQ for qemu-devel@nongnu.org; Mon, 03 Oct 2016 08:41:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1br2Yi-0006wR-FR for qemu-devel@nongnu.org; Mon, 03 Oct 2016 08:41:28 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA31980087; Mon, 3 Oct 2016 12:41:27 +0000 (UTC) Received: from localhost.redhat.com (vpn1-5-72.ams2.redhat.com [10.36.5.72]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u93CfJGG008953; Mon, 3 Oct 2016 08:41:26 -0400 From: Eric Auger To: eric.auger@redhat.com, eric.auger.pro@gmail.com, qemu-devel@nongnu.org, alex.williamson@redhat.com, armbru@redhat.com Date: Mon, 3 Oct 2016 12:41:04 +0000 Message-Id: <1475498477-2695-5-git-send-email-eric.auger@redhat.com> In-Reply-To: <1475498477-2695-1-git-send-email-eric.auger@redhat.com> References: <1475498477-2695-1-git-send-email-eric.auger@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 03 Oct 2016 12:41:27 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 04/17] vfio/pci: Pass an error object to vfio_msix_early_setup X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" Pass an error object to prepare for migration to VFIO-PCI realize. The returned value will be removed later on. We now format an error in case of reading failure for - the MSIX flags - the MSIX table, - the MSIX PBA. Signed-off-by: Eric Auger --- v1 -> v2: - this patch now comes before the actual realize migration - mention in the commit message we are no more silent on above errors --- hw/vfio/pci.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 8f825bd..d1967a2 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1277,7 +1277,7 @@ static void vfio_pci_fixup_msix_region(VFIOPCIDevice *vdev) * need to first look for where the MSI-X table lives. So we * unfortunately split MSI-X setup across two functions. */ -static int vfio_msix_early_setup(VFIOPCIDevice *vdev) +static int vfio_msix_early_setup(VFIOPCIDevice *vdev, Error **errp) { uint8_t pos; uint16_t ctrl; @@ -1292,16 +1292,19 @@ static int vfio_msix_early_setup(VFIOPCIDevice *vdev) if (pread(fd, &ctrl, sizeof(ctrl), vdev->config_offset + pos + PCI_MSIX_FLAGS) != sizeof(ctrl)) { + error_setg_errno(errp, errno, "failed to read PCI MSIX FLAGS"); return -errno; } if (pread(fd, &table, sizeof(table), vdev->config_offset + pos + PCI_MSIX_TABLE) != sizeof(table)) { + error_setg_errno(errp, errno, "failed to read PCI MSIX TABLE"); return -errno; } if (pread(fd, &pba, sizeof(pba), vdev->config_offset + pos + PCI_MSIX_PBA) != sizeof(pba)) { + error_setg_errno(errp, errno, "failed to read PCI MSIX PBA"); return -errno; } @@ -1332,8 +1335,8 @@ static int vfio_msix_early_setup(VFIOPCIDevice *vdev) (vdev->device_id & 0xff00) == 0x5800) { msix->pba_offset = 0x1000; } else { - error_report("vfio: Hardware reports invalid configuration, " - "MSIX PBA outside of specified BAR"); + error_setg(errp, "hardware reports invalid configuration, " + "MSIX PBA outside of specified BAR"); g_free(msix); return -EINVAL; } @@ -2657,9 +2660,9 @@ static int vfio_initfn(PCIDevice *pdev) vfio_pci_size_rom(vdev); - ret = vfio_msix_early_setup(vdev); - if (ret) { - return ret; + ret = vfio_msix_early_setup(vdev, &err); + if (err) { + goto error; } vfio_bars_setup(vdev);