aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Roberts <lee.roberts@hpe.com>2018-03-24 22:46:19 -0600
committerDamjan Marion <dmarion.lists@gmail.com>2018-03-26 11:23:26 +0000
commit1b8e8252b074e1981d09a53c1a5da19dc35541c9 (patch)
treed5c6be8144e6aae8455570c4f4533857e4402310
parent487f5474fea738174e1cfe68fe70a2eaf58c5ce2 (diff)
Correct address calculation for VPP-1168
Use (u64) cast to ensure proper address calculations. Change-Id: Ifbbe66072eb94bfe33ac04eaa4416abceeb7245e Signed-off-by: Lee Roberts <lee.roberts@hpe.com>
-rw-r--r--src/vlib/linux/physmem.c5
-rw-r--r--src/vppinfra/linux/mem.c2
2 files changed, 4 insertions, 3 deletions
diff --git a/src/vlib/linux/physmem.c b/src/vlib/linux/physmem.c
index 161dbf5c0c7..6f5ef7e1c5a 100644
--- a/src/vlib/linux/physmem.c
+++ b/src/vlib/linux/physmem.c
@@ -154,7 +154,8 @@ unix_physmem_region_iommu_register (vlib_physmem_region_t * pr)
vec_foreach_index (i, pr->page_table)
{
- dma_map.vaddr = pointer_to_uword (pr->mem) + (i << pr->log2_page_size);
+ dma_map.vaddr =
+ pointer_to_uword (pr->mem) + ((u64) i << pr->log2_page_size);
dma_map.size = 1 << pr->log2_page_size;
dma_map.iova = pr->page_table[i];
if (ioctl (fd, VFIO_IOMMU_MAP_DMA, &dma_map) != 0)
@@ -221,7 +222,7 @@ unix_physmem_region_alloc (vlib_main_t * vm, char *name, u32 size,
int i;
for (i = 0; i < pr->n_pages; i++)
{
- void *ptr = pr->mem + (i << pr->log2_page_size);
+ void *ptr = pr->mem + ((u64) i << pr->log2_page_size);
int node;
move_pages (0, 1, &ptr, 0, &node, 0);
if (numa_node != node)
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 0bc08787baa..c47dd57d0e8 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -167,7 +167,7 @@ clib_mem_vm_ext_alloc (clib_mem_vm_alloc_t * a)
}
if (fd != -1)
- if ((ftruncate (fd, n_pages * (1 << log2_page_size))) == -1)
+ if ((ftruncate (fd, (u64) n_pages * (1 << log2_page_size))) == -1)
{
err = clib_error_return_unix (0, "ftruncate");
goto error;