linux-kernel-test/arch/x86/kvm
Matt T. Yourst 2dea4c84bc KVM: x86: silence preempt warning on kvm_write_guest_time
This issue just appeared in kvm-84 when running on 2.6.28.7 (x86-64)
with PREEMPT enabled.

We're getting syslog warnings like this many (but not all) times qemu
tells KVM to run the VCPU:

BUG: using smp_processor_id() in preemptible [00000000] code:
qemu-system-x86/28938
caller is kvm_arch_vcpu_ioctl_run+0x5d1/0xc70 [kvm]
Pid: 28938, comm: qemu-system-x86 2.6.28.7-mtyrel-64bit
Call Trace:
debug_smp_processor_id+0xf7/0x100
kvm_arch_vcpu_ioctl_run+0x5d1/0xc70 [kvm]
? __wake_up+0x4e/0x70
? wake_futex+0x27/0x40
kvm_vcpu_ioctl+0x2e9/0x5a0 [kvm]
enqueue_hrtimer+0x8a/0x110
_spin_unlock_irqrestore+0x27/0x50
vfs_ioctl+0x31/0xa0
do_vfs_ioctl+0x74/0x480
sys_futex+0xb4/0x140
sys_ioctl+0x99/0xa0
system_call_fastpath+0x16/0x1b

As it turns out, the call trace is messed up due to gcc's inlining, but
I isolated the problem anyway: kvm_write_guest_time() is being used in a
non-thread-safe manner on preemptable kernels.

Basically kvm_write_guest_time()'s body needs to be surrounded by
preempt_disable() and preempt_enable(), since the kernel won't let us
query any per-CPU data (indirectly using smp_processor_id()) without
preemption disabled. The attached patch fixes this issue by disabling
preemption inside kvm_write_guest_time().

[marcelo: surround only __get_cpu_var calls since the warning
is harmless]

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2009-06-10 11:48:24 +03:00
..
i8254.c KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked 2009-03-24 11:03:03 +02:00
i8254.h KVM: Reset PIT irq injection logic when the PIT IRQ is unmasked 2009-03-24 11:03:03 +02:00
i8259.c KVM: fix sparse warnings: context imbalance 2009-03-24 11:03:13 +02:00
irq.c KVM: x86: fix LAPIC pending count calculation 2009-02-15 02:47:38 +02:00
irq.h KVM: make irq ack notifications aware of routing table 2009-03-24 11:03:08 +02:00
Kconfig Merge branch 'tracing/core-v2' into tracing-for-linus 2009-04-02 00:49:02 +02:00
kvm_cache_regs.h KVM: x86: accessors for guest registers 2008-10-15 10:13:57 +02:00
kvm_svm.h KVM: x86: Virtualize debug registers 2009-03-24 11:02:49 +02:00
lapic.c KVM: bit ops for deliver_bitmap 2009-06-10 11:48:22 +03:00
lapic.h KVM: x86: fix LAPIC pending count calculation 2009-02-15 02:47:38 +02:00
Makefile KVM: change KVM to use IOMMU API 2009-01-03 14:11:07 +01:00
mmu.c KVM: Make paravirt tlb flush also reload the PAE PDPTRs 2009-05-25 20:00:50 +03:00
mmu.h KVM: is_long_mode() should check for EFER.LMA 2009-03-24 11:03:13 +02:00
paging_tmpl.h KVM: Fix missing smp tlb flush in invlpg 2009-03-24 11:03:14 +02:00
svm.c KVM: SVM: Remove port 80 passthrough 2009-05-11 14:40:51 +03:00
tss.h KVM: x86: hardware task switching support 2008-04-27 12:00:39 +03:00
vmx.c KVM: VMX: Don't intercept MSR_KERNEL_GS_BASE 2009-06-10 11:48:21 +03:00
x86_emulate.c KVM: x86 emulator: implement 'ret far' instruction (opcode 0xcb) 2009-03-24 11:03:01 +02:00
x86.c KVM: x86: silence preempt warning on kvm_write_guest_time 2009-06-10 11:48:24 +03:00
x86.h KVM: Add a pending interrupt queue 2008-10-15 10:15:13 +02:00