Hello Farhan,

On 12/19/25 18:30, Farhan Ali wrote:

On 12/19/2025 8:30 AM, Cédric Le Goater wrote:
On 12/19/25 17:21, Philippe Mathieu-Daudé wrote:
On 19/12/25 15:51, Cédric Le Goater wrote:
Hello,

On 12/17/25 19:42, Farhan Ali wrote:
The VFIO pread/pwrite functions use little-endian data format.
When enabling the Bus Master bit, the value must be correctly converted
from the CPU's native endianess to little-endian format.

How did you find the issue ?

I presumed using VFIO on s390x hosts...

yes. I have been using a nvme drive for over 2y in an s390x VM and never
saw any issue.

C.

Hi Cedric,

I have recently been experimenting with QEMU NVMe userspace driver and PCI 
instructions from userspace [1]. On some of our test systems I noticed the 
driver being hung. After some investigation we realized it was due to this 
issue.

Do you think you could provide a test case for it ?

Also, I think the LE conversion should be done in routines
qemu_vfio_pci_read_config() and qemu_vfio_pci_write_config().

Thanks,

C.



[1] https://lore.kernel.org/all/[email protected]/

Thanks

Farhan




Thanks,

C.


Signed-off-by: Farhan Ali <[email protected]>
---
  util/vfio-helpers.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index fdff042ab4..3c8284284f 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -443,7 +443,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char 
*device,
      if (ret) {
          goto fail;
      }
-    pci_cmd |= PCI_COMMAND_MASTER;
+    pci_cmd = cpu_to_le16(le16_to_cpu(pci_cmd) | PCI_COMMAND_MASTER);
      ret = qemu_vfio_pci_write_config(s, &pci_cmd, sizeof(pci_cmd), 
PCI_COMMAND);
      if (ret) {
          goto fail;









Reply via email to