From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [patch 3/3] KVM: task switch: check for segment base translation failure Date: Sun, 20 Jul 2008 12:24:35 +0300 Message-ID: <48830453.5010000@qumranet.com> References: <20080719220806.152409866@localhost.localdomain> <20080719220933.000583030@localhost.localdomain> 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 il.qumranet.com ([212.179.150.194]:31764 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754230AbYGTJYg (ORCPT ); Sun, 20 Jul 2008 05:24:36 -0400 In-Reply-To: <20080719220933.000583030@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: Marcelo Tosatti wrote: > Subject says it all. > > Signed-off-by: Marcelo Tosatti > > Index: kvm-vmx-checks/arch/x86/kvm/x86.c > =================================================================== > --- kvm-vmx-checks.orig/arch/x86/kvm/x86.c > +++ kvm-vmx-checks/arch/x86/kvm/x86.c > @@ -3253,6 +3253,8 @@ static int load_guest_segment_descriptor > return 1; > } > gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base); > + if (gpa == UNMAPPED_GVA) > + return 1; > gpa += index * 8; > return kvm_read_guest(vcpu->kvm, gpa, seg_desc, 8); > } > This is wrong; if the descriptor table is long enough, the first page could be unmapped but the page(s) containing the segment could be mapped (and nothing guarantees the mapping is contiguous). We need to translate dtable.base + index * 8. What we really need is kvm_read_guest_virt() to take care of all of these things. The emulator callbacks come fairly close. -- error compiling committee.c: too many arguments to function