aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/devices/virtio
diff options
context:
space:
mode:
authorPierre Pfister <ppfister@cisco.com>2017-04-20 15:34:00 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2017-04-26 19:36:35 +0000
commitbed5489a4eb109efe91dac8d259a03b1834b0db8 (patch)
tree0bc56522a396ac336da14869b5dd5aba9fd09b3b /src/vnet/devices/virtio
parent5ef1fef692182dabc986995390d46552d88fb9df (diff)
vhost: Fix mmap size calculation
I had a bug where a requested size of 1G was resulting in an aligned size of '1G + 2M', resulting in an OOM error. Previous code was adding one huge page size when memory is already aligned. Change-Id: Idd3aa0e9b893fb3efccba6ae1c7161e26d3f9456 Signed-off-by: Pierre Pfister <ppfister@cisco.com>
Diffstat (limited to 'src/vnet/devices/virtio')
-rw-r--r--src/vnet/devices/virtio/vhost-user.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index bcfef9f5aee..3ac76977099 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -303,7 +303,7 @@ unmap_all_mem_regions (vhost_user_intf_t * vui)
ssize_t map_sz = (vui->regions[i].memory_size +
vui->regions[i].mmap_offset +
- page_sz) & ~(page_sz - 1);
+ page_sz - 1) & ~(page_sz - 1);
r =
munmap (vui->region_mmap_addr[i] - vui->regions[i].mmap_offset,
@@ -917,7 +917,7 @@ vhost_user_socket_read (unix_file_t * uf)
/* align size to 2M page */
ssize_t map_sz = (vui->regions[i].memory_size +
vui->regions[i].mmap_offset +
- page_sz) & ~(page_sz - 1);
+ page_sz - 1) & ~(page_sz - 1);
vui->region_mmap_addr[i] = mmap (0, map_sz, PROT_READ | PROT_WRITE,
MAP_SHARED, fds[i], 0);
@@ -1168,7 +1168,7 @@ vhost_user_socket_read (unix_file_t * uf)
/* align size to 2M page */
long page_sz = get_huge_page_size (fd);
ssize_t map_sz =
- (msg.log.size + msg.log.offset + page_sz) & ~(page_sz - 1);
+ (msg.log.size + msg.log.offset + page_sz - 1) & ~(page_sz - 1);
vui->log_base_addr = mmap (0, map_sz, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0);