From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM: MMU: bail out pagewalk on kvm_read_guest error Date: Sun, 17 Jan 2010 10:23:37 +0200 Message-ID: <4B52C909.2010909@redhat.com> References: <20100114194127.GA3968@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2373 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752133Ab0AQIXj (ORCPT ); Sun, 17 Jan 2010 03:23:39 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0H8Nd9A019064 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 17 Jan 2010 03:23:39 -0500 In-Reply-To: <20100114194127.GA3968@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On 01/14/2010 09:41 PM, Marcelo Tosatti wrote: > Exit the guest pagetable walk loop if reading gpte failed. Otherwise its > possible to enter an endless loop processing the previous present pte. > > Cc: stable@kernel.org > Signed-off-by: Marcelo Tosatti > > diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h > index 58a0f1e..ede2131 100644 > --- a/arch/x86/kvm/paging_tmpl.h > +++ b/arch/x86/kvm/paging_tmpl.h > @@ -150,7 +150,9 @@ walk: > walker->table_gfn[walker->level - 1] = table_gfn; > walker->pte_gpa[walker->level - 1] = pte_gpa; > > - kvm_read_guest(vcpu->kvm, pte_gpa,&pte, sizeof(pte)); > + if (kvm_read_guest(vcpu->kvm, pte_gpa,&pte, sizeof(pte))) > + goto not_present; > + > On real hardware, if you place a pte at non-existing memory, you aren't guaranteed to get the present bit clear, so why is this necessary? We should be able to survive any garbage the pte previously contained. -- error compiling committee.c: too many arguments to function