Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 3160499aacb81f6735941eb4c372d87a > files > 431

kvm-83-164.el5_5.30.src.rpm

From b44fba8eab9ad89882fd34b112c9af1da3307447 Mon Sep 17 00:00:00 2001
From: Marcelo Tosatti <mtosatti@redhat.com>
Date: Wed, 25 Nov 2009 18:14:17 -0200
Subject: [PATCH 2/3] KVM: x86: raise TSS exception for NULL CS and SS segments

RH-Author: Marcelo Tosatti <mtosatti@redhat.com>
Message-id: <20091125181417.GB12634@amt.cnet>
Patchwork-id: 3790
O-Subject: [PATCH RHEL-5.5/5.4.z] KVM: x86: raise TSS exception for NULL CS
	and SS segments
Bugzilla: 532086
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Avi Kivity <avi@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>

commit 5e8cb552cb8b48244b6d07bff984b3c4080d4bc9
Author: Marcelo Tosatti <mtosatti@redhat.com>
Date:   Wed Nov 11 17:29:49 2009 -0200

KVM: x86: raise TSS exception for NULL CS and SS segments

Windows 2003 uses task switch to triple fault and reboot (the other
exception being reserved pdptrs bits).

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Bugzilla: 532086

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 arch/x86/kvm/x86.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 9a4b9cf..6f5e7e8 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -3670,6 +3670,15 @@ static int is_vm86_segment(struct kvm_vcpu *vcpu, int seg)
 		(kvm_x86_ops->get_rflags(vcpu) & X86_EFLAGS_VM);
 }
 
+static void kvm_check_segment_descriptor(struct kvm_vcpu *vcpu, int seg,
+					 u16 selector)
+{
+	/* NULL selector is not valid for CS and SS */
+	if (seg == VCPU_SREG_CS || seg == VCPU_SREG_SS)
+		if (!selector)
+			kvm_queue_exception_e(vcpu, TS_VECTOR, selector >> 3);
+}
+
 int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
 				int type_bits, int seg)
 {
@@ -3679,6 +3688,8 @@ int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector,
 		return kvm_load_realmode_segment(vcpu, selector, seg);
 	if (load_segment_descriptor_to_kvm_desct(vcpu, selector, &kvm_seg))
 		return 1;
+
+	kvm_check_segment_descriptor(vcpu, seg, selector);
 	kvm_seg.type |= type_bits;
 
 	if (seg != VCPU_SREG_SS && seg != VCPU_SREG_CS &&
-- 
1.6.3.rc4.29.g8146