aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/x86.c
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2009-07-18 10:58:32 -0400
committerAvi Kivity <avi@redhat.com>2009-09-10 01:33:15 -0400
commit46a359e71526909a18a47aaf4347343d6d1d74b2 (patch)
treee2dfcf8f51851b2a42211c79d27dade8b3fc7de8 /arch/x86/kvm/x86.c
parentdecde80b6a2fedd6ea62ea5c4bc4b3cb9fabf153 (diff)
KVM: x86: use get_desc_base() and get_desc_limit()
Use get_desc_base() and get_desc_limit() to get the base address and limit in desc_struct. Cc: Avi Kivity <avi@redhat.com> Cc: kvm@vger.kernel.org Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r--arch/x86/kvm/x86.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b87d65d89a05..6277a316821e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -142,8 +142,7 @@ unsigned long segment_base(u16 selector)
142 table_base = segment_base(ldt_selector); 142 table_base = segment_base(ldt_selector);
143 } 143 }
144 d = (struct desc_struct *)(table_base + (selector & ~7)); 144 d = (struct desc_struct *)(table_base + (selector & ~7));
145 v = d->base0 | ((unsigned long)d->base1 << 16) | 145 v = get_desc_base(d);
146 ((unsigned long)d->base2 << 24);
147#ifdef CONFIG_X86_64 146#ifdef CONFIG_X86_64
148 if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11)) 147 if (d->s == 0 && (d->type == 2 || d->type == 9 || d->type == 11))
149 v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32; 148 v |= ((unsigned long)((struct ldttss_desc64 *)d)->base3) << 32;
@@ -3947,11 +3946,8 @@ static void kvm_set_segment(struct kvm_vcpu *vcpu,
3947static void seg_desct_to_kvm_desct(struct desc_struct *seg_desc, u16 selector, 3946static void seg_desct_to_kvm_desct(struct desc_struct *seg_desc, u16 selector,
3948 struct kvm_segment *kvm_desct) 3947 struct kvm_segment *kvm_desct)
3949{ 3948{
3950 kvm_desct->base = seg_desc->base0; 3949 kvm_desct->base = get_desc_base(seg_desc);
3951 kvm_desct->base |= seg_desc->base1 << 16; 3950 kvm_desct->limit = get_desc_limit(seg_desc);
3952 kvm_desct->base |= seg_desc->base2 << 24;
3953 kvm_desct->limit = seg_desc->limit0;
3954 kvm_desct->limit |= seg_desc->limit << 16;
3955 if (seg_desc->g) { 3951 if (seg_desc->g) {
3956 kvm_desct->limit <<= 12; 3952 kvm_desct->limit <<= 12;
3957 kvm_desct->limit |= 0xfff; 3953 kvm_desct->limit |= 0xfff;
@@ -4030,11 +4026,7 @@ static int save_guest_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
4030static u32 get_tss_base_addr(struct kvm_vcpu *vcpu, 4026static u32 get_tss_base_addr(struct kvm_vcpu *vcpu,
4031 struct desc_struct *seg_desc) 4027 struct desc_struct *seg_desc)
4032{ 4028{
4033 u32 base_addr; 4029 u32 base_addr = get_desc_base(seg_desc);
4034
4035 base_addr = seg_desc->base0;
4036 base_addr |= (seg_desc->base1 << 16);
4037 base_addr |= (seg_desc->base2 << 24);
4038 4030
4039 return vcpu->arch.mmu.gva_to_gpa(vcpu, base_addr); 4031 return vcpu->arch.mmu.gva_to_gpa(vcpu, base_addr);
4040} 4032}
@@ -4323,7 +4315,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
4323 } 4315 }
4324 } 4316 }
4325 4317
4326 if (!nseg_desc.p || (nseg_desc.limit0 | nseg_desc.limit << 16) < 0x67) { 4318 if (!nseg_desc.p || get_desc_limit(&nseg_desc) < 0x67) {
4327 kvm_queue_exception_e(vcpu, TS_VECTOR, tss_selector & 0xfffc); 4319 kvm_queue_exception_e(vcpu, TS_VECTOR, tss_selector & 0xfffc);
4328 return 1; 4320 return 1;
4329 } 4321 }