Merge branch 'linus' into tracing/hw-breakpoints
Ingo Molnar [Tue, 15 Sep 2009 10:18:15 +0000 (12:18 +0200)]
Conflicts:
arch/x86/kernel/process_64.c

Semantic conflict fixed in:
arch/x86/kvm/x86.c

Signed-off-by: Ingo Molnar <mingo@elte.hu>

1  2 
arch/Kconfig
arch/x86/Kconfig
arch/x86/include/asm/processor.h
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c
arch/x86/kernel/signal.c
arch/x86/kernel/smpboot.c
arch/x86/kernel/traps.c
arch/x86/kvm/x86.c
kernel/Makefile

diff --cc arch/Kconfig
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -493,33 -489,12 +502,30 @@@ __switch_to(struct task_struct *prev_p
                     task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
                __switch_to_xtra(prev_p, next_p, tss);
  
-       /* If the task has used fpu the last 5 timeslices, just do a full
-        * restore of the math state immediately to avoid the trap; the
-        * chances of needing FPU soon are obviously high now
-        *
-        * tsk_used_math() checks prevent calling math_state_restore(),
-        * which can sleep in the case of !tsk_used_math()
+       /*
+        * Preload the FPU context, now that we've determined that the
+        * task is likely to be using it. 
         */
-       if (tsk_used_math(next_p) && next_p->fpu_counter > 5)
-               math_state_restore();
+       if (preload_fpu)
+               __math_state_restore();
 +      /*
 +       * There's a problem with moving the arch_install_thread_hw_breakpoint()
 +       * call before current is updated.  Suppose a kernel breakpoint is
 +       * triggered in between the two, the hw-breakpoint handler will see that
 +       * the 'current' task does not have TIF_DEBUG flag set and will think it
 +       * is leftover from an old task (lazy switching) and will erase it. Then
 +       * until the next context switch, no user-breakpoints will be installed.
 +       *
 +       * The real problem is that it's impossible to update both current and
 +       * physical debug registers at the same instant, so there will always be
 +       * a window in which they disagree and a breakpoint might get triggered.
 +       * Since we use lazy switching, we are forced to assume that a
 +       * disagreement means that current is correct and the exception is due
 +       * to lazy debug register switching.
 +       */
 +      if (unlikely(test_tsk_thread_flag(next_p, TIF_DEBUG)))
 +              arch_install_thread_hw_breakpoint(next_p);
 +
        return prev_p;
  }
  
Simple merge
Simple merge
Simple merge
@@@ -3312,18 -3638,17 +3638,17 @@@ static int vcpu_enter_guest(struct kvm_
                set_debugreg(vcpu->arch.eff_db[3], 3);
        }
  
-       KVMTRACE_0D(VMENTRY, vcpu, entryexit);
+       trace_kvm_entry(vcpu->vcpu_id);
        kvm_x86_ops->run(vcpu, kvm_run);
  
-       if (unlikely(vcpu->arch.switch_db_regs)) {
-               set_debugreg(0, 7);
-               set_debugreg(vcpu->arch.host_db[0], 0);
-               set_debugreg(vcpu->arch.host_db[1], 1);
-               set_debugreg(vcpu->arch.host_db[2], 2);
-               set_debugreg(vcpu->arch.host_db[3], 3);
+       if (unlikely(vcpu->arch.switch_db_regs || test_thread_flag(TIF_DEBUG))) {
 -              set_debugreg(current->thread.debugreg0, 0);
 -              set_debugreg(current->thread.debugreg1, 1);
 -              set_debugreg(current->thread.debugreg2, 2);
 -              set_debugreg(current->thread.debugreg3, 3);
++              set_debugreg(current->thread.debugreg[0], 0);
++              set_debugreg(current->thread.debugreg[1], 1);
++              set_debugreg(current->thread.debugreg[2], 2);
++              set_debugreg(current->thread.debugreg[3], 3);
+               set_debugreg(current->thread.debugreg6, 6);
+               set_debugreg(current->thread.debugreg7, 7);
        }
-       set_debugreg(vcpu->arch.host_dr6, 6);
-       set_debugreg(vcpu->arch.host_dr7, 7);
  
        set_bit(KVM_REQ_KICK, &vcpu->requests);
        local_irq_enable();
diff --cc kernel/Makefile
Simple merge