qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 5/5] vfio-user: Fix config space access byte order


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3 5/5] vfio-user: Fix config space access byte order
Date: Thu, 14 Sep 2023 22:29:10 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

On 7/9/23 15:04, Mattias Nissler wrote:
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.

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 cee5e615a9..d38b4700f3 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;

This makes sense,

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]