summary refs log tree commit diff stats
path: root/util/vfio-helpers.c
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@redhat.com>2020-09-22 10:38:16 +0200
committerStefan Hajnoczi <stefanha@redhat.com>2020-10-05 09:35:52 +0100
commitb02c01a513a17e03e2245feff19b3dcc8c408859 (patch)
treea4bb66de8c0091fc06398ee4dd4e6361759f3733 /util/vfio-helpers.c
parent469e72ab7dbbd7ff4ee601e5ea7c29545d46593b (diff)
downloadfocaccia-qemu-b02c01a513a17e03e2245feff19b3dcc8c408859.tar.gz
focaccia-qemu-b02c01a513a17e03e2245feff19b3dcc8c408859.zip
util/vfio-helpers: Pass page protections to qemu_vfio_pci_map_bar()
Pages are currently mapped READ/WRITE. To be able to use different
protections, add a new argument to qemu_vfio_pci_map_bar().

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20200922083821.578519-2-philmd@redhat.com>
Diffstat (limited to 'util/vfio-helpers.c')
-rw-r--r--util/vfio-helpers.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/vfio-helpers.c b/util/vfio-helpers.c
index 583bdfb36f..9ac307e3d4 100644
--- a/util/vfio-helpers.c
+++ b/util/vfio-helpers.c
@@ -146,13 +146,13 @@ static int qemu_vfio_pci_init_bar(QEMUVFIOState *s, int index, Error **errp)
  * Map a PCI bar area.
  */
 void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
-                            uint64_t offset, uint64_t size,
+                            uint64_t offset, uint64_t size, int prot,
                             Error **errp)
 {
     void *p;
     assert_bar_index_valid(s, index);
     p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset),
-             PROT_READ | PROT_WRITE, MAP_SHARED,
+             prot, MAP_SHARED,
              s->device, s->bar_region_info[index].offset + offset);
     if (p == MAP_FAILED) {
         error_setg_errno(errp, errno, "Failed to map BAR region");