From patchwork Wed Aug 19 10:42:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikhail Ershov X-Patchwork-Id: 42569 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7JAgEHR006667 for ; Wed, 19 Aug 2009 10:42:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751542AbZHSKmK (ORCPT ); Wed, 19 Aug 2009 06:42:10 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751474AbZHSKmJ (ORCPT ); Wed, 19 Aug 2009 06:42:09 -0400 Received: from mail-bw0-f219.google.com ([209.85.218.219]:38671 "EHLO mail-bw0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbZHSKmI (ORCPT ); Wed, 19 Aug 2009 06:42:08 -0400 Received: by bwz19 with SMTP id 19so4674608bwz.37 for ; Wed, 19 Aug 2009 03:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=dKvYCM7lltUHdW8nu23o29KYe0eF9KQqpe21AlshM1k=; b=ilGH0A0+N0jdVe1JRC2akVh359KzdUVZf0OFTndRSehkHLsnG5UWgb59PazC0ysRCG IJ95BDqWTV7xy98mMXCrQ+R23xFAu0CaqYHhkhdZ7XhwoOleVJLTaC1Vphqf5BTr6i6d s7hPKIFmMuYECQ0bipo3ltVZKDobFP3FcoENQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=MyZy1dScmjImrRsqKrLy9TjHm2jouUJetdLw/I5bXzXQQXCI9jwntiCbwHEZK5zvkF 6MTamicPF0+2/spkF3asZr9aKY13YrmLFdOJQDolHmSkl3u/O/oKgFRcuObe+xGyQp2b 71wtRLnu0wJVTbvVyCrqr0WQDxtKGat02UP+I= MIME-Version: 1.0 Received: by 10.210.76.4 with SMTP id y4mr5282402eba.86.1250678528742; Wed, 19 Aug 2009 03:42:08 -0700 (PDT) In-Reply-To: <4A87F5E6.6010807@redhat.com> References: <6f9242d20908101011t2df862e7l8f35615c7dbb90ea@mail.gmail.com> <4A87F5E6.6010807@redhat.com> Date: Wed, 19 Aug 2009 14:42:08 +0400 Message-ID: <6f9242d20908190342h7145343ey68fc0e7a9cc5d0cc@mail.gmail.com> Subject: Re: [PATCH] x86: use kvm_read/write_guest_virt for reading and writing segment descriptors From: Mikhail Ershov To: Avi Kivity Cc: kvm@vger.kernel.org Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org The patch is in attachment. 2009/8/16 Avi Kivity : > On 08/10/2009 08:11 PM, Mikhail Ershov wrote: >> >> Descriptor table can be placed on two non-contiguous pages. >> It is better to read descriptor by linear address. >> > > Patch is good, but is whitespace-corrupted.  Please send as an attachment > (or using git-send-email). > > Make sure the attachment is plain/text so mail clients can display it > inline. > > -- > error compiling committee.c: too many arguments to function > > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 52d5d72..aa2dd12 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4017,7 +4017,6 @@ static void get_segment_descriptor_dtable(struct kvm_vcpu *vcpu, static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, struct desc_struct *seg_desc) { - gpa_t gpa; struct descriptor_table dtable; u16 index = selector >> 3; @@ -4027,16 +4026,13 @@ static int load_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, kvm_queue_exception_e(vcpu, GP_VECTOR, selector & 0xfffc); return 1; } - gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base); - gpa += index * 8; - return kvm_read_guest(vcpu->kvm, gpa, seg_desc, 8); + return kvm_read_guest_virt(dtable.base + index*8, seg_desc, sizeof(*seg_desc), vcpu); } /* allowed just for 8 bytes segments */ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, struct desc_struct *seg_desc) { - gpa_t gpa; struct descriptor_table dtable; u16 index = selector >> 3; @@ -4044,9 +4040,7 @@ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, if (dtable.limit < index * 8 + 7) return 1; - gpa = vcpu->arch.mmu.gva_to_gpa(vcpu, dtable.base); - gpa += index * 8; - return kvm_write_guest(vcpu->kvm, gpa, seg_desc, 8); + return kvm_write_guest_virt(dtable.base + index*8, seg_desc, sizeof(*seg_desc), vcpu); } static u32 get_tss_base_addr(struct kvm_vcpu *vcpu,