Skip to content

Commit 9c6ff8b

Browse files
Suresh SiddhaH. Peter Anvin
authored andcommitted
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: Suresh 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: H. Peter Anvin <hpa@linux.intel.com>
1 parent 841e360 commit 9c6ff8b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/lguest/x86/core.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ void lguest_arch_run_guest(struct lg_cpu *cpu)
203203
* we set it now, so we can trap and pass that trap to the Guest if it
204204
* uses the FPU.
205205
*/
206-
if (cpu->ts)
207-
unlazy_fpu(current);
206+
if (cpu->ts && user_has_fpu())
207+
stts();
208208

209209
/*
210210
* 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)
234234
if (boot_cpu_has(X86_FEATURE_SEP))
235235
wrmsr(MSR_IA32_SYSENTER_CS, __KERNEL_CS, 0);
236236

237+
/* Clear the host TS bit if it was set above. */
238+
if (cpu->ts && user_has_fpu())
239+
clts();
240+
237241
/*
238242
* If the Guest page faulted, then the cr2 register will tell us the
239243
* 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)
249253
* a different CPU. So all the critical stuff should be done
250254
* before this.
251255
*/
252-
else if (cpu->regs->trapnum == 7)
256+
else if (cpu->regs->trapnum == 7 && !user_has_fpu())
253257
math_state_restore();
254258
}
255259

0 commit comments

Comments
 (0)