From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH v2] KVM: MMU: Don't use RCU for lockless shadow walking Date: Sun, 29 Apr 2012 12:38:55 +0300 Message-ID: <4F9D0C2F.9000209@redhat.com> References: <1335260845-16271-1-git-send-email-avi@redhat.com> <20120426220000.GA30343@amt.cnet> <4F9A37BD.8030700@linux.vnet.ibm.com> <20120427214946.GA5762@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Xiao Guangrong , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:52573 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753150Ab2D2JjA (ORCPT ); Sun, 29 Apr 2012 05:39:00 -0400 In-Reply-To: <20120427214946.GA5762@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 04/28/2012 12:49 AM, Marcelo Tosatti wrote: > > >> + smp_mb(); > > >> + vcpu->mode = OUTSIDE_GUEST_MODE; > > > > > > Don't you want > > > > > > vcpu->mode = OUTSIDE_GUEST_MODE; > > > smp_mb(); > > > > > > > > > It is unsafe i think, it is a problem if spte read / spte update is ordered > > to the behind of vcpu->mode = OUTSIDE_GUEST_MODE, like below: > > > > VCPU 0 VCPU 1 > > commit_zapped_page: > > /* > > * setting vcpu->mode is reordered > > * to the head of read spte. > > */ > > vcpu->mode = OUTSIDE_GUEST_MODE; > > > > see VCPU 0 is out-of-guest-mode, IPI is > > not sent, and the sp is free immediately. > > > > read spte; > > OOPS!!! Ouch! > > > > (It is invalid since spte is freed.) > > > > smp_mb > > Right. In that case a compiler barrier is sufficient (stores are not > reordered with earlier loads on x86). I think it's customary not to depend on arch specific memory barrier behaviour (but I don't have anything to base this on, just a feeling). -- error compiling committee.c: too many arguments to function