From patchwork Sat Jul 18 14:58:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 36188 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 n6IFAah9024118 for ; Sat, 18 Jul 2009 15:10:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753109AbZGRPJX (ORCPT ); Sat, 18 Jul 2009 11:09:23 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752914AbZGRPJV (ORCPT ); Sat, 18 Jul 2009 11:09:21 -0400 Received: from wf-out-1314.google.com ([209.85.200.171]:34088 "EHLO wf-out-1314.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbZGRPJQ (ORCPT ); Sat, 18 Jul 2009 11:09:16 -0400 Received: by wf-out-1314.google.com with SMTP id 26so451932wfd.4 for ; Sat, 18 Jul 2009 08:09:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=agaLlHFgrRgtFcYf/i91TDHGLoSKJVxLGykfuq32uik=; b=HU/BEuSrJY27e8ocS/5shcO5DDM2IS4TIQ4vMUZbJA1T0IysORGU7hMbzHsJKvFRNr lygWlmMRISsmQjwrJrQ9ZVpQj83nJxgfwL86OazLgiik503ewL9JV1J6y7Gz9+2/5fKk MZ3QsTukskF6MZ99BsBS8vy8OGN1/Xcw0FBZs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=onplmj3RoO6Vkapi+B8Ujvkr/LnGY/2SZUP6lqZMAhLTCI02i0N8V9LcxJlXc2XTRd L6Q1q9pOtMrdRNA0qsqTNTy3Ej3pyhyW1DllvwkZqwRSmInhVZ9uwmuPWuW7S/u7mrp3 MrRW6HYfUb+CcolB6yDj9WImLPBghYkwj4LrU= Received: by 10.143.161.3 with SMTP id n3mr665482wfo.179.1247929299915; Sat, 18 Jul 2009 08:01:39 -0700 (PDT) Received: from localhost.localdomain (p11179-adsao01yokonib1-acca.kanagawa.ocn.ne.jp [61.199.5.179]) by mx.google.com with ESMTPS id b39sm11639434rvf.0.2009.07.18.08.01.37 (version=SSLv3 cipher=RC4-MD5); Sat, 18 Jul 2009 08:01:39 -0700 (PDT) Date: Sat, 18 Jul 2009 23:58:32 +0900 From: Akinobu Mita To: linux-kernel@vger.kernel.org Cc: Avi Kivity , kvm@vger.kernel.org, x86@kernel.org Subject: [PATCH 1/2] kvm: use get_desc_base() and get_desc_limit() Message-ID: <20090718145830.GA11275@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Use get_desc_base() and get_desc_limit() to get the base address and limit in desc_struct. Cc: Avi Kivity Cc: kvm@vger.kernel.org Signed-off-by: Akinobu Mita --- arch/x86/kvm/x86.c | 18 +++++------------- 1 files changed, 5 insertions(+), 13 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index fe5474a..38d9b53 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -132,8 +132,7 @@ unsigned long segment_base(u16 selector) table_base = segment_base(ldt_selector); } d = (struct desc_struct *)(table_base + (selector & ~7)); - v = d->base0 | ((unsigned long)d->base1 << 16) | - ((unsigned long)d->base2 << 24); + v = get_desc_base(d); #ifdef CONFIG_X86_64 if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11)) v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32; @@ -3617,11 +3616,8 @@ static void kvm_set_segment(struct kvm_vcpu *vcpu, static void seg_desct_to_kvm_desct(struct desc_struct *seg_desc, u16 selector, struct kvm_segment *kvm_desct) { - kvm_desct->base = seg_desc->base0; - kvm_desct->base |= seg_desc->base1 << 16; - kvm_desct->base |= seg_desc->base2 << 24; - kvm_desct->limit = seg_desc->limit0; - kvm_desct->limit |= seg_desc->limit << 16; + kvm_desct->base = get_desc_base(seg_desc); + kvm_desct->limit = get_desc_limit(seg_desc); if (seg_desc->g) { kvm_desct->limit <<= 12; kvm_desct->limit |= 0xfff; @@ -3700,11 +3696,7 @@ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, static u32 get_tss_base_addr(struct kvm_vcpu *vcpu, struct desc_struct *seg_desc) { - u32 base_addr; - - base_addr = seg_desc->base0; - base_addr |= (seg_desc->base1 << 16); - base_addr |= (seg_desc->base2 << 24); + u32 base_addr = get_desc_base(seg_desc); return vcpu->arch.mmu.gva_to_gpa(vcpu, base_addr); } @@ -3993,7 +3985,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason) } } - if (!nseg_desc.p || (nseg_desc.limit0 | nseg_desc.limit << 16) < 0x67) { + if (!nseg_desc.p || get_desc_limit(&nseg_desc) < 0x67) { kvm_queue_exception_e(vcpu, TS_VECTOR, tss_selector & 0xfffc); return 1; }