aboutsummaryrefslogtreecommitdiffstats
path: root/vlib
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2016-01-20 09:11:55 -0500
committerGerrit Code Review <gerrit@fd.io>2016-01-21 12:33:07 +0000
commitbfdedbd5a3ba7e6fdc036d212253aa55c9062211 (patch)
tree63cf45fd5839e377ef757946be8bdcaa90dbc2a4 /vlib
parent08ff7e00bf0e7cf93a732e98a026a76a4349fd41 (diff)
PowerPC64-be arch support. Qemu ("qppc") platform support.
Change-Id: Ib0a05f9d1b08bacef09f6d7c101391737031ee0d Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'vlib')
-rw-r--r--vlib/vlib/main.h1
-rw-r--r--vlib/vlib/node.c26
-rw-r--r--vlib/vlib/threads.c4
-rw-r--r--vlib/vlib/unix/main.c10
-rw-r--r--vlib/vlib/unix/physmem.c5
5 files changed, 35 insertions, 11 deletions
diff --git a/vlib/vlib/main.h b/vlib/vlib/main.h
index 5a8d745661b..1a110459826 100644
--- a/vlib/vlib/main.h
+++ b/vlib/vlib/main.h
@@ -171,6 +171,7 @@ typedef struct vlib_main_t {
/* control-plane API queue signal pending */
volatile u32 queue_signal_pending;
void (*queue_signal_callback)(struct vlib_main_t *);
+ u8 **argv;
} vlib_main_t;
/* Global main structure. */
diff --git a/vlib/vlib/node.c b/vlib/vlib/node.c
index 4fb117e4f3e..66a2d09fdb8 100644
--- a/vlib/vlib/node.c
+++ b/vlib/vlib/node.c
@@ -262,7 +262,7 @@ static void node_elog_init (vlib_main_t * vm, uword ni)
}
#ifdef CLIB_UNIX
-#define STACK_ALIGN 4096
+#define STACK_ALIGN (clib_mem_get_page_size())
#else
#define STACK_ALIGN CLIB_CACHE_LINE_BYTES
#endif
@@ -272,6 +272,7 @@ static void register_node (vlib_main_t * vm,
{
vlib_node_main_t * nm = &vm->node_main;
vlib_node_t * n;
+ u32 page_size = clib_mem_get_page_size();
int i;
if (CLIB_DEBUG > 0)
@@ -363,9 +364,26 @@ static void register_node (vlib_main_t * vm,
log2_n_stack_bytes = clib_max (r->process_log2_n_stack_bytes, 15);
- p = clib_mem_alloc_aligned_no_fail
+#ifdef CLIB_UNIX
+ /*
+ * Bump the stack size if running over a kernel with a large page size,
+ * and the stack isn't any too big to begin with. Otherwise, we'll
+ * trip over the stack guard page for sure.
+ */
+ if ((page_size > (4<<10)) && log2_n_stack_bytes < 19)
+ {
+ if ((1<<log2_n_stack_bytes) <= page_size)
+ log2_n_stack_bytes = min_log2 (page_size) + 1;
+ else
+ log2_n_stack_bytes++;
+ }
+#endif
+
+ p = clib_mem_alloc_aligned_at_offset
(sizeof (p[0]) + (1 << log2_n_stack_bytes),
- STACK_ALIGN);
+ STACK_ALIGN, STRUCT_OFFSET_OF (vlib_process_t, stack));
+ if (p == 0)
+ clib_panic ("failed to allocate process stack (%d bytes)", 1<<log2_n_stack_bytes);
memset (p, 0, sizeof (p[0]));
p->log2_n_stack_bytes = log2_n_stack_bytes;
@@ -388,7 +406,7 @@ static void register_node (vlib_main_t * vm,
* Disallow writes to the bottom page of the stack, to
* catch stack overflows.
*/
- if (mprotect (p->stack, 4096, PROT_READ) < 0)
+ if (mprotect (p->stack, page_size, PROT_READ) < 0)
clib_unix_warning ("process stack");
#endif
diff --git a/vlib/vlib/threads.c b/vlib/vlib/threads.c
index 73abba83f70..3eed1080d31 100644
--- a/vlib/vlib/threads.c
+++ b/vlib/vlib/threads.c
@@ -1025,7 +1025,7 @@ cpu_config (vlib_main_t * vm, unformat_input_t * input)
VLIB_EARLY_CONFIG_FUNCTION (cpu_config, "cpu");
-#if !defined (__x86_64__)
+#if !defined (__x86_64__) && !defined (__aarch64__) && !defined (__powerpc64__)
void __sync_fetch_and_add_8 (void)
{
fformat(stderr, "%s called\n", __FUNCTION__);
@@ -1128,6 +1128,7 @@ show_threads_fn (vlib_main_t * vm,
"ID", "Name", "Type", "LWP",
"lcore", "Core", "Socket", "State");
+#if !defined(__powerpc64__)
for (i = 0; i < vec_len(vlib_worker_threads); i++)
{
w = vlib_worker_threads + i;
@@ -1166,6 +1167,7 @@ show_threads_fn (vlib_main_t * vm,
vlib_cli_output(vm, "%v", line);
vec_free(line);
}
+#endif
return 0;
}
diff --git a/vlib/vlib/unix/main.c b/vlib/vlib/unix/main.c
index b85f3e73326..1aac32759a8 100644
--- a/vlib/vlib/unix/main.c
+++ b/vlib/vlib/unix/main.c
@@ -397,15 +397,13 @@ VLIB_MAIN_LOOP_EXIT_FUNCTION (unix_exit);
u8 **vlib_thread_stacks;
-static char **argv_global;
-
static uword thread0 (uword arg)
{
vlib_main_t * vm = (vlib_main_t *)arg;
unformat_input_t input;
int i;
- unformat_init_command_line (&input, argv_global);
+ unformat_init_command_line (&input, vm->argv);
i = vlib_main (vm, &input);
unformat_free (&input);
@@ -423,7 +421,7 @@ int vlib_unix_main (int argc, char * argv[])
clib_error_t * e;
int i;
- argv_global = argv;
+ vm->argv = (u8 **)argv;
vm->name = argv[0];
vm->heap_base = clib_mem_get_heap ();
ASSERT(vm->heap_base);
@@ -432,7 +430,7 @@ int vlib_unix_main (int argc, char * argv[])
if (i)
return i;
- unformat_init_command_line (&input, argv_global);
+ unformat_init_command_line (&input, vm->argv);
vm->init_functions_called = hash_create (0, /* value bytes */ 0);
e = vlib_call_all_config_functions (vm, &input, 1 /* early */);
if (e != 0)
@@ -459,7 +457,7 @@ int vlib_unix_main (int argc, char * argv[])
* Disallow writes to the bottom page of the stack, to
* catch stack overflows.
*/
- if (mprotect (thread_stacks, 4096, PROT_READ) < 0)
+ if (mprotect (thread_stacks, clib_mem_get_page_size(), PROT_READ) < 0)
clib_unix_warning ("thread stack");
thread_stacks += VLIB_THREAD_STACK_SIZE;
diff --git a/vlib/vlib/unix/physmem.c b/vlib/vlib/unix/physmem.c
index 83b40be6449..d7428c9b227 100644
--- a/vlib/vlib/unix/physmem.c
+++ b/vlib/vlib/unix/physmem.c
@@ -261,6 +261,11 @@ clib_error_t * unix_physmem_init (vlib_main_t * vm, int physical_memory_required
else
error = clib_error_return (0, "uio_dma deprecated");
+ vpm->page_mask = pow2_mask (vpm->log2_n_bytes_per_page);
+ vpm->virtual.start = pointer_to_uword (pm->mem);
+ vpm->virtual.size = pm->mem_size;
+ vpm->virtual.end = vpm->virtual.start + vpm->virtual.size;
+
if (using_fake_memory)
fformat(stderr, "%s: use fake dma pages\n", __FUNCTION__);
else