From: Gavin Shan <shangw@linux.vnet.ibm.com>
To: kvm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org
Cc: aik@ozlabs.ru, alex.williamson@redhat.com,
Gavin Shan <shangw@linux.vnet.ibm.com>
Subject: [PATCH 3/3] VFIO: Direct access config reg without capability
Date: Fri, 15 Mar 2013 15:26:30 +0800 [thread overview]
Message-ID: <1363332390-12754-4-git-send-email-shangw@linux.vnet.ibm.com> (raw)
In-Reply-To: <1363332390-12754-1-git-send-email-shangw@linux.vnet.ibm.com>
The config registers in [0, 0x40] is being supported by VFIO. Apart
from that, the other config registers should be coverred by PCI or
PCIe capability. However, there might have some PCI devices (be2net)
who has config registers (0x7c) out of [0, 0x40], and don't have
corresponding PCI or PCIe capability. VFIO will return 0x0 on reading
those registers and writing is dropped. It caused the be2net driver
fails to be loaded because 0x0 returned from its config register 0x7c.
The patch changes the behaviour so that those config registers out
of [0, 0x40] and don't have corresponding PCI or PCIe capability
will be accessed directly.
Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>
---
drivers/vfio/pci/vfio_pci_config.c | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
index 964ff22..5ea3afb 100644
--- a/drivers/vfio/pci/vfio_pci_config.c
+++ b/drivers/vfio/pci/vfio_pci_config.c
@@ -1471,18 +1471,27 @@ static ssize_t vfio_config_do_rw(struct vfio_pci_device *vdev, char __user *buf,
cap_id = vdev->pci_config_map[*ppos / 4];
+ /*
+ * Some PCI device config registers might not be coverred by
+ * capability and useful. We will enable direct access to
+ * those registers.
+ */
if (cap_id == PCI_CAP_ID_INVALID) {
- if (iswrite)
- return ret; /* drop */
-
- /*
- * Per PCI spec 3.0, section 6.1, reads from reserved and
- * unimplemented registers return 0
- */
- if (copy_to_user(buf, &val, count))
- return -EFAULT;
-
- return ret;
+ if (iswrite) {
+ if (copy_from_user(&val, buf, count))
+ return -EFAULT;
+ ret = vfio_user_config_write(vdev->pdev, (int)(*ppos),
+ val, count);
+ return ret ? ret : count;
+ } else {
+ ret = vfio_user_config_read(vdev->pdev, (int)(*ppos),
+ &val, count);
+ if (ret)
+ return ret;
+ if (copy_to_user(buf, &val, count))
+ return -EFAULT;
+ return count;
+ }
}
/*
--
1.7.5.4
next prev parent reply other threads:[~2013-03-15 7:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-15 7:26 [PATCH 0/3] VFIO change for EEH support Gavin Shan
2013-03-15 7:26 ` [PATCH 1/3] VFIO: Architecture dependent VFIO device operations Gavin Shan
2013-03-15 7:26 ` [PATCH 2/3] VFIO: VFIO_DEVICE_SET_ADDR_MAPPING command Gavin Shan
2013-03-15 19:29 ` Alex Williamson
2013-03-16 1:34 ` Gavin Shan
2013-03-16 5:37 ` Benjamin Herrenschmidt
2013-03-18 21:01 ` Alex Williamson
2013-03-19 3:24 ` Gavin Shan
2013-03-19 4:18 ` Alex Williamson
2013-03-19 4:45 ` Benjamin Herrenschmidt
2013-03-20 18:48 ` Alex Williamson
2013-03-20 19:31 ` Benjamin Herrenschmidt
2013-03-20 19:46 ` Alex Williamson
2013-03-21 2:09 ` Gavin Shan
2013-03-15 7:26 ` Gavin Shan [this message]
2013-03-15 19:41 ` [PATCH 3/3] VFIO: Direct access config reg without capability Alex Williamson
2013-03-16 3:34 ` Gavin Shan
2013-03-16 5:30 ` Benjamin Herrenschmidt
2013-03-18 21:15 ` Alex Williamson
2013-03-21 0:58 ` Alex Williamson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363332390-12754-4-git-send-email-shangw@linux.vnet.ibm.com \
--to=shangw@linux.vnet.ibm.com \
--cc=aik@ozlabs.ru \
--cc=alex.williamson@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).