From patchwork Mon Aug 10 17:11:57 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Ershov X-Patchwork-Id: 40447 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 n7AHC7Pr000449 for ; Mon, 10 Aug 2009 17:12:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932324AbZHJRMB (ORCPT ); Mon, 10 Aug 2009 13:12:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932288AbZHJRMB (ORCPT ); Mon, 10 Aug 2009 13:12:01 -0400 Received: from mail-bw0-f219.google.com ([209.85.218.219]:40962 "EHLO mail-bw0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932084AbZHJRMB (ORCPT ); Mon, 10 Aug 2009 13:12:01 -0400 Received: by bwz19 with SMTP id 19so2702262bwz.37 for ; Mon, 10 Aug 2009 10:12:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=vSn9sdGN5u9rNDMYc5cR9f9gsV34Y0Ftb7fV3XTtfko=; b=t/8y4tluace4lXEKOWr9N0yIjuDML1dbuhyEQx5MpuIrDandbEKmdWSiKKz+yeukfE ZPz4RTHvwPGsrcfldUJObvDsZZIq36zcmDY8WPDdXzBWkTIkeiO2R+fShM0P+XYgm1TT HmKACqKM74P09Lh5tnd/bf3CWB+lrToScZyMg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=OA1eu1Q6vRd04wSkDTZ+LFCn7ODakb5Y4gp8OOw0nKaayRtI9c5JEYMt+4NdBmsONY x2O2zcCMN/JFo0NHO/GG6J/z2FxE3YixE3n4nKtR0CWfRCbvVepG7h6VsU9GMkkYpCFn ctHMl56PUzqgo0pmZQhX1Yt4hGD4FnPX9H5Hk= MIME-Version: 1.0 Received: by 10.239.179.200 with SMTP id e8mr492952hbg.122.1249924317222; Mon, 10 Aug 2009 10:11:57 -0700 (PDT) Date: Mon, 10 Aug 2009 21:11:57 +0400 Message-ID: <6f9242d20908101011t2df862e7l8f35615c7dbb90ea@mail.gmail.com> Subject: [PATCH] x86: use kvm_read/write_guest_virt for reading and writing segment descriptors From: Mikhail Ershov To: kvm@vger.kernel.org Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Descriptor table can be placed on two non-contiguous pages. It is better to read descriptor by linear address. Signed-off-by: Mikhail Ershov --- arch/x86/kvm/x86.c | 10 ++-------- 1 files changed, 2 insertions(+), 8 deletions(-) @@ -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, diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 850cf56..13f39bb 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;