linux/arch/x86/kvm
Linus Torvalds f94edacf99 i387: move TS_USEDFPU flag from thread_info to task_struct
This moves the bit that indicates whether a thread has ownership of the
FPU from the TS_USEDFPU bit in thread_info->status to a word of its own
(called 'has_fpu') in task_struct->thread.has_fpu.

This fixes two independent bugs at the same time:

 - changing 'thread_info->status' from the scheduler causes nasty
   problems for the other users of that variable, since it is defined to
   be thread-synchronous (that's what the "TS_" part of the naming was
   supposed to indicate).

   So perfectly valid code could (and did) do

	ti->status |= TS_RESTORE_SIGMASK;

   and the compiler was free to do that as separate load, or and store
   instructions.  Which can cause problems with preemption, since a task
   switch could happen in between, and change the TS_USEDFPU bit. The
   change to TS_USEDFPU would be overwritten by the final store.

   In practice, this seldom happened, though, because the 'status' field
   was seldom used more than once, so gcc would generally tend to
   generate code that used a read-modify-write instruction and thus
   happened to avoid this problem - RMW instructions are naturally low
   fat and preemption-safe.

 - On x86-32, the current_thread_info() pointer would, during interrupts
   and softirqs, point to a *copy* of the real thread_info, because
   x86-32 uses %esp to calculate the thread_info address, and thus the
   separate irq (and softirq) stacks would cause these kinds of odd
   thread_info copy aliases.

   This is normally not a problem, since interrupts aren't supposed to
   look at thread information anyway (what thread is running at
   interrupt time really isn't very well-defined), but it confused the
   heck out of irq_fpu_usable() and the code that tried to squirrel
   away the FPU state.

   (It also caused untold confusion for us poor kernel developers).

It also turns out that using 'task_struct' is actually much more natural
for most of the call sites that care about the FPU state, since they
tend to work with the task struct for other reasons anyway (ie
scheduling).  And the FPU data that we are going to save/restore is
found there too.

Thanks to Arjan Van De Ven <arjan@linux.intel.com> for pointing us to
the %esp issue.

Cc: Arjan van de Ven <arjan@linux.intel.com>
Reported-and-tested-by: Raphael Prevost <raphael@buro.asia>
Acked-and-tested-by: Suresh Siddha <suresh.b.siddha@intel.com>
Tested-by: Peter Anvin <hpa@zytor.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2012-02-18 10:19:41 -08:00
..
Kconfig KVM: Expose a version 2 architectural PMU to a guests 2011-12-27 11:24:29 +02:00
Makefile KVM: Expose a version 2 architectural PMU to a guests 2011-12-27 11:24:29 +02:00
cpuid.c KVM: Expose the architectural performance monitoring CPUID leaf 2011-12-27 11:24:40 +02:00
cpuid.h KVM: Move cpuid code to new file 2011-12-27 11:21:49 +02:00
emulate.c KVM: x86: fix missing checks in syscall emulation 2012-02-01 11:43:40 +02:00
i8254.c KVM: x86: Consolidate PIT legacy test 2011-12-27 11:22:30 +02:00
i8254.h KVM: remove useless function declaration kvm_inject_pit_timer_irqs() 2011-05-11 07:57:09 -04:00
i8259.c KVM: drop bsp_vcpu pointer from kvm struct 2011-12-27 11:22:32 +02:00
irq.c KVM: fix typo in copyright notice 2010-10-24 10:53:14 +02:00
irq.h KVM: Intelligent device lookup on I/O bus 2011-09-25 19:17:59 +03:00
kvm_cache_regs.h KVM: MMU: Do not unconditionally read PDPTE from guest memory 2011-09-25 19:18:01 +03:00
kvm_timer.h KVM: emulate lapic tsc deadline timer for guest 2011-10-05 15:34:56 +02:00
lapic.c KVM: Expose kvm_lapic_local_deliver() 2011-12-27 11:23:39 +02:00
lapic.h KVM: Expose kvm_lapic_local_deliver() 2011-12-27 11:23:39 +02:00
mmu.c module_param: make bool parameters really bool (arch) 2012-01-13 09:32:18 +10:30
mmu.h KVM: MMU: mmio page fault support 2011-07-24 11:50:40 +03:00
mmu_audit.c KVM: MMU: audit: inline audit function 2011-12-27 11:22:12 +02:00
mmutrace.h KVM: MMU: audit: replace mmu audit tracepoint with jump-label 2011-12-27 11:22:05 +02:00
paging_tmpl.h KVM: MMU: audit: replace mmu audit tracepoint with jump-label 2011-12-27 11:22:05 +02:00
pmu.c KVM: Expose a version 2 architectural PMU to a guests 2011-12-27 11:24:29 +02:00
svm.c KVM: SVM: Intercept RDPMC 2011-12-27 11:24:37 +02:00
timer.c KVM: x86: Simplify kvm timer handler 2011-12-27 11:17:05 +02:00
trace.h KVM: Use __print_symbolic() for vmexit tracepoints 2011-09-25 19:17:59 +03:00
tss.h KVM: x86: hardware task switching support 2008-04-27 12:00:39 +03:00
vmx.c i387: move TS_USEDFPU flag from thread_info to task_struct 2012-02-18 10:19:41 -08:00
x86.c KVM: do not #GP on perf MSR writes when vPMU is disabled 2012-02-01 11:44:46 +02:00
x86.h KVM: Move cpuid code to new file 2011-12-27 11:21:49 +02:00