kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, jan.kiszka@siemens.com,
	shashidhar.patil@gmail.com
Subject: [PATCH 3/9] pci-assign: Update MSI-X MMIO to Memory API
Date: Sat, 28 Jan 2012 07:21:52 -0700	[thread overview]
Message-ID: <20120128142151.25681.74407.stgit@bling.home> (raw)
In-Reply-To: <20120128142104.25681.93072.stgit@bling.home>

Stop using compatibility mode and at the same time fix available
access sizes.  The PCI spec indicates that the MSI-X table may
only be accessed as DWORD or QWORD.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 hw/device-assignment.c |   56 +++++++++++++-----------------------------------
 1 files changed, 15 insertions(+), 41 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index b176375..1fc7ffa 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1437,62 +1437,36 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
     return 0;
 }
 
-static uint32_t msix_mmio_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t msix_mmio_read(void *opaque, target_phys_addr_t addr,
+                               unsigned size)
 {
     AssignedDevice *adev = opaque;
-    unsigned int offset = addr & 0xfff;
-    void *page = adev->msix_table_page;
-    uint32_t val = 0;
+    uint64_t val;
 
-    memcpy(&val, (void *)((char *)page + offset), 4);
+    memcpy(&val, (void *)((uint8_t *)adev->msix_table_page + addr), size);
 
     return val;
 }
 
-static uint32_t msix_mmio_readb(void *opaque, target_phys_addr_t addr)
-{
-    return ((msix_mmio_readl(opaque, addr & ~3)) >>
-            (8 * (addr & 3))) & 0xff;
-}
-
-static uint32_t msix_mmio_readw(void *opaque, target_phys_addr_t addr)
-{
-    return ((msix_mmio_readl(opaque, addr & ~3)) >>
-            (8 * (addr & 3))) & 0xffff;
-}
-
-static void msix_mmio_writel(void *opaque,
-                             target_phys_addr_t addr, uint32_t val)
+static void msix_mmio_write(void *opaque, target_phys_addr_t addr,
+                            uint64_t val, unsigned size)
 {
     AssignedDevice *adev = opaque;
-    unsigned int offset = addr & 0xfff;
-    void *page = adev->msix_table_page;
-
-    DEBUG("write to MSI-X entry table mmio offset 0x%lx, val 0x%x\n",
-		    addr, val);
-    memcpy((void *)((char *)page + offset), &val, 4);
-}
 
-static void msix_mmio_writew(void *opaque,
-                             target_phys_addr_t addr, uint32_t val)
-{
-    msix_mmio_writel(opaque, addr & ~3,
-                     (val & 0xffff) << (8*(addr & 3)));
-}
+    DEBUG("write to MSI-X entry table mmio offset 0x%lx, val 0x%lx\n",
+          addr, val);
 
-static void msix_mmio_writeb(void *opaque,
-                             target_phys_addr_t addr, uint32_t val)
-{
-    msix_mmio_writel(opaque, addr & ~3,
-                     (val & 0xff) << (8*(addr & 3)));
+    memcpy((void *)((uint8_t *)adev->msix_table_page + addr), &val, size);
 }
 
 static const MemoryRegionOps msix_mmio_ops = {
-    .old_mmio = {
-        .read = { msix_mmio_readb, msix_mmio_readw, msix_mmio_readl, },
-        .write = { msix_mmio_writeb, msix_mmio_writew, msix_mmio_writel, },
-    },
+    .read = msix_mmio_read,
+    .write = msix_mmio_write,
     .endianness = DEVICE_NATIVE_ENDIAN,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 8,
+    },
 };
 
 static int assigned_dev_register_msix_mmio(AssignedDevice *dev)


  parent reply	other threads:[~2012-01-28 14:21 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-28 14:21 [PATCH 0/9] pci-assign: 64bit MMIO + better MSI-X table support Alex Williamson
2012-01-28 14:21 ` [PATCH 1/9] pci-assign: Optionally enable 64bit BARs in guest Alex Williamson
2012-01-31 12:40   ` Avi Kivity
2012-01-31 12:45     ` Jan Kiszka
2012-01-31 12:51       ` Avi Kivity
2012-01-31 12:57         ` Jan Kiszka
2012-01-31 13:10           ` Avi Kivity
2012-01-31 13:21             ` Jan Kiszka
2012-01-31 13:33               ` Avi Kivity
2012-01-31 21:08                 ` Alex Williamson
2012-01-31 21:14                   ` Michael S. Tsirkin
2012-02-01  9:03                     ` Avi Kivity
2012-02-01 10:03                       ` Michael S. Tsirkin
2012-02-01 13:55                       ` Alex Williamson
2012-02-01 15:18                         ` Michael S. Tsirkin
2012-02-01 15:24                           ` Alex Williamson
2012-01-28 14:21 ` [PATCH 2/9] pci-assign: Fix warnings with DEBUG enabled Alex Williamson
2012-01-28 14:21 ` Alex Williamson [this message]
2012-01-31 12:45   ` [PATCH 3/9] pci-assign: Update MSI-X MMIO to Memory API Avi Kivity
2012-01-31 21:13     ` Alex Williamson
2012-02-01  4:22       ` Alex Williamson
2012-02-01  9:04         ` Avi Kivity
2012-02-01 13:56           ` Alex Williamson
2012-01-28 14:21 ` [PATCH 4/9] pci-assign: Use struct for MSI-X table Alex Williamson
2012-01-31 17:40   ` Michael S. Tsirkin
2012-01-31 19:05     ` Alex Williamson
2012-01-31 20:00       ` Michael S. Tsirkin
2012-01-31 21:17         ` Alex Williamson
2012-01-31 21:24           ` Michael S. Tsirkin
2012-01-31 21:30             ` Alex Williamson
2012-01-28 14:22 ` [PATCH 5/9] pci-assign: Only calculate maximum MSI-X vector entries once Alex Williamson
2012-01-31 20:18   ` Michael S. Tsirkin
2012-01-31 20:31     ` Alex Williamson
2012-01-31 20:56       ` Michael S. Tsirkin
2012-01-28 14:22 ` [PATCH 6/9] pci-assign: Proper initialization for MSI-X table Alex Williamson
2012-01-31 17:40   ` Michael S. Tsirkin
2012-01-31 19:07     ` Alex Williamson
2012-01-31 19:12       ` Michael S. Tsirkin
2012-01-31 19:16         ` Jan Kiszka
2012-01-31 20:19           ` Michael S. Tsirkin
2012-01-31 21:06             ` Alex Williamson
2012-01-28 14:22 ` [PATCH 7/9] pci-assign: Allocate entries for all MSI-X vectors Alex Williamson
2012-01-28 14:22 ` [PATCH 8/9] pci-assign: Use MSIX_PAGE_SIZE Alex Williamson
2012-01-28 14:22 ` [PATCH 9/9] pci-assign: Update MSI-X config based on table writes Alex Williamson
2012-01-31 12:50   ` Avi Kivity
2012-01-30 10:11 ` [PATCH 0/9] pci-assign: 64bit MMIO + better MSI-X table support Jan Kiszka
2012-01-30 13:44   ` Alex Williamson
2012-01-31 12:52     ` Avi Kivity
2012-01-31 12:56       ` Jan Kiszka
2012-02-06 15:55 ` Shashidhar Patil
2012-02-06 17:29   ` Alex Williamson
2012-02-09 16:23     ` Shashidhar Patil
2012-02-09 17:23       ` Alex Williamson
2012-02-12 16:30         ` Shashidhar Patil

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=20120128142151.25681.74407.stgit@bling.home \
    --to=alex.williamson@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=kvm@vger.kernel.org \
    --cc=shashidhar.patil@gmail.com \
    /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).