summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-02-21 14:44:59 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-02-22 16:46:08 +0000
commit903c21b47073860c53f93d17870cf78c12c51629 (patch)
tree9b17f8094dce58265499576c703be5b958a259a4 /src/vlib
parentc41559afe58d37b5a544767b99c45ade3aaf5f58 (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/vlib')
-rwxr-xr-xsrc/vlib/physmem.c34
-rw-r--r--src/vlib/physmem.h1
2 files changed, 34 insertions, 1 deletions
diff --git a/src/vlib/physmem.c b/src/vlib/physmem.c
index 21fe44fc1ca..64920e1ebe2 100755
--- a/src/vlib/physmem.c
+++ b/src/vlib/physmem.c
@@ -29,6 +29,15 @@
#include <vlib/pci/pci.h>
#include <vlib/linux/vfio.h>
+#ifdef __x86_64__
+/* we keep physmem in low 38 bits of VA address space as some
+ IOMMU implamentation cannot map above that range */
+#define VLIB_PHYSMEM_DEFAULT_BASE_ADDDR (1ULL << 36)
+#else
+/* let kernel decide */
+#define VLIB_PHYSMEM_DEFAULT_BASE_ADDDR 0
+#endif
+
clib_error_t *
vlib_physmem_shared_map_create (vlib_main_t * vm, char *name, uword size,
u32 log2_page_sz, u32 numa_node,
@@ -102,7 +111,11 @@ vlib_physmem_init (vlib_main_t * vm)
CLIB_CACHE_LINE_BYTES);
memset (p, 0, sizeof (clib_pmalloc_main_t));
vpm->pmalloc_main = (clib_pmalloc_main_t *) p;
- clib_pmalloc_init (vpm->pmalloc_main, 0);
+
+ if (vpm->base_addr == 0)
+ vpm->base_addr = VLIB_PHYSMEM_DEFAULT_BASE_ADDDR;
+
+ clib_pmalloc_init (vpm->pmalloc_main, vpm->base_addr, 0);
return error;
}
@@ -151,6 +164,25 @@ VLIB_CLI_COMMAND (show_physmem_command, static) = {
};
/* *INDENT-ON* */
+static clib_error_t *
+vlib_physmem_config (vlib_main_t * vm, unformat_input_t * input)
+{
+ vlib_physmem_main_t *vpm = &vm->physmem_main;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "base-addr 0x%lx", &vpm->base_addr))
+ ;
+ else
+ return unformat_parse_error (input);
+ }
+
+ unformat_free (input);
+ return 0;
+}
+
+VLIB_EARLY_CONFIG_FUNCTION (vlib_physmem_config, "physmem");
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vlib/physmem.h b/src/vlib/physmem.h
index a986a50b1cb..7b7a3af3dfa 100644
--- a/src/vlib/physmem.h
+++ b/src/vlib/physmem.h
@@ -56,6 +56,7 @@ typedef struct
typedef struct
{
u32 flags;
+ uword base_addr;
#define VLIB_PHYSMEM_MAIN_F_HAVE_PAGEMAP (1 << 0)
#define VLIB_PHYSMEM_MAIN_F_HAVE_IOMMU (1 << 1)
vlib_physmem_map_t *maps;