X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fpalacios-stubs.c;h=60b481fc9ce99dd0b23a961c00c1dbfb29d06fd6;hb=b040d5d6eeac8036a6f39905913dcacbac87c6dd;hp=78759d0886c9e1534174c11e767fa98c75487887;hpb=fe436f3769306b960087068610f9afc85b7141ba;p=palacios.git diff --git a/linux_module/palacios-stubs.c b/linux_module/palacios-stubs.c index 78759d0..60b481f 100644 --- a/linux_module/palacios-stubs.c +++ b/linux_module/palacios-stubs.c @@ -48,7 +48,7 @@ static void deinit_print_buffers(void) for (i=0;iname); - kfree(thread_info); + palacios_free(thread_info); // handle cleanup do_exit(ret); @@ -276,7 +289,12 @@ palacios_start_kernel_thread( void * arg, char * thread_name) { - struct lnx_thread_arg * thread_info = kmalloc(sizeof(struct lnx_thread_arg), GFP_KERNEL); + struct lnx_thread_arg * thread_info = palacios_alloc(sizeof(struct lnx_thread_arg)); + + if (!thread_info) { + ERROR("ALERT ALERT Unable to allocate thread\n"); + return NULL; + } thread_info->fn = fn; thread_info->arg = arg; @@ -295,7 +313,12 @@ palacios_start_thread_on_cpu(int cpu_id, void * arg, char * thread_name ) { struct task_struct * thread = NULL; - struct lnx_thread_arg * thread_info = kmalloc(sizeof(struct lnx_thread_arg), GFP_KERNEL); + struct lnx_thread_arg * thread_info = palacios_alloc(sizeof(struct lnx_thread_arg)); + + if (!thread_info) { + ERROR("ALERT ALERT Unable to allocate thread to start on cpu\n"); + return NULL; + } thread_info->fn = fn; thread_info->arg = arg; @@ -306,11 +329,14 @@ palacios_start_thread_on_cpu(int cpu_id, if (IS_ERR(thread)) { WARNING("Palacios error creating thread: %s\n", thread_name); + palacios_free(thread_info); return NULL; } if (set_cpus_allowed_ptr(thread, cpumask_of(cpu_id)) != 0) { + WARNING("Attempt to start thread on disallowed CPU\n"); kthread_stop(thread); + palacios_free(thread_info); return NULL; } @@ -438,7 +464,8 @@ palacios_hook_interrupt(struct v3_vm_info * vm, //set_idtvec_handler(vector, palacios_dispatch_interrupt); if (vector < 32) { - panic("unexpected vector for hooking\n"); + ERROR("unexpected vector for hooking\n"); + return -1; } else { int device_id = 0; @@ -461,7 +488,8 @@ palacios_hook_interrupt(struct v3_vm_info * vm, if (error) { ERROR("error code for request_irq is %d\n", error); - panic("request vector %d failed", vector); + ERROR("request vector %d failed", vector); + return -1; } } @@ -519,7 +547,10 @@ palacios_yield_cpu(void) */ void palacios_yield_cpu_timed(unsigned int us) { - unsigned int jiffies = 1000000U * HZ / us; + + unsigned int uspj = 1000000U/HZ; + + unsigned int jiffies = us/uspj + ((us%uspj) !=0); // ceiling set_current_state(TASK_INTERRUPTIBLE); @@ -535,10 +566,13 @@ void palacios_yield_cpu_timed(unsigned int us) void * palacios_mutex_alloc(void) { - spinlock_t *lock = kmalloc(sizeof(spinlock_t), GFP_KERNEL); + spinlock_t *lock = palacios_alloc(sizeof(spinlock_t)); if (lock) { spin_lock_init(lock); + } else { + ERROR("ALERT ALERT Unable to allocate lock\n"); + return NULL; } return lock; @@ -549,7 +583,7 @@ palacios_mutex_alloc(void) */ void palacios_mutex_free(void * mutex) { - kfree(mutex); + palacios_free(mutex); } /** @@ -588,7 +622,7 @@ palacios_mutex_unlock( /** - * Unlocks a mutex. + * Unlocks a mutex and restores previous interrupt state on this core */ void palacios_mutex_unlock_irqrestore(void *mutex, void *flags) @@ -640,7 +674,7 @@ int palacios_vmm_init( void ) int minor = 0; int i = 0; - cpu_mask = kmalloc((num_cpus / 8) + 1, GFP_KERNEL); + cpu_mask = palacios_alloc((num_cpus / 8) + 1); if (!cpu_mask) { ERROR("Cannot allocate cpu mask\n"); @@ -666,7 +700,7 @@ int palacios_vmm_init( void ) if (init_print_buffers()) { ERROR("Cannot initialize print buffers\n"); - kfree(cpu_mask); + palacios_free(cpu_mask); return -1; }