* [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write
@ 2012-10-08 10:45 Jan Kiszka
2012-10-08 14:27 ` Alex Williamson
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2012-10-08 10:45 UTC (permalink / raw)
To: Alex Williamson, qemu-devel
DO_UPCAST is supposed to translate from the first member of a struct to
that struct, not from arbitrary ones. And it (usually) breaks the build
when neglecting this rule. Use container_of to fix the build breakage
and likely also the runtime behavior.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
hw/vfio_pci.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
index a1eeced..d36d50e 100644
--- a/hw/vfio_pci.c
+++ b/hw/vfio_pci.c
@@ -601,7 +601,7 @@ static void vfio_bar_write(void *opaque, target_phys_addr_t addr,
* which access will service the interrupt, so we're potentially
* getting quite a few host interrupts per guest interrupt.
*/
- vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
+ vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
}
static uint64_t vfio_bar_read(void *opaque,
@@ -641,7 +641,7 @@ static uint64_t vfio_bar_read(void *opaque,
__func__, bar->nr, addr, size, data);
/* Same as write above */
- vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
+ vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
return data;
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write
2012-10-08 10:45 [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write Jan Kiszka
@ 2012-10-08 14:27 ` Alex Williamson
0 siblings, 0 replies; 2+ messages in thread
From: Alex Williamson @ 2012-10-08 14:27 UTC (permalink / raw)
To: Jan Kiszka; +Cc: qemu-devel
On Mon, 2012-10-08 at 12:45 +0200, Jan Kiszka wrote:
> DO_UPCAST is supposed to translate from the first member of a struct to
> that struct, not from arbitrary ones. And it (usually) breaks the build
> when neglecting this rule. Use container_of to fix the build breakage
> and likely also the runtime behavior.
It should have warned, but afaict the runtime behavior should have been
the same. It would have been miraculous if INTx ever got an EOI
otherwise. I'll apply this to my tree. Thanks,
Alex
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> hw/vfio_pci.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/vfio_pci.c b/hw/vfio_pci.c
> index a1eeced..d36d50e 100644
> --- a/hw/vfio_pci.c
> +++ b/hw/vfio_pci.c
> @@ -601,7 +601,7 @@ static void vfio_bar_write(void *opaque, target_phys_addr_t addr,
> * which access will service the interrupt, so we're potentially
> * getting quite a few host interrupts per guest interrupt.
> */
> - vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
> + vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
> }
>
> static uint64_t vfio_bar_read(void *opaque,
> @@ -641,7 +641,7 @@ static uint64_t vfio_bar_read(void *opaque,
> __func__, bar->nr, addr, size, data);
>
> /* Same as write above */
> - vfio_eoi(DO_UPCAST(VFIODevice, bars[bar->nr], bar));
> + vfio_eoi(container_of(bar, VFIODevice, bars[bar->nr]));
>
> return data;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-08 14:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08 10:45 [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write Jan Kiszka
2012-10-08 14:27 ` Alex Williamson
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).