From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAgsm-0004L0-Kc for qemu-devel@nongnu.org; Mon, 12 Jan 2015 10:26:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YAgsh-0007dZ-Lb for qemu-devel@nongnu.org; Mon, 12 Jan 2015 10:26:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YAgsh-0007dR-Cb for qemu-devel@nongnu.org; Mon, 12 Jan 2015 10:26:15 -0500 Message-ID: <1421076367.6130.13.camel@redhat.com> From: Alex Williamson Date: Mon, 12 Jan 2015 08:26:07 -0700 In-Reply-To: <1e75bc42628775555cabe140c8438af0093d4ead.1421028274.git.chen.fan.fnst@cn.fujitsu.com> References: <1e75bc42628775555cabe140c8438af0093d4ead.1421028274.git.chen.fan.fnst@cn.fujitsu.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH 3/4] vfio-pci: add aer capability support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Fan Cc: qemu-devel@nongnu.org On Mon, 2015-01-12 at 11:04 +0800, Chen Fan wrote: This patch isn't trivial enough for a blank commit log. Why do we need to make those bits emulated? Do we only care about AER for now? > Signed-off-by: Chen Fan > --- > hw/vfio/pci.c | 40 ++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c > index b4e73d1..0ee6326 100644 > --- a/hw/vfio/pci.c > +++ b/hw/vfio/pci.c > @@ -2667,6 +2667,41 @@ static int vfio_add_capabilities(VFIOPCIDevice *vdev) > return vfio_add_std_cap(vdev, pdev->config[PCI_CAPABILITY_LIST]); > } > > +static int vfio_add_ext_capabilities(VFIOPCIDevice *vdev) > +{ > + PCIDevice *pdev = &vdev->pdev; > + PCIExpressDevice *exp; > + uint32_t header; > + uint16_t next = PCI_CONFIG_SPACE_SIZE; > + > + if (pci_config_size(pdev) <= PCI_CONFIG_SPACE_SIZE) { > + return 0; > + } > + > + header = pci_get_long(pdev->config + next); > + while (header) { > + switch (PCI_EXT_CAP_ID(header)) { > + case PCI_EXT_CAP_ID_ERR: > + exp = &pdev->exp; > + exp->aer_cap = next; > + > + /* enable the error report */ > + vfio_add_emulated_long(vdev, exp->exp_cap + PCI_EXP_DEVCTL, > + PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | > + PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE, ~0); > + break; > + }; > + > + next = PCI_EXT_CAP_NEXT(header); > + if (!next) { > + return 0; > + } > + header = pci_get_long(pdev->config + next); > + } > + > + return 0; > +} > + > static void vfio_pci_pre_reset(VFIOPCIDevice *vdev) > { > PCIDevice *pdev = &vdev->pdev; > @@ -3293,6 +3328,11 @@ static int vfio_initfn(PCIDevice *pdev) > goto out_teardown; > } > > + ret = vfio_add_ext_capabilities(vdev); > + if (ret) { > + goto out_teardown; > + } > + > /* QEMU emulates all of MSI & MSIX */ > if (pdev->cap_present & QEMU_PCI_CAP_MSIX) { > memset(vdev->emulated_config_bits + pdev->msix_cap, 0xff,