diff options
author | Damjan Marion <damarion@cisco.com> | 2019-02-21 14:44:59 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2019-02-22 16:46:08 +0000 |
commit | 903c21b47073860c53f93d17870cf78c12c51629 (patch) | |
tree | 9b17f8094dce58265499576c703be5b958a259a4 /src/vppinfra | |
parent | c41559afe58d37b5a544767b99c45ade3aaf5f58 (diff) |
physmem: keep physmem VA in 39-bit address space on x86_64
Some x86 CPUs have IOMMU capable dealing only with 39-bit address space
This patch also adds option to specify physmem base address from
startup.conf
Change-Id: I9e8abd26efb60e9c4ad54c035fb1751a4a61f4dc
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/pmalloc.c | 12 | ||||
-rw-r--r-- | src/vppinfra/pmalloc.h | 2 | ||||
-rw-r--r-- | src/vppinfra/test_pmalloc.c | 2 |
3 files changed, 11 insertions, 5 deletions
diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c index 41309dd1d99..9c5f475e8dd 100644 --- a/src/vppinfra/pmalloc.c +++ b/src/vppinfra/pmalloc.c @@ -59,10 +59,11 @@ pmalloc_validate_numa_node (u32 * numa_node) } int -clib_pmalloc_init (clib_pmalloc_main_t * pm, uword size) +clib_pmalloc_init (clib_pmalloc_main_t * pm, uword base_addr, uword size) { uword off, pagesize; u64 *pt = 0; + int mmap_flags; ASSERT (pm->error == 0); @@ -82,8 +83,13 @@ clib_pmalloc_init (clib_pmalloc_main_t * pm, uword size) pm->max_pages = size >> pm->def_log2_page_sz; /* reserve VA space for future growth */ - pm->base = mmap (0, size + pagesize, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS; + + if (base_addr) + mmap_flags |= MAP_FIXED; + + pm->base = mmap (uword_to_pointer (base_addr, void *), size + pagesize, + PROT_NONE, mmap_flags, -1, 0); if (pm->base == MAP_FAILED) { diff --git a/src/vppinfra/pmalloc.h b/src/vppinfra/pmalloc.h index 25c46783f8c..2a3bde2acc4 100644 --- a/src/vppinfra/pmalloc.h +++ b/src/vppinfra/pmalloc.h @@ -103,7 +103,7 @@ typedef struct } clib_pmalloc_main_t; -int clib_pmalloc_init (clib_pmalloc_main_t * pm, uword size); +int clib_pmalloc_init (clib_pmalloc_main_t * pm, uword base_addr, uword size); void *clib_pmalloc_alloc_aligned_on_numa (clib_pmalloc_main_t * pm, uword size, uword align, u32 numa_node); diff --git a/src/vppinfra/test_pmalloc.c b/src/vppinfra/test_pmalloc.c index 90b1775bb4f..a59ff32db05 100644 --- a/src/vppinfra/test_pmalloc.c +++ b/src/vppinfra/test_pmalloc.c @@ -44,7 +44,7 @@ test_palloc (test_main_t * tm) int i; uword *va; - if (clib_pmalloc_init (pm, 0) != 0) + if (clib_pmalloc_init (pm, 0, 0) != 0) return clib_error_return (0, "pmalloc init failure"); fformat (stdout, "Allocate %d items...\n", tm->nitems); |