[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-7.2.12 12/19] hw/remote/vfio-user: Fix config space access byte
From: |
Michael Tokarev |
Subject: |
[Stable-7.2.12 12/19] hw/remote/vfio-user: Fix config space access byte order |
Date: |
Mon, 27 May 2024 09:40:43 +0300 |
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>
(cherry picked from commit e6578f1f68a0e90789a841ada532c3e494c9a04c)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/remote/vfio-user-obj.c b/hw/remote/vfio-user-obj.c
index 4e36bb8bcf..973cebe785 100644
--- a/hw/remote/vfio-user-obj.c
+++ b/hw/remote/vfio-user-obj.c
@@ -273,7 +273,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);
@@ -281,7 +281,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.39.2
- [Stable-7.2.12 00/19] Patch Round-up for stable 7.2.12, freeze on 2024-06-07, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 05/19] nbd/server: Mark negotiation functions as coroutine_fn, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 03/19] linux-user: do_setsockopt: fix SOL_ALG.ALG_SET_KEY, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 10/19] hw/arm/npcm7xx: Store derivative OTP fuse key in little endian, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 12/19] hw/remote/vfio-user: Fix config space access byte order,
Michael Tokarev <=
- [Stable-7.2.12 06/19] backends/cryptodev-builtin: Fix local_error leaks, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 09/19] hw/dmax/xlnx_dpdma: fix handling of address_extension descriptor fields, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 01/19] gitlab-ci: Remove job building EDK2 firmware binaries, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 02/19] gitlab/opensbi: Move to docker:stable, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 07/19] tests/avocado: update sunxi kernel from armbian to 6.6.16, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 11/19] target/i386: Give IRQs a chance when resetting HF_INHIBIT_IRQ_MASK, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 04/19] nbd/server: do not poll within a coroutine context, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 08/19] .gitlab-ci.d/cirrus.yml: Shorten the runtime of the macOS and FreeBSD jobs, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 14/19] target/i386: rdpkru/wrpkru are no-prefix instructions, Michael Tokarev, 2024/05/27
- [Stable-7.2.12 16/19] ui/gtk: Check if fence_fd is equal to or greater than 0, Michael Tokarev, 2024/05/27