qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Nicholas Piggin <npiggin@gmail.com>, qemu-ppc@nongnu.org
Cc: Daniel Henrique Barboza <danielhb413@gmail.com>,
	Harsh Prateek Bora <harshpb@linux.ibm.com>,
	Fabiano Rosas <farosas@suse.de>,
	Laurent Vivier <lvivier@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Coiby Xu <Coiby.Xu@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Emanuele Giuseppe Esposito <e.emanuelegiuseppe@gmail.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [RFC PATCH 1/2] tests/qtest: Fix virtio msix message endianness
Date: Wed, 16 Apr 2025 08:29:41 +0200	[thread overview]
Message-ID: <0d3ae936-7013-418d-a478-48d14b5b8e70@linaro.org> (raw)
In-Reply-To: <20250415081914.378236-2-npiggin@gmail.com>

Hi Nick,

On 15/4/25 10:19, Nicholas Piggin wrote:
> msix messages are written to memory in little-endian order, so they
> should not be byteswapped depending on target endianness, but read
> as le and converted to host endian by the qtest.
> 
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>   tests/qtest/libqos/virtio-pci-modern.c | 9 +++++++--
>   tests/qtest/libqos/virtio-pci.c        | 7 +++++--
>   2 files changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qtest/libqos/virtio-pci-modern.c b/tests/qtest/libqos/virtio-pci-modern.c
> index 4e67fcbd5d3..67aa2af0bd7 100644
> --- a/tests/qtest/libqos/virtio-pci-modern.c
> +++ b/tests/qtest/libqos/virtio-pci-modern.c
> @@ -8,6 +8,7 @@
>    */
>   
>   #include "qemu/osdep.h"
> +#include "qemu/bswap.h"
>   #include "standard-headers/linux/pci_regs.h"
>   #include "standard-headers/linux/virtio_pci.h"
>   #include "standard-headers/linux/virtio_config.h"
> @@ -136,12 +137,16 @@ static bool get_msix_status(QVirtioPCIDevice *dev, uint32_t msix_entry,
>           return qpci_msix_pending(dev->pdev, msix_entry);
>       }
>   
> -    data = qtest_readl(dev->pdev->bus->qts, msix_addr);
> +    qtest_memread(dev->pdev->bus->qts, msix_addr, &data, 4);
> +    data = le32_to_cpu(data);
>       if (data == msix_data) {
>           qtest_writel(dev->pdev->bus->qts, msix_addr, 0);
>           return true;
> -    } else {
> +    } else if (data == 0) {
>           return false;
> +    } else {
> +        /* Must only be either 0 (no interrupt) or the msix data. */
> +        g_assert_not_reached();

This distinct change belong to a different preliminary patch.

>       }
>   }
>   
> diff --git a/tests/qtest/libqos/virtio-pci.c b/tests/qtest/libqos/virtio-pci.c
> index 002bf8b8c2d..6b421a4d859 100644
> --- a/tests/qtest/libqos/virtio-pci.c
> +++ b/tests/qtest/libqos/virtio-pci.c
> @@ -131,12 +131,15 @@ static bool qvirtio_pci_get_queue_isr_status(QVirtioDevice *d, QVirtQueue *vq)
>               /* No ISR checking should be done if masked, but read anyway */
>               return qpci_msix_pending(dev->pdev, vqpci->msix_entry);
>           } else {
> -            data = qtest_readl(dev->pdev->bus->qts, vqpci->msix_addr);
> +            qtest_memread(dev->pdev->bus->qts, vqpci->msix_addr, &data, 4);
> +            data = le32_to_cpu(data);
>               if (data == vqpci->msix_data) {
>                   qtest_writel(dev->pdev->bus->qts, vqpci->msix_addr, 0);
>                   return true;
> -            } else {
> +            } else if (data == 0) {
>                   return false;
> +            } else {
> +                g_assert_not_reached();

Ditto.

>               }
>           }

Splitting in 2:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

>       } else {



  parent reply	other threads:[~2025-04-16  6:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15  8:19 [RFC PATCH 0/2] tests/qtest: Enable spapr dma tests Nicholas Piggin
2025-04-15  8:19 ` [RFC PATCH 1/2] tests/qtest: Fix virtio msix message endianness Nicholas Piggin
2025-04-15 18:01   ` Fabiano Rosas
2025-04-16  6:29   ` Philippe Mathieu-Daudé [this message]
2025-04-15  8:19 ` [RFC PATCH 2/2] tests/qtest: Enable spapr dma with linear iommu map Nicholas Piggin
2025-04-15 18:07   ` Fabiano Rosas
2025-04-16  2:06     ` Nicholas Piggin

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=0d3ae936-7013-418d-a478-48d14b5b8e70@linaro.org \
    --to=philmd@linaro.org \
    --cc=Coiby.Xu@gmail.com \
    --cc=danielhb413@gmail.com \
    --cc=e.emanuelegiuseppe@gmail.com \
    --cc=farosas@suse.de \
    --cc=harshpb@linux.ibm.com \
    --cc=lvivier@redhat.com \
    --cc=npiggin@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).