[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v10 7/7] vfio-user: Fix config space access byte order
From: |
Mattias Nissler |
Subject: |
[PATCH v10 7/7] vfio-user: Fix config space access byte order |
Date: |
Tue, 7 May 2024 07:34:31 -0700 |
PCI config space is little-endian, so on a big-endian host we need to
perform byte swaps for values as they are passed to and received from
the generic PCI config space access machinery.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Jagannathan Raman <jag.raman@oracle.com>
Signed-off-by: Mattias Nissler <mnissler@rivosinc.com>
---
hw/remote/vfio-user-obj.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c
index a15e291c9a..0e93d7a7b4 100644
--- a/hw/remote/vfio-user-obj.c
+++ b/hw/remote/vfio-user-obj.c
@@ -281,7 +281,7 @@ static ssize_t vfu_object_cfg_access(vfu_ctx_t *vfu_ctx,
char * const buf,
while (bytes > 0) {
len = (bytes > pci_access_width) ? pci_access_width : bytes;
if (is_write) {
- memcpy(&val, ptr, len);
+ val = ldn_le_p(ptr, len);
pci_host_config_write_common(o->pci_dev, offset,
pci_config_size(o->pci_dev),
val, len);
@@ -289,7 +289,7 @@ static ssize_t vfu_object_cfg_access(vfu_ctx_t *vfu_ctx,
char * const buf,
} else {
val = pci_host_config_read_common(o->pci_dev, offset,
pci_config_size(o->pci_dev),
len);
- memcpy(ptr, &val, len);
+ stn_le_p(ptr, len, val);
trace_vfu_cfg_read(offset, val);
}
offset += len;
--
2.43.2
- [PATCH v10 0/7] Support message-based DMA in vfio-user server, Mattias Nissler, 2024/05/07
- [PATCH v10 1/7] system/physmem: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD, Mattias Nissler, 2024/05/07
- [PATCH v10 2/7] system/physmem: Propagate AddressSpace to MapClient helpers, Mattias Nissler, 2024/05/07
- [PATCH v10 4/7] softmmu: Support concurrent bounce buffers, Mattias Nissler, 2024/05/07
- [PATCH v10 3/7] system/physmem: Per-AddressSpace bounce buffering, Mattias Nissler, 2024/05/07
- [PATCH v10 5/7] Update subprojects/libvfio-user, Mattias Nissler, 2024/05/07
- [PATCH v10 7/7] vfio-user: Fix config space access byte order,
Mattias Nissler <=
- [PATCH v10 6/7] vfio-user: Message-based DMA support, Mattias Nissler, 2024/05/07
- Re: [PATCH v10 0/7] Support message-based DMA in vfio-user server, Peter Xu, 2024/05/07
- Re: [PATCH v10 0/7] Support message-based DMA in vfio-user server, Philippe Mathieu-Daudé, 2024/05/08