qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] vfio: Fix BAR->VFIODevice translation in vfio_bar_read/write
Date: Mon, 08 Oct 2012 08:27:54 -0600	[thread overview]
Message-ID: <1349706474.2759.75.camel@ul30vt.home> (raw)
In-Reply-To: <5072AEB8.8020706@siemens.com>

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;
>  }

      reply	other threads:[~2012-10-08 14:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=1349706474.2759.75.camel@ul30vt.home \
    --to=alex.williamson@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=qemu-devel@nongnu.org \
    /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).