Skip to content

Commit

Permalink
KVM: x86: Fix TSS size check for 16-bit tasks
Browse files Browse the repository at this point in the history
(Cherry-picked from commit e8861cf)

A 16-bit TSS is only 44 bytes long. So make sure to test for the correct
size on task switch.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jan Kiszka authored and Greg Kroah-Hartman committed Apr 26, 2010
1 parent 00e7035 commit 151b026
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion arch/x86/kvm/x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -4576,6 +4576,7 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
int ret = 0;
u32 old_tss_base = get_segment_base(vcpu, VCPU_SREG_TR);
u16 old_tss_sel = get_segment_selector(vcpu, VCPU_SREG_TR);
u32 desc_limit;

old_tss_base = vcpu->arch.mmu.gva_to_gpa(vcpu, old_tss_base);

Expand All @@ -4598,7 +4599,10 @@ int kvm_task_switch(struct kvm_vcpu *vcpu, u16 tss_selector, int reason)
}
}

if (!nseg_desc.p || get_desc_limit(&nseg_desc) < 0x67) {
desc_limit = get_desc_limit(&nseg_desc);
if (!nseg_desc.p ||
((desc_limit < 0x67 && (nseg_desc.type & 8)) ||
desc_limit < 0x2b)) {
kvm_queue_exception_e(vcpu, TS_VECTOR, tss_selector & 0xfffc);
return 1;
}
Expand Down

0 comments on commit 151b026

Please sign in to comment.