From: Brian Kocoloski Date: Sat, 14 Apr 2012 05:10:06 +0000 (-0400) Subject: Added selective per CPU initialization option X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=a2b48dd0c4f8ccfa633139bc2b9aa4ddf59eda5c;p=palacios.releases.git Added selective per CPU initialization option --- diff --git a/linux_module/main.c b/linux_module/main.c index 62a0fb5..b24df34 100644 --- a/linux_module/main.c +++ b/linux_module/main.c @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -28,6 +29,12 @@ MODULE_LICENSE("GPL"); +// Module parameter +int cpu_list[NR_CPUS] = {}; +int cpu_list_len = 0; +module_param_array(cpu_list, int, &cpu_list_len, 0644); +MODULE_PARM_DESC(cpu_list, "Comma-delimited list of CPUs that Palacios will run on"); + int mod_allocs = 0; int mod_frees = 0; @@ -171,9 +178,7 @@ static int __init v3_init(void) { palacios_init_mm(); - // Initialize Palacios - palacios_vmm_init(); diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index 2499339..c5b0ca0 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -36,6 +36,9 @@ static struct v3_vm_info * irq_to_guest_map[256]; extern unsigned int cpu_khz; +extern int cpu_list[NR_CPUS]; +extern int cpu_list_len; + /** * Prints a message to the console. @@ -496,12 +499,35 @@ static struct v3_os_hooks palacios_os_hooks = { int palacios_vmm_init( void ) { + int num_cpus = num_online_cpus(); + char * cpu_mask = NULL; + + if (cpu_list_len > 0) { + int major = 0; + int minor = 0; + int i = 0; + + cpu_mask = kmalloc((num_cpus / 8) + 1, GFP_KERNEL); + memset(cpu_mask, 0, (num_cpus / 8) + 1); + + for (i = 0; i < cpu_list_len; i++) { + if (cpu_list[i] >= num_cpus) { + printk("CPU (%d) exceeds number of available CPUs. Ignoring...\n", cpu_list[i]); + continue; + } + + major = cpu_list[i] / 8; + minor = cpu_list[i] % 8; + *(cpu_mask + major) |= (0x1 << minor); + } + } + memset(irq_to_guest_map, 0, sizeof(struct v3_vm_info *) * 256); - + printk("palacios_init starting - calling init_v3\n"); - Init_V3(&palacios_os_hooks, num_online_cpus()); + Init_V3(&palacios_os_hooks, cpu_mask, num_cpus); return 0; diff --git a/palacios/include/palacios/vmm.h b/palacios/include/palacios/vmm.h index ee74ad6..7bfb97c 100644 --- a/palacios/include/palacios/vmm.h +++ b/palacios/include/palacios/vmm.h @@ -331,7 +331,7 @@ struct v3_interrupt { -void Init_V3(struct v3_os_hooks * hooks, int num_cpus); +void Init_V3(struct v3_os_hooks * hooks, char * cpus, int num_cpus); void Shutdown_V3( void ); diff --git a/palacios/src/palacios/vmm.c b/palacios/src/palacios/vmm.c index 8bd6c0a..cef9ff5 100644 --- a/palacios/src/palacios/vmm.c +++ b/palacios/src/palacios/vmm.c @@ -100,9 +100,10 @@ static void deinit_cpu(void * arg) { } - -void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { - int i; +void Init_V3(struct v3_os_hooks * hooks, char * cpu_mask, int num_cpus) { + int i = 0; + int minor = 0; + int major = 0; V3_Print("V3 Print statement to fix a Kitten page fault bug\n"); @@ -134,26 +135,26 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) { V3_init_checkpoint(); #endif - - - if ((hooks) && (hooks->call_on_cpu)) { - for (i = 0; i < num_cpus; i++) { - V3_Print("Initializing VMM extensions on cpu %d\n", i); - hooks->call_on_cpu(i, &init_cpu, (void *)(addr_t)i); + for (i = 0; i < num_cpus; i++) { + major = i / 8; + minor = i % 8; - if (v3_mach_type == V3_INVALID_CPU) { - v3_mach_type = v3_cpu_types[i]; - } + if ((cpu_mask == NULL) || (*(cpu_mask + major) & (0x1 << minor))) { + V3_Print("Initializing VMM extensions on cpu %d\n", i); + hooks->call_on_cpu(i, &init_cpu, (void *)(addr_t)i); - } + if (v3_mach_type == V3_INVALID_CPU) { + v3_mach_type = v3_cpu_types[i]; + } + } + } } - - } + void Shutdown_V3() { int i;