* [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03
@ 2017-05-03 21:38 Alex Williamson
2017-05-03 21:38 ` [Qemu-devel] [PULL 1/3] vfio: Set MemoryRegionOps:max_access_size and min_access_size Alex Williamson
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Alex Williamson @ 2017-05-03 21:38 UTC (permalink / raw)
To: qemu-devel
The following changes since commit e619b14746e5d8c0e53061661fd0e1da01fd4d60:
Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging (2017-05-02 15:16:29 +0100)
are available in the git repository at:
git://github.com/awilliam/qemu-vfio.git tags/vfio-updates-20170503.0
for you to fetch changes up to 6e4e6f0d403b1fb25f9dfdbe17754c643997753d:
vfio/pci: Fix incorrect error message (2017-05-03 14:52:35 -0600)
----------------------------------------------------------------
VFIO fixes 2017-05-03
- Enable 8-byte memory region accesses (Jose Ricardo Ziviani)
- Fix vfio-pci error message (Dong Jia Shi)
----------------------------------------------------------------
Dong Jia Shi (1):
vfio/pci: Fix incorrect error message
Jose Ricardo Ziviani (2):
vfio: Set MemoryRegionOps:max_access_size and min_access_size
vfio: enable 8-byte reads/writes to vfio
hw/vfio/common.c | 14 ++++++++++++++
hw/vfio/pci.c | 4 ++--
2 files changed, 16 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 1/3] vfio: Set MemoryRegionOps:max_access_size and min_access_size
2017-05-03 21:38 [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Alex Williamson
@ 2017-05-03 21:38 ` Alex Williamson
2017-05-03 21:39 ` [Qemu-devel] [PULL 2/3] vfio: enable 8-byte reads/writes to vfio Alex Williamson
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2017-05-03 21:38 UTC (permalink / raw)
To: qemu-devel; +Cc: Jose Ricardo Ziviani
From: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Sets valid.max_access_size and valid.min_access_size to ensure safe
8-byte accesses to vfio. Today, 8-byte accesses are broken into pairs
of 4-byte calls that goes unprotected:
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc0, 0x2020c, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc4, 0xa0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
which occasionally leads to:
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc0, 0x2030c, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc0, 0x1000c, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc4, 0xb0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc4, 0xa0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
causing strange errors in guest OS. With this patch, such accesses
are protected by the same lock guard:
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc0, 0x2000c, 4)
vfio_region_write (0001:03:00.0:region1+0xc4, 0xb0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
This happens because the 8-byte write should be broken into 4-byte
writes by memory.c:access_with_adjusted_size() in order to be under
the same lock. Today, it's done in exec.c:address_space_write_continue()
which was able to handle only 4 bytes due to a zero'ed
valid.max_access_size (see exec.c:memory_access_size()).
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 6b33b9f55df1..6572c0744cb5 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -190,6 +190,10 @@ const MemoryRegionOps vfio_region_ops = {
.read = vfio_region_read,
.write = vfio_region_write,
.endianness = DEVICE_LITTLE_ENDIAN,
+ .valid = {
+ .min_access_size = 1,
+ .max_access_size = 8,
+ },
};
/*
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 2/3] vfio: enable 8-byte reads/writes to vfio
2017-05-03 21:38 [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Alex Williamson
2017-05-03 21:38 ` [Qemu-devel] [PULL 1/3] vfio: Set MemoryRegionOps:max_access_size and min_access_size Alex Williamson
@ 2017-05-03 21:39 ` Alex Williamson
2017-05-03 21:39 ` [Qemu-devel] [PULL 3/3] vfio/pci: Fix incorrect error message Alex Williamson
2017-05-05 15:14 ` [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2017-05-03 21:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Jose Ricardo Ziviani
From: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
This patch enables 8-byte writes and reads to VFIO. Such implemention
is already done but it's missing the 'case' to handle such accesses in
both vfio_region_write and vfio_region_read and the MemoryRegionOps:
impl.max_access_size and impl.min_access_size.
After this patch, 8-byte writes such as:
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc0, 0x4140c, 4)
vfio_region_write (0001:03:00.0:region1+0xc4, 0xa0000, 4)
qemu_mutex_unlock unlocked mutex 0x10905ad8
goes like this:
qemu_mutex_lock locked mutex 0x10905ad8
vfio_region_write (0001:03:00.0:region1+0xc0, 0xbfd0008, 8)
qemu_mutex_unlock unlocked mutex 0x10905ad8
Signed-off-by: Jose Ricardo Ziviani <joserz@linux.vnet.ibm.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 6572c0744cb5..a8f12eeb3589 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -119,6 +119,9 @@ void vfio_region_write(void *opaque, hwaddr addr,
case 4:
buf.dword = cpu_to_le32(data);
break;
+ case 8:
+ buf.qword = cpu_to_le64(data);
+ break;
default:
hw_error("vfio: unsupported write size, %d bytes", size);
break;
@@ -173,6 +176,9 @@ uint64_t vfio_region_read(void *opaque,
case 4:
data = le32_to_cpu(buf.dword);
break;
+ case 8:
+ data = le64_to_cpu(buf.qword);
+ break;
default:
hw_error("vfio: unsupported read size, %d bytes", size);
break;
@@ -194,6 +200,10 @@ const MemoryRegionOps vfio_region_ops = {
.min_access_size = 1,
.max_access_size = 8,
},
+ .impl = {
+ .min_access_size = 1,
+ .max_access_size = 8,
+ },
};
/*
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PULL 3/3] vfio/pci: Fix incorrect error message
2017-05-03 21:38 [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Alex Williamson
2017-05-03 21:38 ` [Qemu-devel] [PULL 1/3] vfio: Set MemoryRegionOps:max_access_size and min_access_size Alex Williamson
2017-05-03 21:39 ` [Qemu-devel] [PULL 2/3] vfio: enable 8-byte reads/writes to vfio Alex Williamson
@ 2017-05-03 21:39 ` Alex Williamson
2017-05-05 15:14 ` [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2017-05-03 21:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Eric Auger, Dong Jia Shi
From: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
When the "No host device provided" error occurs, the hint message
that starts with "Use -vfio-pci," makes no sense, since "-vfio-pci"
is not a valid command line parameter.
Correct this by replacing "-vfio-pci" with "-device vfio-pci".
Signed-off-by: Dong Jia Shi <bjsdjshi@linux.vnet.ibm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 03a3d0154976..32aca7770177 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2625,8 +2625,8 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
if (!(~vdev->host.domain || ~vdev->host.bus ||
~vdev->host.slot || ~vdev->host.function)) {
error_setg(errp, "No provided host device");
- error_append_hint(errp, "Use -vfio-pci,host=DDDD:BB:DD.F "
- "or -vfio-pci,sysfsdev=PATH_TO_DEVICE\n");
+ error_append_hint(errp, "Use -device vfio-pci,host=DDDD:BB:DD.F "
+ "or -device vfio-pci,sysfsdev=PATH_TO_DEVICE\n");
return;
}
vdev->vbasedev.sysfsdev =
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03
2017-05-03 21:38 [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Alex Williamson
` (2 preceding siblings ...)
2017-05-03 21:39 ` [Qemu-devel] [PULL 3/3] vfio/pci: Fix incorrect error message Alex Williamson
@ 2017-05-05 15:14 ` Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2017-05-05 15:14 UTC (permalink / raw)
To: Alex Williamson; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1284 bytes --]
On Wed, May 03, 2017 at 03:38:39PM -0600, Alex Williamson wrote:
> The following changes since commit e619b14746e5d8c0e53061661fd0e1da01fd4d60:
>
> Merge remote-tracking branch 'sthibault/tags/samuel-thibault' into staging (2017-05-02 15:16:29 +0100)
>
> are available in the git repository at:
>
>
> git://github.com/awilliam/qemu-vfio.git tags/vfio-updates-20170503.0
>
> for you to fetch changes up to 6e4e6f0d403b1fb25f9dfdbe17754c643997753d:
>
> vfio/pci: Fix incorrect error message (2017-05-03 14:52:35 -0600)
>
> ----------------------------------------------------------------
> VFIO fixes 2017-05-03
>
> - Enable 8-byte memory region accesses (Jose Ricardo Ziviani)
> - Fix vfio-pci error message (Dong Jia Shi)
>
> ----------------------------------------------------------------
> Dong Jia Shi (1):
> vfio/pci: Fix incorrect error message
>
> Jose Ricardo Ziviani (2):
> vfio: Set MemoryRegionOps:max_access_size and min_access_size
> vfio: enable 8-byte reads/writes to vfio
>
> hw/vfio/common.c | 14 ++++++++++++++
> hw/vfio/pci.c | 4 ++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
Thanks, applied to my staging tree:
https://github.com/stefanha/qemu/commits/staging
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-05-05 15:14 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-03 21:38 [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Alex Williamson
2017-05-03 21:38 ` [Qemu-devel] [PULL 1/3] vfio: Set MemoryRegionOps:max_access_size and min_access_size Alex Williamson
2017-05-03 21:39 ` [Qemu-devel] [PULL 2/3] vfio: enable 8-byte reads/writes to vfio Alex Williamson
2017-05-03 21:39 ` [Qemu-devel] [PULL 3/3] vfio/pci: Fix incorrect error message Alex Williamson
2017-05-05 15:14 ` [Qemu-devel] [PULL 0/3] VFIO fixes 2017-05-03 Stefan Hajnoczi
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).