Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759872Ab3JOWVs (ORCPT ); Tue, 15 Oct 2013 18:21:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:13499 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759622Ab3JOWVq (ORCPT ); Tue, 15 Oct 2013 18:21:46 -0400 Date: Tue, 15 Oct 2013 19:21:19 -0300 From: Marcelo Tosatti To: Gleb Natapov Cc: Xiao Guangrong , Xiao Guangrong , avi.kivity@gmail.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v2 12/15] KVM: MMU: allow locklessly access shadow page table out of vcpu thread Message-ID: <20131015222119.GA3125@amt.cnet> References: <20131010014710.GA2198@amt.cnet> <20131010120845.GT3574@redhat.com> <20131010164222.GB3211@amt.cnet> <20131010191646.GE15954@redhat.com> <20131010210301.GA7275@amt.cnet> <20131011053831.GG15954@redhat.com> <20131011203017.GA29576@amt.cnet> <20131012055356.GC14789@redhat.com> <20131014192945.GA22655@amt.cnet> <20131015035705.GB30802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131015035705.GB30802@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1537 Lines: 37 On Tue, Oct 15, 2013 at 06:57:05AM +0300, Gleb Natapov wrote: > > > > Why is it safe to allow access, by the lockless page write protect > > side, to spt pointer for shadow page A that can change to a shadow page > > pointer of shadow page B? > > > > Write protect spte of any page at will? Or verify that in fact thats the > > shadow you want to write protect? > > > > Note that spte value might be the same for different shadow pages, > > so cmpxchg succeeding does not guarantees its the same shadow page that > > has been protected. > > > Two things can happen: spte that we accidentally write protect is some > other last level spte - this is benign, it will be unprotected on next > fault. Nothing forbids two identical writable sptes to point to a same pfn. How do you know you are write protecting the correct one? (the proper gfn). Lockless walk sounds interesting. By the time you get to the lower level, that might be a different spte. All of this to avoid throttling, is it worthwhile? > If spte is not last level this is a problem and Xiao propose to > fix it by encoding spte level into spte itself. Another way to fix it is > to handle fault that is caused by write protected middle sptes in KVM - > just unprotected them and go back to a guest. > > -- > Gleb. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/