Commit 9c6ff8bb authored by Suresh Siddha's avatar Suresh Siddha Committed by H. Peter Anvin

lguest, x86: handle guest TS bit for lazy/non-lazy fpu host models

Instead of using unlazy_fpu() check if user_has_fpu() and set/clear
the host TS bits so that the lguest works fine with both the
lazy/non-lazy FPU host models with minimal changes.
Signed-off-by: default avatarSuresh Siddha <suresh.b.siddha@intel.com>
Link: http://lkml.kernel.org/r/1345842782-24175-6-git-send-email-suresh.b.siddha@intel.com
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
parent 841e3604
...@@ -203,8 +203,8 @@ void lguest_arch_run_guest(struct lg_cpu *cpu) ...@@ -203,8 +203,8 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
* we set it now, so we can trap and pass that trap to the Guest if it * we set it now, so we can trap and pass that trap to the Guest if it
* uses the FPU. * uses the FPU.
*/ */
if (cpu->ts) if (cpu->ts && user_has_fpu())
unlazy_fpu(current); stts();
/* /*
* SYSENTER is an optimized way of doing system calls. We can't allow * SYSENTER is an optimized way of doing system calls. We can't allow
...@@ -234,6 +234,10 @@ void lguest_arch_run_guest(struct lg_cpu *cpu) ...@@ -234,6 +234,10 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
if (boot_cpu_has(X86_FEATURE_SEP)) if (boot_cpu_has(X86_FEATURE_SEP))
wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0); wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0);
/* Clear the host TS bit if it was set above. */
if (cpu->ts && user_has_fpu())
clts();
/* /*
* If the Guest page faulted, then the cr2 register will tell us the * If the Guest page faulted, then the cr2 register will tell us the
* bad virtual address. We have to grab this now, because once we * bad virtual address. We have to grab this now, because once we
...@@ -249,7 +253,7 @@ void lguest_arch_run_guest(struct lg_cpu *cpu) ...@@ -249,7 +253,7 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
* a different CPU. So all the critical stuff should be done * a different CPU. So all the critical stuff should be done
* before this. * before this.
*/ */
else if (cpu->regs->trapnum == 7) else if (cpu->regs->trapnum == 7 && !user_has_fpu())
math_state_restore(); math_state_restore();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment