public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* KVM: MMU: fix rmap_remove on non present sptes
@ 2010-10-25 13:58 Marcelo Tosatti
  2010-10-27  9:16 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2010-10-25 13:58 UTC (permalink / raw)
  To: kvm; +Cc: Lucas Meneghel Rodrigues


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 <mtosatti@redhat.com>
Reported-by: Lucas Meneghel Rodrigues <lmr@redhat.com>

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 7ab734d..5c77e760 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -722,7 +722,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;
@@ -733,19 +733,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 (!shadow_dirty_mask || (old_spte & shadow_dirty_mask))
 		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)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: KVM: MMU: fix rmap_remove on non present sptes
  2010-10-25 13:58 KVM: MMU: fix rmap_remove on non present sptes Marcelo Tosatti
@ 2010-10-27  9:16 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2010-10-27  9:16 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm, Lucas Meneghel Rodrigues

  On 10/25/2010 03:58 PM, Marcelo Tosatti wrote:
> drop_spte should not attempt to rmap_remove a non present shadow pte.
>
> This fixes a BUG_ON seen on kvm-autotest.

Applied, thanks.

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-10-27  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-25 13:58 KVM: MMU: fix rmap_remove on non present sptes Marcelo Tosatti
2010-10-27  9:16 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox