diff mbox

vfio_pci: fix build on 32-bit systems

Message ID 1349116911-18550-1-git-send-email-aliguori@us.ibm.com
State New
Headers show

Commit Message

Anthony Liguori Oct. 1, 2012, 6:41 p.m. UTC
We cannot cast directly from pointer to uint64.

Cc: Alex Williamson <alex.williamson@redhat.com>
Cc: Alex Barcelo <abarcelo@ac.upc.edu>
Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/vfio_pci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Alex Williamson Oct. 1, 2012, 6:49 p.m. UTC | #1
On Mon, 2012-10-01 at 13:41 -0500, Anthony Liguori wrote:
> We cannot cast directly from pointer to uint64.
> 
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Alex Barcelo <abarcelo@ac.upc.edu>
> Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  hw/vfio_pci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
> index a24558a..a1eeced 100644
> --- a/hw/vfio_pci.c
> +++ b/hw/vfio_pci.c
> @@ -768,7 +768,7 @@ static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
>      struct vfio_iommu_type1_dma_map map = {
>          .argsz = sizeof(map),
>          .flags = VFIO_DMA_MAP_FLAG_READ,
> -        .vaddr = (__u64)vaddr,
> +        .vaddr = (__u64)(intptr_t)vaddr,
>          .iova = iova,
>          .size = size,
>      };

Thanks Anthony

Acked-by: Alex Williamson <alex.williamson@redhat.com>
Anthony Liguori Oct. 1, 2012, 7:27 p.m. UTC | #2
Anthony Liguori <aliguori@us.ibm.com> writes:

> We cannot cast directly from pointer to uint64.
>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Alex Barcelo <abarcelo@ac.upc.edu>
> Reported-by: Alex Barcelo <abarcelo@ac.upc.edu>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Applied.

Regards,

Anthony Liguori

> ---
>  hw/vfio_pci.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
> index a24558a..a1eeced 100644
> --- a/hw/vfio_pci.c
> +++ b/hw/vfio_pci.c
> @@ -768,7 +768,7 @@ static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
>      struct vfio_iommu_type1_dma_map map = {
>          .argsz = sizeof(map),
>          .flags = VFIO_DMA_MAP_FLAG_READ,
> -        .vaddr = (__u64)vaddr,
> +        .vaddr = (__u64)(intptr_t)vaddr,
>          .iova = iova,
>          .size = size,
>      };
> -- 
> 1.7.5.4
Paolo Bonzini Oct. 2, 2012, 6:11 a.m. UTC | #3
Il 01/10/2012 20:49, Alex Williamson ha scritto:
>> > @@ -768,7 +768,7 @@ static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
>> >      struct vfio_iommu_type1_dma_map map = {
>> >          .argsz = sizeof(map),
>> >          .flags = VFIO_DMA_MAP_FLAG_READ,
>> > -        .vaddr = (__u64)vaddr,
>> > +        .vaddr = (__u64)(intptr_t)vaddr,

Does this need to be uintptr_t?

Paolo

>> >          .iova = iova,
>> >          .size = size,
>> >      };
> Thanks Anthony
> 
> Acked-by: Alex Williamson <alex.williamson@redhat.com>
Alex Williamson Oct. 2, 2012, 2:37 p.m. UTC | #4
On Tue, 2012-10-02 at 08:11 +0200, Paolo Bonzini wrote:
> Il 01/10/2012 20:49, Alex Williamson ha scritto:
> >> > @@ -768,7 +768,7 @@ static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
> >> >      struct vfio_iommu_type1_dma_map map = {
> >> >          .argsz = sizeof(map),
> >> >          .flags = VFIO_DMA_MAP_FLAG_READ,
> >> > -        .vaddr = (__u64)vaddr,
> >> > +        .vaddr = (__u64)(intptr_t)vaddr,
> 
> Does this need to be uintptr_t?

With a simple test program, I don't seem to get sign extension either
way.  Logically uintptr_t seems preferable to me.  I'll add a patch to
my tree.  Thanks,

Alex
Anthony Liguori Oct. 2, 2012, 3:03 p.m. UTC | #5
Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 01/10/2012 20:49, Alex Williamson ha scritto:
>>> > @@ -768,7 +768,7 @@ static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
>>> >      struct vfio_iommu_type1_dma_map map = {
>>> >          .argsz = sizeof(map),
>>> >          .flags = VFIO_DMA_MAP_FLAG_READ,
>>> > -        .vaddr = (__u64)vaddr,
>>> > +        .vaddr = (__u64)(intptr_t)vaddr,
>
> Does this need to be uintptr_t?

I don't think it matters semantically but using uintptr_t can't hurt.

Regards,

Anthony Liguori

>
> Paolo
>
>>> >          .iova = iova,
>>> >          .size = size,
>>> >      };
>> Thanks Anthony
>> 
>> Acked-by: Alex Williamson <alex.williamson@redhat.com>
diff mbox

Patch

diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
index a24558a..a1eeced 100644
--- a/hw/vfio_pci.c
+++ b/hw/vfio_pci.c
@@ -768,7 +768,7 @@  static int vfio_dma_map(VFIOContainer *container, target_phys_addr_t iova,
     struct vfio_iommu_type1_dma_map map = {
         .argsz = sizeof(map),
         .flags = VFIO_DMA_MAP_FLAG_READ,
-        .vaddr = (__u64)vaddr,
+        .vaddr = (__u64)(intptr_t)vaddr,
         .iova = iova,
         .size = size,
     };