From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/4] KVM: MMU: Introduce drop_spte() Date: Sun, 06 Jun 2010 17:33:12 +0300 Message-ID: <4C0BB1A8.2020406@redhat.com> References: <1275829583-7117-1-git-send-email-avi@redhat.com> <1275829583-7117-2-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55892 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756570Ab0FFOdP (ORCPT ); Sun, 6 Jun 2010 10:33:15 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o56EXEps029056 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 6 Jun 2010 10:33:15 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o56EXDJ3003832 for ; Sun, 6 Jun 2010 10:33:14 -0400 In-Reply-To: <1275829583-7117-2-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 06/06/2010 04:06 PM, Avi Kivity wrote: > When we call rmap_remove(), we (almost) always immediately follow it by > an __set_spte() to a nonpresent pte. Since we need to perform the two > operations atomically, to avoid losing the dirty and accessed bits, introduce > a helper drop_spte() and convert all call sites. > > The operation is still nonatomic at this point. > > > @@ -1498,13 +1502,14 @@ static void kvm_mmu_page_unlink_children(struct kvm *kvm, > ent&= PT64_BASE_ADDR_MASK; > mmu_page_remove_parent_pte(page_header(ent), > &pt[i]); > + pt[i] = shadow_trap_nonpresent_pte; > } else { > if (is_large_pte(ent)) > --kvm->stat.lpages; > - rmap_remove(kvm,&pt[i]); > + drop_spte(kvm,&pt[i], > + shadow_trap_nonpresent_pte); > } > } > - pt[i] = shadow_trap_nonpresent_pte; > } > } > Autotest points out that this transformation (and an identical one in zap_pte) does not preserve the semantics; if the outer if () fails, the new code does not update pt[i]. With the original line after the if () retained, autotest is happier. -- error compiling committee.c: too many arguments to function