[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/26] hw/remote/vfio-user: Fix config space access byte order
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 05/26] hw/remote/vfio-user: Fix config space access byte order |
Date: |
Wed, 8 May 2024 19:44:49 +0200 |
From: Mattias Nissler <mnissler@rivosinc.com>
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>
Message-ID: <20240507094210.300566-6-mnissler@rivosinc.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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 d9b879e056..8dbafafb9e 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.41.0
- [PULL 00/26] Misc HW patches for 2024-05-08, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 01/26] block/qcow2-bitmap: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 03/26] hw/hppa/machine: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 06/26] system/physmem: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 02/26] target/ppc: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 07/26] system/physmem: Propagate AddressSpace to MapClient helpers, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 13/26] hw/i386: Have x86_bios_rom_init() take X86MachineState rather than MachineState, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 09/26] hw/i386/pc: Allow to compile without CONFIG_FDC_ISA, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 04/26] hw/ppc/spapr_pci: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 05/26] hw/remote/vfio-user: Fix config space access byte order,
Philippe Mathieu-Daudé <=
- [PULL 12/26] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 14/26] hw/i386/x86: Don't leak "isa-bios" memory regions, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 10/26] hw/i386/Kconfig: Allow to compile Q35 without FDC_ISA, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 08/26] system/physmem: Per-AddressSpace bounce buffering, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 11/26] hw/i386: Add the possibility to use i440fx and isapc without FDC, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 15/26] hw/usb/dev-network: Remove unused struct 'rndis_config_parameter', Philippe Mathieu-Daudé, 2024/05/08
- [PULL 16/26] hw/gpio: Handle clock migration in STM32L4x5 gpios, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 17/26] hw/ppc: Deprecate 'ref405ep' machine and 405 CPUs, Philippe Mathieu-Daudé, 2024/05/08