From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 1/5] KVM: MMU: Push clean gpte write protection out of gpte_access() Date: Thu, 13 Sep 2012 19:29:31 +0800 Message-ID: <5051C39B.7020105@linux.vnet.ibm.com> References: <1347460194-11807-1-git-send-email-avi@redhat.com> <1347460194-11807-2-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from e23smtp07.au.ibm.com ([202.81.31.140]:51471 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757551Ab2IMLf6 (ORCPT ); Thu, 13 Sep 2012 07:35:58 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Sep 2012 21:28:07 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q8DBTXnS12976170 for ; Thu, 13 Sep 2012 21:29:34 +1000 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q8DBTXJv023253 for ; Thu, 13 Sep 2012 21:29:33 +1000 In-Reply-To: <1347460194-11807-2-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 09/12/2012 10:29 PM, Avi Kivity wrote: > gpte_access() computes the access permissions of a guest pte and also > write-protects clean gptes. This is wrong when we are servicing a > write fault (since we'll be setting the dirty bit momentarily) but > correct when instantiating a speculative spte, or when servicing a > read fault (since we'll want to trap a following write in order to > set the dirty bit). > > It doesn't seem to hurt in practice, but in order to make the code In current code, it seems that we will get two #PF if guest write memory through clean pte: one mark the dirty bit, then fault again, set W bit. > readable, push the write protection out of gpte_access() and into > a new protect_clean_gpte() which is called explicitly when needed. Reviewed-by: Xiao Guangrong