From f3ac1a4b667eeffcedf779f45529c95d66ddc71a Mon Sep 17 00:00:00 2001 From: Xiao Guangrong Date: Tue, 16 Oct 2012 20:07:03 +0800 Subject: KVM: MMU: fix release noslot pfn We can not directly call kvm_release_pfn_clean to release the pfn since we can meet noslot pfn which is used to cache mmio info into spte Signed-off-by: Xiao Guangrong Cc: stable@vger.kernel.org Signed-off-by: Avi Kivity diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index d289fee..6f85fe0 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2497,8 +2497,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, } } - if (!is_error_pfn(pfn)) - kvm_release_pfn_clean(pfn); + kvm_release_pfn_clean(pfn); } static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c353b45..a65bc02 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1322,9 +1322,7 @@ EXPORT_SYMBOL_GPL(kvm_release_page_clean); void kvm_release_pfn_clean(pfn_t pfn) { - WARN_ON(is_error_pfn(pfn)); - - if (!kvm_is_mmio_pfn(pfn)) + if (!is_error_pfn(pfn) && !kvm_is_mmio_pfn(pfn)) put_page(pfn_to_page(pfn)); } EXPORT_SYMBOL_GPL(kvm_release_pfn_clean); -- cgit v0.10.2 From 7f46ddbd487e0d0528d89534fdfb31d885977804 Mon Sep 17 00:00:00 2001 From: Gleb Natapov Date: Sun, 14 Oct 2012 13:08:58 +0200 Subject: KVM: apic: fix LDR calculation in x2apic mode Signed-off-by: Gleb Natapov Reviewed-by: Chegu Vinod Tested-by: Chegu Vinod Signed-off-by: Avi Kivity diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index c6e6b72..43e9fad 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1311,7 +1311,7 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value) vcpu->arch.apic_base = value; if (apic_x2apic_mode(apic)) { u32 id = kvm_apic_id(apic); - u32 ldr = ((id & ~0xf) << 16) | (1 << (id & 0xf)); + u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf)); kvm_apic_set_ldr(apic, ldr); } apic->base_address = apic->vcpu->arch.apic_base & -- cgit v0.10.2 From c5e015d4949aa665c486cae6884beb00b97e3dea Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Fri, 19 Oct 2012 12:11:55 -0400 Subject: KVM guest: exit idleness when handling KVM_PV_REASON_PAGE_NOT_PRESENT KVM_PV_REASON_PAGE_NOT_PRESENT kicks cpu out of idleness, but we haven't marked that spot as an exit from idleness. Not doing so can cause RCU warnings such as: [ 732.788386] =============================== [ 732.789803] [ INFO: suspicious RCU usage. ] [ 732.790032] 3.7.0-rc1-next-20121019-sasha-00002-g6d8d02d-dirty #63 Tainted: G W [ 732.790032] ------------------------------- [ 732.790032] include/linux/rcupdate.h:738 rcu_read_lock() used illegally while idle! [ 732.790032] [ 732.790032] other info that might help us debug this: [ 732.790032] [ 732.790032] [ 732.790032] RCU used illegally from idle CPU! [ 732.790032] rcu_scheduler_active = 1, debug_locks = 1 [ 732.790032] RCU used illegally from extended quiescent state! [ 732.790032] 2 locks held by trinity-child31/8252: [ 732.790032] #0: (&rq->lock){-.-.-.}, at: [] __schedule+0x178/0x8f0 [ 732.790032] #1: (rcu_read_lock){.+.+..}, at: [] cpuacct_charge+0xe/0x200 [ 732.790032] [ 732.790032] stack backtrace: [ 732.790032] Pid: 8252, comm: trinity-child31 Tainted: G W 3.7.0-rc1-next-20121019-sasha-00002-g6d8d02d-dirty #63 [ 732.790032] Call Trace: [ 732.790032] [] lockdep_rcu_suspicious+0x10b/0x120 [ 732.790032] [] cpuacct_charge+0x90/0x200 [ 732.790032] [] ? cpuacct_charge+0xe/0x200 [ 732.790032] [] update_curr+0x1a3/0x270 [ 732.790032] [] dequeue_entity+0x2a/0x210 [ 732.790032] [] dequeue_task_fair+0x45/0x130 [ 732.790032] [] dequeue_task+0x89/0xa0 [ 732.790032] [] deactivate_task+0x1e/0x20 [ 732.790032] [] __schedule+0x879/0x8f0 [ 732.790032] [] ? trace_hardirqs_off+0xd/0x10 [ 732.790032] [] ? kvm_async_pf_task_wait+0x1d5/0x2b0 [ 732.790032] [] schedule+0x55/0x60 [ 732.790032] [] kvm_async_pf_task_wait+0x1f4/0x2b0 [ 732.790032] [] ? abort_exclusive_wait+0xb0/0xb0 [ 732.790032] [] ? prepare_to_wait+0x25/0x90 [ 732.790032] [] do_async_page_fault+0x56/0xa0 [ 732.790032] [] async_page_fault+0x28/0x30 Signed-off-by: Sasha Levin Acked-by: Gleb Natapov Acked-by: Paul E. McKenney Signed-off-by: Avi Kivity diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index b3e5e51..4180a87 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c @@ -247,7 +247,10 @@ do_async_page_fault(struct pt_regs *regs, unsigned long error_code) break; case KVM_PV_REASON_PAGE_NOT_PRESENT: /* page is swapped out by the host. */ + rcu_irq_enter(); + exit_idle(); kvm_async_pf_task_wait((u32)read_cr2()); + rcu_irq_exit(); break; case KVM_PV_REASON_PAGE_READY: rcu_irq_enter(); -- cgit v0.10.2