X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fpalacios-stubs.c;h=1e1d17e53ca7f1710da5faae0ba646f85b1eb271;hb=f41eb8ea81fe04856e0939d0f6a7bec9564a8043;hp=965d5780222d50ccbf422e72a7e5c5410aae9064;hpb=35ae6d4aed98585da4c63817a4336daa10546e40;p=palacios.git diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index 965d578..1e1d17e 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -84,7 +85,7 @@ static int init_print_buffers(void) if (!print_buffer[i]) { ERROR("Cannot allocate print buffer for cpu %d\n",i); deinit_print_buffers(); - return -1; + return -1; } memset(print_buffer[i],0,V3_PRINTK_BUF_SIZE); } @@ -305,7 +306,7 @@ palacios_alloc(unsigned int size) { // this function is used extensively throughout palacios and the linux // module, both in places where interrupts are off and where they are on // a GFP_KERNEL call, when done with interrupts off can lead to DEADLOCK - if (irqs_disabled()) { + if (irqs_disabled() || in_atomic()) { return palacios_alloc_extended(size,GFP_ATOMIC,-1); } else { return palacios_alloc_extended(size,GFP_KERNEL,-1); @@ -357,7 +358,7 @@ palacios_paddr_to_vaddr( /** * Runs a function on the specified CPU. */ -static void +void palacios_xcall( int cpu_id, void (*fn)(void *arg), @@ -417,7 +418,7 @@ static int lnx_thread_target(void * arg) { * Creates a kernel thread. */ void * -palacios_start_kernel_thread( +palacios_create_and_start_kernel_thread( int (*fn) (void * arg), void * arg, char * thread_name) { @@ -442,7 +443,7 @@ palacios_start_kernel_thread( * Starts a kernel thread on the specified CPU. */ void * -palacios_start_thread_on_cpu(int cpu_id, +palacios_create_thread_on_cpu(int cpu_id, int (*fn)(void * arg), void * arg, char * thread_name ) { @@ -474,11 +475,36 @@ palacios_start_thread_on_cpu(int cpu_id, return NULL; } - wake_up_process(thread); - return thread; } +void +palacios_start_thread(void * th){ + + struct task_struct * thread = (struct task_struct *)th; + wake_up_process(thread); + +} + +/* + Convenience wrapper +*/ +void * +palacios_create_and_start_thread_on_cpu(int cpu_id, + int (*fn)(void * arg), + void * arg, + char * thread_name ) { + + void *t = palacios_create_thread_on_cpu(cpu_id, fn, arg, thread_name); + + if (t) { + palacios_start_thread(t); + } + + return t; +} + + /** * Rebind a kernel thread to the specified CPU @@ -809,7 +835,7 @@ void palacios_used_fpu(void) struct thread_info *cur = current_thread_info(); // We assume we are not preemptible here... - cur->status |= TS_USEDFPU; + cur->status |= TS_USEDFPU; clts(); // After this, FP Save should be handled by Linux if it // switches to a different task and that task uses FPU @@ -845,7 +871,7 @@ static struct v3_os_hooks palacios_os_hooks = { .hook_interrupt = palacios_hook_interrupt, .ack_irq = palacios_ack_interrupt, .get_cpu_khz = palacios_get_cpu_khz, - .start_kernel_thread = palacios_start_kernel_thread, + .start_kernel_thread = palacios_create_and_start_kernel_thread, .yield_cpu = palacios_yield_cpu, .sleep_cpu = palacios_sleep_cpu, .wakeup_cpu = palacios_wakeup_cpu, @@ -858,7 +884,8 @@ static struct v3_os_hooks palacios_os_hooks = { .get_cpu = palacios_get_cpu, .interrupt_cpu = palacios_interrupt_cpu, .call_on_cpu = palacios_xcall, - .start_thread_on_cpu = palacios_start_thread_on_cpu, + .create_thread_on_cpu = palacios_create_thread_on_cpu, + .start_thread = palacios_start_thread, .move_thread_to_cpu = palacios_move_thread_to_cpu, };