Skip to content
Snippets Groups Projects
Commit fc107d86 authored by Philippe Mathieu-Daudé's avatar Philippe Mathieu-Daudé Committed by Stefan Hajnoczi
Browse files

util/vfio-helpers: Assert offset is aligned to page size


mmap(2) states:

  'offset' must be a multiple of the page size as returned
   by sysconf(_SC_PAGE_SIZE).

Add an assertion to be sure we don't break this contract.

Signed-off-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20201103020733.2303148-8-philmd@redhat.com
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Tested-by: default avatarEric Auger <eric.auger@redhat.com>
parent f6b8104d
No related branches found
No related tags found
No related merge requests found
......@@ -162,6 +162,7 @@ void *qemu_vfio_pci_map_bar(QEMUVFIOState *s, int index,
Error **errp)
{
void *p;
assert(QEMU_IS_ALIGNED(offset, qemu_real_host_page_size));
assert_bar_index_valid(s, index);
p = mmap(NULL, MIN(size, s->bar_region_info[index].size - offset),
prot, MAP_SHARED,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment