aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThanos Makatos <thanos.makatos@nutanix.com>2022-10-04 12:35:12 +0100
committerGitHub <noreply@github.com>2022-10-04 12:35:12 +0100
commitaa19ba90f73c9b456a03a03d0d453e79fd8cf2d9 (patch)
tree933e141b0490f443cd653954f92fd39fd24f69c3 /lib
parent87c216d9492476c28eb306b8f4ba22a1269849cf (diff)
downloadlibvfio-user-aa19ba90f73c9b456a03a03d0d453e79fd8cf2d9.zip
libvfio-user-aa19ba90f73c9b456a03a03d0d453e79fd8cf2d9.tar.gz
libvfio-user-aa19ba90f73c9b456a03a03d0d453e79fd8cf2d9.tar.bz2
fix compilation for i386 and ppc64 (#709)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com> Reviewed-by: John Levon <john.levon@nutanix.com> Reported-by: Eduardo Lima <eblima@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/common.h2
-rw-r--r--lib/dma.c28
-rw-r--r--lib/dma.h3
-rw-r--r--lib/libvfio-user.c82
-rw-r--r--lib/migration.c18
-rw-r--r--lib/pci.c12
-rw-r--r--lib/pci_caps.c12
-rw-r--r--lib/private.h4
-rw-r--r--lib/tran.c2
-rw-r--r--lib/tran_pipe.c2
10 files changed, 102 insertions, 63 deletions
diff --git a/lib/common.h b/lib/common.h
index 4d60199..0c3abda 100644
--- a/lib/common.h
+++ b/lib/common.h
@@ -58,6 +58,8 @@
#define ROUND_DOWN(x, a) ((x) & ~((a)-1))
#define ROUND_UP(x,a) ROUND_DOWN((x)+(a)-1, a)
+typedef unsigned long long ull_t;
+
/* Saturating uint64_t addition. */
static inline uint64_t
satadd_u64(uint64_t a, uint64_t b)
diff --git a/lib/dma.c b/lib/dma.c
index ac3ddfe..beefeac 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -249,7 +249,7 @@ dma_map_region(dma_controller_t *dma, dma_memory_region_t *region)
region->info.vaddr = mmap_base + (region->offset - offset);
vfu_log(dma->vfu_ctx, LOG_DEBUG, "mapped DMA region iova=[%p, %p) "
- "vaddr=%p page_size=%#lx mapping=[%p, %p)",
+ "vaddr=%p page_size=%zx mapping=[%p, %p)",
region->info.iova.iov_base, iov_end(&region->info.iova),
region->info.vaddr, region->info.page_size,
region->info.mapping.iov_base, iov_end(&region->info.mapping));
@@ -290,7 +290,7 @@ dirty_page_logging_start_on_region(dma_memory_region_t *region, size_t pgsize)
int
MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
- vfu_dma_addr_t dma_addr, size_t size,
+ vfu_dma_addr_t dma_addr, uint64_t size,
int fd, off_t offset, uint32_t prot)
{
dma_memory_region_t *region;
@@ -300,12 +300,12 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
assert(dma != NULL);
- snprintf(rstr, sizeof(rstr), "[%p, %p) fd=%d offset=%#lx prot=%#x",
- dma_addr, (char *)dma_addr + size, fd, offset, prot);
+ snprintf(rstr, sizeof(rstr), "[%p, %p) fd=%d offset=%#llx prot=%#x",
+ dma_addr, dma_addr + size, fd, (ull_t)offset, prot);
if (size > dma->max_size) {
- vfu_log(dma->vfu_ctx, LOG_ERR, "DMA region size %zu > max %zu",
- size, dma->max_size);
+ vfu_log(dma->vfu_ctx, LOG_ERR, "DMA region size %llu > max %zu",
+ (unsigned long long)size, dma->max_size);
return ERROR_INT(ENOSPC);
}
@@ -317,7 +317,8 @@ MOCK_DEFINE(dma_controller_add_region)(dma_controller_t *dma,
region->info.iova.iov_len == size) {
if (offset != region->offset) {
vfu_log(dma->vfu_ctx, LOG_ERR, "bad offset for new DMA region "
- "%s; existing=%#lx", rstr, region->offset);
+ "%s; existing=%#llx", rstr,
+ (ull_t)region->offset);
return ERROR_INT(EINVAL);
}
if (!fds_are_same_file(region->fd, fd)) {
@@ -568,12 +569,19 @@ dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr,
* IOVAs.
*/
ret = dma_addr_to_sgl(dma, addr, len, &sg, 1, PROT_NONE);
- if (ret != 1 || sg.dma_addr != addr || sg.length != len) {
+ if (unlikely(ret != 1)) {
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "failed to translate %#llx-%#llx: %m",
+ (unsigned long long)(uintptr_t)addr,
+ (unsigned long long)(uintptr_t)addr + len - 1);
+ return ret;
+ }
+
+ if (unlikely(sg.dma_addr != addr || sg.length != len)) {
return ERROR_INT(ENOTSUP);
}
if (pgsize != dma->dirty_pgsize) {
- vfu_log(dma->vfu_ctx, LOG_ERR, "bad page size %ld", pgsize);
+ vfu_log(dma->vfu_ctx, LOG_ERR, "bad page size %zu", pgsize);
return ERROR_INT(EINVAL);
}
@@ -588,7 +596,7 @@ dma_controller_dirty_page_get(dma_controller_t *dma, vfu_dma_addr_t addr,
* receive.
*/
if (size != (size_t)bitmap_size) {
- vfu_log(dma->vfu_ctx, LOG_ERR, "bad bitmap size %ld != %ld", size,
+ vfu_log(dma->vfu_ctx, LOG_ERR, "bad bitmap size %zu != %zu", size,
bitmap_size);
return ERROR_INT(EINVAL);
}
diff --git a/lib/dma.h b/lib/dma.h
index be64617..9687f49 100644
--- a/lib/dma.h
+++ b/lib/dma.h
@@ -125,7 +125,7 @@ dma_controller_destroy(dma_controller_t *dma);
* - On failure, -1 with errno set.
*/
MOCK_DECLARE(int, dma_controller_add_region, dma_controller_t *dma,
- vfu_dma_addr_t dma_addr, size_t size, int fd, off_t offset,
+ vfu_dma_addr_t dma_addr, uint64_t size, int fd, off_t offset,
uint32_t prot);
MOCK_DECLARE(int, dma_controller_remove_region, dma_controller_t *dma,
@@ -209,6 +209,7 @@ dma_init_sg(const dma_controller_t *dma, dma_sg_t *sg, vfu_dma_addr_t dma_addr,
const dma_memory_region_t *const region = &dma->regions[region_index];
if ((prot & PROT_WRITE) && !(region->info.prot & PROT_WRITE)) {
+ vfu_log(dma->vfu_ctx, LOG_DEBUG, "read-only region");
return ERROR_INT(EACCES);
}
diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c
index 2e2ba8f..5bcb0c2 100644
--- a/lib/libvfio-user.c
+++ b/lib/libvfio-user.c
@@ -47,7 +47,7 @@
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
-
+#include <inttypes.h>
#include <sys/eventfd.h>
#include "dma.h"
@@ -183,17 +183,19 @@ debug_region_access(vfu_ctx_t *vfu_ctx, size_t region, char *buf,
case 2: val = *((uint16_t *)buf); break;
case 1: val = *((uint8_t *)buf); break;
default:
- vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: %s %zu bytes at %#lx",
- region, verb, count, offset);
+ vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: %s %zu bytes at %#llx",
+ region, verb, count, (ull_t)offset);
return;
}
if (is_write) {
- vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: wrote %#zx to (%#lx:%zu)",
- region, val, offset, count);
+ vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: wrote %#llx to (%#llx:%zu)",
+ region, (ull_t)val, (ull_t)offset,
+ count);
} else {
- vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: read %#zx from (%#lx:%zu)",
- region, val, offset, count);
+ vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: read %#llx from (%#llx:%zu)",
+ region, (ull_t)val, (ull_t)offset,
+ count);
}
}
@@ -235,8 +237,8 @@ region_access(vfu_ctx_t *vfu_ctx, size_t region, char *buf,
out:
if (ret != (ssize_t)count) {
- vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: %s (%#lx:%zu) failed: %m",
- region, verb, offset, count);
+ vfu_log(vfu_ctx, LOG_DEBUG, "region%zu: %s (%#llx:%zu) failed: %m",
+ region, verb, (ull_t)offset, count);
} else {
debug_region_access(vfu_ctx, region, buf, count, offset, is_write);
}
@@ -266,7 +268,7 @@ is_valid_region_access(vfu_ctx_t *vfu_ctx, size_t size, uint16_t cmd,
if (cmd == VFIO_USER_REGION_WRITE && size - sizeof(*ra) != ra->count) {
vfu_log(vfu_ctx, LOG_ERR, "region write count too small: "
- "expected %lu, got %u", size - sizeof(*ra), ra->count);
+ "expected %zu, got %u", size - sizeof(*ra), ra->count);
return false;
}
@@ -278,8 +280,10 @@ is_valid_region_access(vfu_ctx_t *vfu_ctx, size_t size, uint16_t cmd,
}
if (satadd_u64(ra->offset, ra->count) > vfu_ctx->reg_info[index].size) {
- vfu_log(vfu_ctx, LOG_ERR, "out of bounds region access %#lx-%#lx "
- "(size %u)", ra->offset, ra->offset + ra->count,
+ vfu_log(vfu_ctx, LOG_ERR,
+ "out of bounds region access %#llx-%#llx (size %u)",
+ (ull_t)ra->offset,
+ (ull_t)(ra->offset + ra->count),
vfu_ctx->reg_info[index].size);
return false;
@@ -337,7 +341,7 @@ handle_region_access(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
ret = region_access(vfu_ctx, in_ra->region, buf, in_ra->count,
in_ra->offset, msg->hdr.cmd == VFIO_USER_REGION_WRITE);
- if (ret != in_ra->count) {
+ if (ret != (ssize_t)in_ra->count) {
/* FIXME we should return whatever has been accessed, not an error */
if (ret >= 0) {
ret = ERROR_INT(EINVAL);
@@ -458,8 +462,10 @@ handle_device_get_region_info(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
}
vfu_log(vfu_ctx, LOG_DEBUG, "region_info[%d] offset %#llx flags %#x "
- "size %llu " "argsz %u", out_info->index, out_info->offset,
- out_info->flags, out_info->size, out_info->argsz);
+ "size %llu argsz %u", out_info->index,
+ (ull_t)out_info->offset,
+ out_info->flags, (ull_t)out_info->size,
+ out_info->argsz);
return 0;
}
@@ -476,6 +482,7 @@ vfu_create_ioeventfd(vfu_ctx_t *vfu_ctx, uint32_t region_idx, int fd,
#ifndef SHADOW_IOEVENTFD
if (shadow_fd != -1) {
+ vfu_log(vfu_ctx, LOG_DEBUG, "shadow ioeventfd not compiled");
return ERROR_INT(EINVAL);
}
#endif
@@ -689,8 +696,10 @@ handle_dma_map(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
return ERROR_INT(EINVAL);
}
- snprintf(rstr, sizeof(rstr), "[%#lx, %#lx) offset=%#lx flags=%#x",
- dma_map->addr, dma_map->addr + dma_map->size, dma_map->offset,
+ snprintf(rstr, sizeof(rstr), "[%#llx, %#llx) offset=%#llx flags=%#x",
+ (ull_t)dma_map->addr,
+ (ull_t)(dma_map->addr + dma_map->size),
+ (ull_t)dma_map->offset,
dma_map->flags);
vfu_log(vfu_ctx, LOG_DEBUG, "adding DMA region %s", rstr);
@@ -718,7 +727,8 @@ handle_dma_map(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
}
}
- ret = dma_controller_add_region(vfu_ctx->dma, (void *)dma_map->addr,
+ ret = dma_controller_add_region(vfu_ctx->dma,
+ (vfu_dma_addr_t)(uintptr_t)dma_map->addr,
dma_map->size, fd, dma_map->offset,
prot);
if (ret < 0) {
@@ -765,8 +775,9 @@ is_valid_unmap(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
case VFIO_DMA_UNMAP_FLAG_ALL:
if (dma_unmap->addr || dma_unmap->size) {
- vfu_log(vfu_ctx, LOG_ERR, "bad addr=%#lx or size=%#lx, expected "
- "both to be zero", dma_unmap->addr, dma_unmap->size);
+ vfu_log(vfu_ctx, LOG_ERR, "bad addr=%#llx or size=%#llx, expected "
+ "both to be zero", (ull_t)dma_unmap->addr,
+ (ull_t)dma_unmap->size);
errno = EINVAL;
return false;
}
@@ -809,8 +820,10 @@ handle_dma_unmap(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
return -1;
}
- snprintf(rstr, sizeof(rstr), "[%#lx, %#lx) flags=%#x",
- dma_unmap->addr, dma_unmap->addr + dma_unmap->size, dma_unmap->flags);
+ snprintf(rstr, sizeof(rstr), "[%#llx, %#llx) flags=%#x",
+ (ull_t)dma_unmap->addr,
+ (ull_t)(dma_unmap->addr + dma_unmap->size),
+ dma_unmap->flags);
vfu_log(vfu_ctx, LOG_DEBUG, "removing DMA region %s", rstr);
@@ -835,7 +848,7 @@ handle_dma_unmap(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
if (dma_unmap->flags & VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP) {
memcpy(msg->out.iov.iov_base + sizeof(*dma_unmap), dma_unmap->bitmap, sizeof(*dma_unmap->bitmap));
ret = dma_controller_dirty_page_get(vfu_ctx->dma,
- (vfu_dma_addr_t)dma_unmap->addr,
+ (vfu_dma_addr_t)(uintptr_t)dma_unmap->addr,
dma_unmap->size,
dma_unmap->bitmap->pgsize,
dma_unmap->bitmap->size,
@@ -847,7 +860,7 @@ handle_dma_unmap(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg,
}
ret = dma_controller_remove_region(vfu_ctx->dma,
- (void *)dma_unmap->addr,
+ (vfu_dma_addr_t)(uintptr_t)dma_unmap->addr,
dma_unmap->size,
vfu_ctx->dma_unregister,
vfu_ctx);
@@ -942,7 +955,7 @@ handle_dirty_pages_get(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
range_out = msg->out.iov.iov_base + sizeof(*dirty_pages_out);
memcpy(range_out, range_in, sizeof(*range_out));
ret = dma_controller_dirty_page_get(vfu_ctx->dma,
- (vfu_dma_addr_t)range_in->iova,
+ (vfu_dma_addr_t)(uintptr_t)range_in->iova,
range_in->size,
range_in->bitmap.pgsize,
range_in->bitmap.size, bitmap_out);
@@ -957,8 +970,8 @@ handle_dirty_pages_get(vfu_ctx_t *vfu_ctx, vfu_msg_t *msg)
}
} else {
vfu_log(vfu_ctx, LOG_ERR,
- "dirty pages: get [%#lx, %#lx): buffer too small (%u < %lu)",
- range_in->iova, range_in->iova + range_in->size,
+ "dirty pages: get [%#llx, %#llx): buffer too small (%u < %zu)",
+ (ull_t)range_in->iova, (ull_t)range_in->iova + range_in->size,
dirty_pages_in->argsz, argsz);
}
@@ -1891,6 +1904,10 @@ vfu_setup_region(vfu_ctx_t *vfu_ctx, int region_idx, size_t size,
for (i = 0; i < nr_mmap_areas; i++) {
struct iovec *iov = &mmap_areas[i];
if ((size_t)iov_end(iov) > size) {
+ vfu_log(vfu_ctx, LOG_ERR, "mmap area #%zu %#llx-%#llx exceeds region size of %#llx\n",
+ i, (unsigned long long)(uintptr_t)iov->iov_base,
+ (unsigned long long)(uintptr_t)(iov->iov_base) + iov->iov_len - 1,
+ (unsigned long long)size);
return ERROR_INT(EINVAL);
}
}
@@ -2150,7 +2167,7 @@ vfu_dma_transfer(vfu_ctx_t *vfu_ctx, enum vfio_user_command cmd,
while (remaining > 0) {
int ret;
- dma_req->addr = (uint64_t)sg->dma_addr + count;
+ dma_req->addr = (uintptr_t)sg->dma_addr + count;
dma_req->count = MIN(remaining, vfu_ctx->client_max_data_xfer_size);
if (cmd == VFIO_USER_DMA_WRITE) {
@@ -2179,10 +2196,13 @@ vfu_dma_transfer(vfu_ctx_t *vfu_ctx, enum vfio_user_command cmd,
if (dma_reply->addr != dma_req->addr ||
dma_reply->count != dma_req->count) {
+ /* TODO shouldn't we use %#llx for both and also use the range format? */
vfu_log(vfu_ctx, LOG_ERR, "bad reply to DMA transfer: "
- "request:%#lx,%lu reply:%#lx,%lu",
- dma_req->addr, dma_req->count,
- dma_reply->addr, dma_reply->count);
+ "request:%#llx,%llu reply:%#llx,%llu",
+ (ull_t)dma_req->addr,
+ (ull_t)dma_req->count,
+ (ull_t)dma_reply->addr,
+ (ull_t)dma_reply->count);
free(rbuf);
return ERROR_INT(EINVAL);
}
diff --git a/lib/migration.c b/lib/migration.c
index 2936768..794e7b8 100644
--- a/lib/migration.c
+++ b/lib/migration.c
@@ -413,7 +413,7 @@ MOCK_DEFINE(migration_region_access_registers)(vfu_ctx_t *vfu_ctx, char *buf,
case offsetof(struct vfio_user_migration_info, device_state):
if (count != sizeof(migr->info.device_state)) {
vfu_log(vfu_ctx, LOG_ERR,
- "bad device_state access size %ld", count);
+ "bad device_state access size %zu", count);
return ERROR_INT(EINVAL);
}
device_state = (uint32_t *)buf;
@@ -443,7 +443,7 @@ MOCK_DEFINE(migration_region_access_registers)(vfu_ctx_t *vfu_ctx, char *buf,
case offsetof(struct vfio_user_migration_info, pending_bytes):
if (count != sizeof(migr->info.pending_bytes)) {
vfu_log(vfu_ctx, LOG_ERR,
- "bad pending_bytes access size %ld", count);
+ "bad pending_bytes access size %zu", count);
return ERROR_INT(EINVAL);
}
ret = handle_pending_bytes(vfu_ctx, migr, (uint64_t *)buf, is_write);
@@ -451,7 +451,7 @@ MOCK_DEFINE(migration_region_access_registers)(vfu_ctx_t *vfu_ctx, char *buf,
case offsetof(struct vfio_user_migration_info, data_offset):
if (count != sizeof(migr->info.data_offset)) {
vfu_log(vfu_ctx, LOG_ERR,
- "bad data_offset access size %ld", count);
+ "bad data_offset access size %zu", count);
return ERROR_INT(EINVAL);
}
ret = handle_data_offset(vfu_ctx, migr, (uint64_t *)buf, is_write);
@@ -459,14 +459,15 @@ MOCK_DEFINE(migration_region_access_registers)(vfu_ctx_t *vfu_ctx, char *buf,
case offsetof(struct vfio_user_migration_info, data_size):
if (count != sizeof(migr->info.data_size)) {
vfu_log(vfu_ctx, LOG_ERR,
- "bad data_size access size %ld", count);
+ "bad data_size access size %zu", count);
return ERROR_INT(EINVAL);
}
ret = handle_data_size(vfu_ctx, migr, (uint64_t *)buf, is_write);
break;
default:
- vfu_log(vfu_ctx, LOG_ERR, "bad migration region register offset %#lx",
- pos);
+ vfu_log(vfu_ctx, LOG_ERR,
+ "bad migration region register offset %#llx",
+ (ull_t)pos);
return ERROR_INT(EINVAL);
}
return ret;
@@ -502,8 +503,9 @@ migration_region_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count,
* any access to the data region properly.
*/
vfu_log(vfu_ctx, LOG_WARNING,
- "bad access to dead space %#lx-%#lx in migration region",
- pos, pos + count - 1);
+ "bad access to dead space %#llx - %#llx in migration region",
+ (ull_t)pos,
+ (ull_t)(pos + count - 1));
return ERROR_INT(EINVAL);
}
diff --git a/lib/pci.c b/lib/pci.c
index 21db6e4..5a0cd1a 100644
--- a/lib/pci.c
+++ b/lib/pci.c
@@ -264,8 +264,8 @@ pci_hdr_write(vfu_ctx_t *vfu_ctx, const char *buf, loff_t offset)
ret = handle_erom_write(vfu_ctx, cfg_space, buf);
break;
default:
- vfu_log(vfu_ctx, LOG_ERR, "PCI config write %#lx not handled",
- offset);
+ vfu_log(vfu_ctx, LOG_ERR, "PCI config write %#llx not handled",
+ (ull_t)offset);
ret = ERROR_INT(EINVAL);
}
@@ -315,7 +315,7 @@ pci_nonstd_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count,
if (is_write) {
vfu_log(vfu_ctx, LOG_ERR, "no callback for write to config space "
- "offset %lu size %zu", offset, count);
+ "offset %#llx size %zu", (ull_t)offset, count);
return ERROR_INT(EINVAL);
}
@@ -429,8 +429,10 @@ pci_config_space_access(vfu_ctx_t *vfu_ctx, char *buf, size_t count,
size = pci_config_space_next_segment(vfu_ctx, count, offset, is_write,
&cb);
if (cb == NULL) {
- vfu_log(vfu_ctx, LOG_ERR, "bad write to PCI config space %#lx-%#lx",
- offset, offset + count - 1);
+ vfu_log(vfu_ctx, LOG_ERR,
+ "bad write to PCI config space %#llx-%#llx",
+ (ull_t)offset,
+ (ull_t)(offset + count - 1));
return size;
}
diff --git a/lib/pci_caps.c b/lib/pci_caps.c
index e9dc5ac..50eb29b 100644
--- a/lib/pci_caps.c
+++ b/lib/pci_caps.c
@@ -483,7 +483,7 @@ cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off != 0) {
if (cap->off < PCI_STD_HEADER_SIZEOF) {
- vfu_log(vfu_ctx, LOG_ERR, "invalid offset %#lx for capability "
+ vfu_log(vfu_ctx, LOG_ERR, "invalid offset %zx for capability "
"%u (%s)", cap->off, cap->id, cap->name);
return ERROR_INT(EINVAL);
}
@@ -516,11 +516,11 @@ cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off + cap->size > pci_config_space_size(vfu_ctx)) {
vfu_log(vfu_ctx, LOG_ERR, "no config space left for capability "
- "%u (%s) of size %zu bytes at offset %#lx", cap->id,
+ "%u (%s) of size %zu bytes at offset %zx", cap->id,
cap->name, cap->size, cap->off);
return ERROR_INT(ENOSPC);
}
-
+
memcpy(cap_data(vfu_ctx, cap), data, cap->size);
/* Make sure the previous cap's PCI_CAP_LIST_NEXT points to us. */
*prevp = cap->off;
@@ -547,7 +547,7 @@ ext_cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off != 0) {
if (cap->off < PCI_CFG_SPACE_SIZE) {
- vfu_log(vfu_ctx, LOG_ERR, "invalid offset %#lx for capability "
+ vfu_log(vfu_ctx, LOG_ERR, "invalid offset %zx for capability "
"%u (%s)", cap->off, cap->id, cap->name);
return ERROR_INT(EINVAL);
}
@@ -581,7 +581,7 @@ ext_cap_place(vfu_ctx_t *vfu_ctx, struct pci_cap *cap, void *data)
if (cap->off + cap->size > pci_config_space_size(vfu_ctx)) {
vfu_log(vfu_ctx, LOG_ERR, "no config space left for capability "
- "%u (%s) of size %zu bytes at offset %#lx", cap->id,
+ "%u (%s) of size %zu bytes at offset %zu", cap->id,
cap->name, cap->size, cap->off);
return ERROR_INT(ENOSPC);
}
@@ -700,7 +700,7 @@ vfu_pci_add_capability(vfu_ctx_t *vfu_ctx, size_t pos, int flags, void *data)
if (cap.off + cap.size >= pci_config_space_size(vfu_ctx)) {
vfu_log(vfu_ctx, LOG_DEBUG,
- "PCI capability past end of config space, %#lx >= %#lx",
+ "PCI capability past end of config space, %zx >= %zx",
cap.off + cap.size, pci_config_space_size(vfu_ctx));
return ERROR_INT(EINVAL);
}
diff --git a/lib/private.h b/lib/private.h
index b875138..60adfc9 100644
--- a/lib/private.h
+++ b/lib/private.h
@@ -45,7 +45,11 @@
* is to limit the size of the dirty bitmaps: this corresponds to 256MB at a 4K
* page size.
*/
+#if defined(__x86_64__) || defined(__ppc64__)
#define MAX_DMA_SIZE (8 * ONE_TB)
+#else
+#define MAX_DMA_SIZE UINT32_MAX /* FIXME check for __i386__ etc? */
+#endif
#define MAX_DMA_REGIONS 16
#define SERVER_MAX_DATA_XFER_SIZE (VFIO_USER_DEFAULT_MAX_DATA_XFER_SIZE)
diff --git a/lib/tran.c b/lib/tran.c
index ba49fd6..a183877 100644
--- a/lib/tran.c
+++ b/lib/tran.c
@@ -176,7 +176,7 @@ recv_version(vfu_ctx_t *vfu_ctx, uint16_t *msg_idp,
if (msg.in.iov.iov_len < sizeof(*cversion)) {
vfu_log(vfu_ctx, LOG_ERR,
- "msg%#hx: VFIO_USER_VERSION: invalid size %lu",
+ "msg%#hx: VFIO_USER_VERSION: invalid size %zu",
*msg_idp, msg.in.iov.iov_len);
ret = EINVAL;
goto out;
diff --git a/lib/tran_pipe.c b/lib/tran_pipe.c
index dea2c3c..d1428ab 100644
--- a/lib/tran_pipe.c
+++ b/lib/tran_pipe.c
@@ -83,7 +83,7 @@ tran_pipe_send_iovec(int fd, uint16_t msg_id, bool is_reply,
return ERROR_INT(ECONNRESET);
}
return -1;
- } else if (ret < hdr.msg_size) {
+ } else if (ret < (ssize_t)hdr.msg_size) {
return ERROR_INT(ECONNRESET);
}