[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 07/12] vfio-user: handle PCI config space accesses
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v3 07/12] vfio-user: handle PCI config space accesses |
Date: |
Wed, 27 Oct 2021 17:35:14 +0100 |
On Mon, Oct 11, 2021 at 01:31:12AM -0400, Jagannathan Raman wrote:
> +static ssize_t vfu_object_cfg_access(vfu_ctx_t *vfu_ctx, char * const buf,
> + size_t count, loff_t offset,
> + const bool is_write)
> +{
> + VfuObject *o = vfu_get_private(vfu_ctx);
> + uint32_t pci_access_width = sizeof(uint32_t);
> + size_t bytes = count;
> + uint32_t val = 0;
> + char *ptr = buf;
> + int len;
> +
> + while (bytes > 0) {
> + len = (bytes > pci_access_width) ? pci_access_width : bytes;
> + if (is_write) {
> + memcpy(&val, ptr, len);
> + pci_host_config_write_common(o->pci_dev, offset,
> + pci_config_size(o->pci_dev),
> + val, len);
> + trace_vfu_cfg_write(offset, val);
> + } else {
> + val = pci_host_config_read_common(o->pci_dev, offset,
> + pci_config_size(o->pci_dev),
> len);
> + memcpy(ptr, &val, len);
> + trace_vfu_cfg_read(offset, val);
> + }
pci_host_config_read/write_common() work with host-endian values. What
is the endianness of buf?
signature.asc
Description: PGP signature
- Re: [PATCH v3 01/12] configure, meson: override C compiler for cmake, (continued)
- [PATCH v3 02/12] vfio-user: build library, Jagannathan Raman, 2021/10/11
- [PATCH v3 03/12] vfio-user: define vfio-user-server object, Jagannathan Raman, 2021/10/11
- [PATCH v3 04/12] vfio-user: instantiate vfio-user context, Jagannathan Raman, 2021/10/11
- [PATCH v3 05/12] vfio-user: find and init PCI device, Jagannathan Raman, 2021/10/11
- [PATCH v3 07/12] vfio-user: handle PCI config space accesses, Jagannathan Raman, 2021/10/11
- Re: [PATCH v3 07/12] vfio-user: handle PCI config space accesses,
Stefan Hajnoczi <=
- [PATCH v3 08/12] vfio-user: handle DMA mappings, Jagannathan Raman, 2021/10/11
- [PATCH v3 06/12] vfio-user: run vfio-user context, Jagannathan Raman, 2021/10/11
- [PATCH v3 10/12] vfio-user: handle device interrupts, Jagannathan Raman, 2021/10/11
- [PATCH v3 09/12] vfio-user: handle PCI BAR accesses, Jagannathan Raman, 2021/10/11
- [PATCH v3 11/12] vfio-user: register handlers to facilitate migration, Jagannathan Raman, 2021/10/11
- [PATCH v3 12/12] vfio-user: acceptance test, Jagannathan Raman, 2021/10/11