* [Qemu-devel] [PULL] VFIO updates 2016-03-28
@ 2016-03-28 22:34 Alex Williamson
2016-03-28 22:34 ` [Qemu-devel] [PULL] vfio: convert to 128 bit arithmetic calculations when adding mem regions Alex Williamson
2016-03-29 17:25 ` [Qemu-devel] [PULL] VFIO updates 2016-03-28 Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Alex Williamson @ 2016-03-28 22:34 UTC (permalink / raw)
To: qemu-devel
The following changes since commit b68a80139e37e806f004237e55311ebc42151434:
Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20160324' into staging (2016-03-24 16:24:02 +0000)
are available in the git repository at:
git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20160328.0
for you to fetch changes up to 55efcc537d330f1659d3fa171a66eebc9327e91b:
vfio: convert to 128 bit arithmetic calculations when adding mem regions (2016-03-28 13:27:49 -0600)
----------------------------------------------------------------
VFIO updates 2016-03-28
- Use 128bit math to avoid asserts with IOMMU regions (Bandan Das)
----------------------------------------------------------------
Bandan Das (1):
vfio: convert to 128 bit arithmetic calculations when adding mem regions
hw/vfio/common.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PULL] vfio: convert to 128 bit arithmetic calculations when adding mem regions
2016-03-28 22:34 [Qemu-devel] [PULL] VFIO updates 2016-03-28 Alex Williamson
@ 2016-03-28 22:34 ` Alex Williamson
2016-03-29 17:25 ` [Qemu-devel] [PULL] VFIO updates 2016-03-28 Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Alex Williamson @ 2016-03-28 22:34 UTC (permalink / raw)
To: qemu-devel; +Cc: Bandan Das
From: Bandan Das <bsd@redhat.com>
vfio_listener_region_add for a iommu mr results in
an overflow assert since iommu memory region is initialized
with UINT64_MAX. Convert calculations to 128 bit arithmetic
for iommu memory regions and let int128_get64 assert for non iommu
regions if there's an overflow.
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bandan Das <bsd@redhat.com>
[missed (end - 1) on 2nd trace call, move llsize closer to use]
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index fb588d8..f27db36 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -323,7 +323,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
{
VFIOContainer *container = container_of(listener, VFIOContainer, listener);
hwaddr iova, end;
- Int128 llend;
+ Int128 llend, llsize;
void *vaddr;
int ret;
@@ -349,12 +349,12 @@ static void vfio_listener_region_add(MemoryListener *listener,
if (int128_ge(int128_make64(iova), llend)) {
return;
}
- end = int128_get64(llend);
+ end = int128_get64(int128_sub(llend, int128_one()));
- if ((iova < container->min_iova) || ((end - 1) > container->max_iova)) {
+ if ((iova < container->min_iova) || (end > container->max_iova)) {
error_report("vfio: IOMMU container %p can't map guest IOVA region"
" 0x%"HWADDR_PRIx"..0x%"HWADDR_PRIx,
- container, iova, end - 1);
+ container, iova, end);
ret = -EFAULT;
goto fail;
}
@@ -364,7 +364,7 @@ static void vfio_listener_region_add(MemoryListener *listener,
if (memory_region_is_iommu(section->mr)) {
VFIOGuestIOMMU *giommu;
- trace_vfio_listener_region_add_iommu(iova, end - 1);
+ trace_vfio_listener_region_add_iommu(iova, end);
/*
* FIXME: We should do some checking to see if the
* capabilities of the host VFIO IOMMU are adequate to model
@@ -395,13 +395,16 @@ static void vfio_listener_region_add(MemoryListener *listener,
section->offset_within_region +
(iova - section->offset_within_address_space);
- trace_vfio_listener_region_add_ram(iova, end - 1, vaddr);
+ trace_vfio_listener_region_add_ram(iova, end, vaddr);
- ret = vfio_dma_map(container, iova, end - iova, vaddr, section->readonly);
+ llsize = int128_sub(llend, int128_make64(iova));
+
+ ret = vfio_dma_map(container, iova, int128_get64(llsize),
+ vaddr, section->readonly);
if (ret) {
error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
"0x%"HWADDR_PRIx", %p) = %d (%m)",
- container, iova, end - iova, vaddr, ret);
+ container, iova, int128_get64(llsize), vaddr, ret);
goto fail;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PULL] VFIO updates 2016-03-28
2016-03-28 22:34 [Qemu-devel] [PULL] VFIO updates 2016-03-28 Alex Williamson
2016-03-28 22:34 ` [Qemu-devel] [PULL] vfio: convert to 128 bit arithmetic calculations when adding mem regions Alex Williamson
@ 2016-03-29 17:25 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-03-29 17:25 UTC (permalink / raw)
To: Alex Williamson; +Cc: QEMU Developers
On 28 March 2016 at 23:34, Alex Williamson <alex.williamson@redhat.com> wrote:
> The following changes since commit b68a80139e37e806f004237e55311ebc42151434:
>
> Merge remote-tracking branch 'remotes/cohuck/tags/s390x-20160324' into staging (2016-03-24 16:24:02 +0000)
>
> are available in the git repository at:
>
>
> git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20160328.0
>
> for you to fetch changes up to 55efcc537d330f1659d3fa171a66eebc9327e91b:
>
> vfio: convert to 128 bit arithmetic calculations when adding mem regions (2016-03-28 13:27:49 -0600)
>
> ----------------------------------------------------------------
> VFIO updates 2016-03-28
>
> - Use 128bit math to avoid asserts with IOMMU regions (Bandan Das)
>
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-29 17:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-28 22:34 [Qemu-devel] [PULL] VFIO updates 2016-03-28 Alex Williamson
2016-03-28 22:34 ` [Qemu-devel] [PULL] vfio: convert to 128 bit arithmetic calculations when adding mem regions Alex Williamson
2016-03-29 17:25 ` [Qemu-devel] [PULL] VFIO updates 2016-03-28 Peter Maydell
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).