From: Marcelo Tosatti Subject: Re: kernel BUG at arch/x86/kvm/mmu.c:655! Date: Tue, 18 Jan 2011 12:42:27 -0200 Message-ID: <20110118144227.GB24679@amt.cnet> References: <4D277B0D.8070505@wpkg.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="H1spWtNR+x+ondvy" Cc: "kvm@vger.kernel.org" To: Tomasz Chmielewski Return-path: Received: from mx1.redhat.com ([209.132.183.28]:60220 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752437Ab1AROwj (ORCPT ); Tue, 18 Jan 2011 09:52:39 -0500 Content-Disposition: inline In-Reply-To: <4D277B0D.8070505@wpkg.org> Sender: kvm-owner@vger.kernel.org List-ID: --H1spWtNR+x+ondvy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Patch against 2.6.36 attached. --H1spWtNR+x+ondvy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="kvm-fix-drop-spte-2.patch" commit 9621afb2eb9a1f06d4afcf435175b5323a2b5cc6 Author: Marcelo Tosatti Date: Mon Oct 25 11:58:22 2010 -0200 KVM: MMU: fix rmap_remove on non present sptes commit eb45fda45f915c7ca3e81e005e853cb770da2642 upstream. drop_spte should not attempt to rmap_remove a non present shadow pte. This fixes a BUG_ON seen on kvm-autotest. Signed-off-by: Marcelo Tosatti Reported-by: Lucas Meneghel Rodrigues Signed-off-by: Avi Kivity diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 7fed5b7..cc1bada 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -675,7 +675,7 @@ static void rmap_remove(struct kvm *kvm, u64 *spte) } } -static void set_spte_track_bits(u64 *sptep, u64 new_spte) +static int set_spte_track_bits(u64 *sptep, u64 new_spte) { pfn_t pfn; u64 old_spte = *sptep; @@ -687,18 +687,20 @@ static void set_spte_track_bits(u64 *sptep, u64 new_spte) old_spte = __xchg_spte(sptep, new_spte); if (!is_rmap_spte(old_spte)) - return; + return 0; + pfn = spte_to_pfn(old_spte); if (!shadow_accessed_mask || old_spte & shadow_accessed_mask) kvm_set_pfn_accessed(pfn); if (is_writable_pte(old_spte)) kvm_set_pfn_dirty(pfn); + return 1; } static void drop_spte(struct kvm *kvm, u64 *sptep, u64 new_spte) { - set_spte_track_bits(sptep, new_spte); - rmap_remove(kvm, sptep); + if (set_spte_track_bits(sptep, new_spte)) + rmap_remove(kvm, sptep); } static u64 *rmap_next(struct kvm *kvm, unsigned long *rmapp, u64 *spte) --H1spWtNR+x+ondvy--