From: Maciek Swiech Date: Fri, 6 Dec 2013 19:14:40 +0000 (-0600) Subject: Fix for floating point save/restore in case where fp context switching is turned off X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=ade1ede94c894363a3d4652d93540aef170b1276;hp=6bc36dbea509d599d3c6fdb42e1a9c67144f5023;p=palacios.git Fix for floating point save/restore in case where fp context switching is turned off --- diff --git a/palacios/include/palacios/vmm_fp.h b/palacios/include/palacios/vmm_fp.h index 76b377d..0271458 100644 --- a/palacios/include/palacios/vmm_fp.h +++ b/palacios/include/palacios/vmm_fp.h @@ -163,8 +163,16 @@ int v3_deinit_fp(void); #ifndef V3_CONFIG_FP_SWITCH -#define V3_FP_EXIT_SAVE(core) -#define V3_FP_ENTRY_RESTORE(core) +/* Ideally these would use the TS trick to do lazy calls to used_fpu() */ +#define V3_FP_EXIT_SAVE(core) + +#define V3_FP_ENTRY_RESTORE(core) \ + do { \ + if ((core)->fp_state.need_restore) { \ + v3_put_fp_state(core); \ + (core)->fp_state.need_restore=0; \ + } \ + } while (0) #else diff --git a/palacios/src/palacios/vmm_barrier.c b/palacios/src/palacios/vmm_barrier.c index ba88e2b..a94e40f 100644 --- a/palacios/src/palacios/vmm_barrier.c +++ b/palacios/src/palacios/vmm_barrier.c @@ -198,9 +198,12 @@ int v3_wait_at_barrier(struct guest_info * core) { if (barrier->active == 0) { return 0; } - -#ifdef V3_CONFIG_LAZY_FP_SWITCH +#ifndef V3_CONFIG_FP_SWITCH + v3_get_fp_state(core); // snapshot FP state now +#else +# ifdef V3_CONFIG_LAZY_FP_SWITCH v3_get_fp_state(core); // snapshot FP state now regardless of lazy eval +# endif #endif V3_Print(core->vm_info, core, "Core %d waiting at barrier\n", core->vcpu_id); @@ -219,9 +222,13 @@ int v3_wait_at_barrier(struct guest_info * core) { // Barrier wait will spin if there is no competing work v3_yield(core,-1); } - -#ifdef V3_LAZY_FP_SWITCH + +#ifndef V3_CONFIG_FP_SWITCH + core->fp_state.need_restore=1; // restore FP on next entry +#else +# ifdef V3_CONFIG_LAZY_FP_SWITCH core->fp_state.need_restore=1; // restore FP on next entry +# endif #endif return 0;