aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2022-11-22 09:10:27 +0000
committerGitHub <noreply@github.com>2022-11-22 09:10:27 +0000
commit14c0bc58e7278271ba22e6d31480da550db69a0c (patch)
tree3c71a37a030e0ece5dfa81f92041d6327032f53a /lib
parentb975ee6e184884b63c654d2414f013c645c8a92e (diff)
downloadlibvfio-user-14c0bc58e7278271ba22e6d31480da550db69a0c.zip
libvfio-user-14c0bc58e7278271ba22e6d31480da550db69a0c.tar.gz
libvfio-user-14c0bc58e7278271ba22e6d31480da550db69a0c.tar.bz2
allow shadow memory offset per shadow ioeventfd (#703)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvfio-user.c15
-rw-r--r--lib/private.h3
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 93dca6d..219b527 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -477,8 +477,8 @@ handle_device_get_region_info(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
EXPORT int
vfu_create_ioeventfd(vfu_ctx_t *vfu_ctx, uint32_t region_idx, int fd,
- size_t offset, uint32_t size, uint32_t flags,
- uint64_t datamatch, int shadow_fd)
+ size_t gpa_offset, uint32_t size, uint32_t flags,
+ uint64_t datamatch, int shadow_fd, size_t shadow_offset)
{
vfu_reg_info_t *vfu_reg;
@@ -498,7 +498,7 @@ vfu_create_ioeventfd(vfu_ctx_t *vfu_ctx, uint32_t region_idx, int fd,
vfu_reg = &vfu_ctx->reg_info[region_idx];
- if (offset + size > vfu_reg->size) {
+ if (gpa_offset + size > vfu_reg->size) {
return ERROR_INT(EINVAL);
}
@@ -508,11 +508,12 @@ vfu_create_ioeventfd(vfu_ctx_t *vfu_ctx, uint32_t region_idx, int fd,
}
elem->fd = fd;
- elem->offset = offset;
+ elem->gpa_offset = gpa_offset;
elem->size = size;
elem->flags = flags;
elem->datamatch = datamatch;
elem->shadow_fd = shadow_fd;
+ elem->shadow_offset = shadow_offset;
LIST_INSERT_HEAD(&vfu_reg->subregions, elem, entry);
return 0;
@@ -647,7 +648,7 @@ handle_device_get_region_io_fds(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
for (i = 0; i < max_sent_sub_regions; i++) {
ioefd = &reply->sub_regions[i].ioeventfd;
- ioefd->offset = sub_reg->offset;
+ ioefd->gpa_offset = sub_reg->gpa_offset;
ioefd->size = sub_reg->size;
ioefd->fd_index = add_fd_index(msg->out.fds, &msg->out.nr_fds,
sub_reg->fd);
@@ -655,11 +656,11 @@ handle_device_get_region_io_fds(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
ioefd->type = VFIO_USER_IO_FD_TYPE_IOEVENTFD;
} else {
ioefd->type = VFIO_USER_IO_FD_TYPE_IOEVENTFD_SHADOW;
- int ret = add_fd_index(msg->out.fds, &msg->out.nr_fds, sub_reg->shadow_fd);
- assert(ret == 1);
+ ioefd->shadow_mem_fd_index = add_fd_index(msg->out.fds, &msg->out.nr_fds, sub_reg->shadow_fd);
}
ioefd->flags = sub_reg->flags;
ioefd->datamatch = sub_reg->datamatch;
+ ioefd->shadow_offset = sub_reg->shadow_offset;
sub_reg = LIST_NEXT(sub_reg, entry);
}
diff --git a/lib/private.h b/lib/private.h
index 60adfc9..346cfed 100644
--- a/lib/private.h
+++ b/lib/private.h
@@ -185,12 +185,13 @@ struct vfu_ctx {
};
typedef struct ioeventfd {
- uint64_t offset;
+ uint64_t gpa_offset;
uint64_t size;
int32_t fd;
uint32_t flags;
uint64_t datamatch;
int32_t shadow_fd;
+ size_t shadow_offset;
LIST_ENTRY(ioeventfd) entry;
} ioeventfd_t;