From e0c15dfd087f8093ee6aab697e9ac2a252ab42bb Mon Sep 17 00:00:00 2001 From: Jag Raman Date: Tue, 13 Jul 2021 12:18:33 -0400 Subject: add VFU_REGION_FLAG_ALWAYS_CB to receive callback always (#583) --- lib/libvfio-user.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index a90d9c2..1ee4026 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -208,7 +208,8 @@ region_access(vfu_ctx_t *vfu_ctx, size_t region_index, char *buf, dump_buffer("buffer write", buf, count); } - if (region_index == VFU_PCI_DEV_CFG_REGION_IDX) { + if ((region_index == VFU_PCI_DEV_CFG_REGION_IDX) && + !(vfu_ctx->reg_info[region_index].flags & VFU_REGION_FLAG_ALWAYS_CB)) { ret = pci_config_space_access(vfu_ctx, buf, count, offset, is_write); if (ret == -1) { return ret; @@ -1445,7 +1446,13 @@ vfu_setup_region(vfu_ctx_t *vfu_ctx, int region_idx, size_t size, * PCI config space is never mappable or of type mem. */ if (region_idx == VFU_PCI_DEV_CFG_REGION_IDX && - flags != VFU_REGION_FLAG_RW) { + (((flags & VFU_REGION_FLAG_RW) != VFU_REGION_FLAG_RW) || + (flags & VFU_REGION_FLAG_MEM))) { + return ERROR_INT(EINVAL); + } + + if ((flags & VFU_REGION_FLAG_ALWAYS_CB) && (cb == NULL)) { + vfu_log(vfu_ctx, LOG_ERR, "VFU_REGION_FLAG_ALWAYS_CB needs callback"); return ERROR_INT(EINVAL); } -- cgit v1.1