public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: kvm@vger.kernel.org
Cc: gleb@redhat.com, jan.kiszka@siemens.com, joerg.roedel@amd.com,
	Marcelo Tosatti <mtosatti@redhat.com>
Subject: [patch 2/2] KVM: x86: raise TSS exception for NULL CS and SS segments
Date: Wed, 11 Nov 2009 17:29:49 -0200	[thread overview]
Message-ID: <20091111193837.229269590@localhost.localdomain> (raw)
In-Reply-To: 20091111192947.348198723@localhost.localdomain

[-- Attachment #1: taskswitch --]
[-- Type: text/plain, Size: 1169 bytes --]

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>

Index: kvm/arch/x86/kvm/x86.c
===================================================================
--- kvm.orig/arch/x86/kvm/x86.c
+++ kvm/arch/x86/kvm/x86.c
@@ -4091,6 +4091,15 @@ static int is_vm86_segment(struct kvm_vc
 		(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)
 {
@@ -4100,6 +4109,8 @@ int kvm_load_segment_descriptor(struct k
 		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 &&

-- 


  parent reply	other threads:[~2009-11-11 19:45 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-11 19:29 [patch 0/2] Handle multiple exceptions (fixes Win2003 reboot by triple fault) Marcelo Tosatti
2009-11-11 19:29 ` [patch 1/2] KVM: x86: handle double and triple faults for every exception Marcelo Tosatti
2009-11-11 20:07   ` Jan Kiszka
2009-11-11 20:41     ` Marcelo Tosatti
2009-11-11 21:02       ` Jan Kiszka
2009-11-11 21:40         ` Marcelo Tosatti
2009-11-15 12:30           ` Avi Kivity
2009-11-12 12:26   ` Gleb Natapov
2009-11-15 12:41     ` Avi Kivity
2009-11-15 12:51       ` Gleb Natapov
2009-11-15 13:11         ` Avi Kivity
2009-11-15 14:29           ` Jan Kiszka
2009-11-15 14:34             ` Avi Kivity
2009-11-15 14:36               ` Jan Kiszka
2009-11-11 19:29 ` Marcelo Tosatti [this message]
2009-11-12 12:21 ` [patch 0/2] Handle multiple exceptions (fixes Win2003 reboot by triple fault) Gleb Natapov
2009-11-12 12:41   ` Jan Kiszka
2009-11-12 13:05     ` Gleb Natapov
2009-11-15 12:54       ` Avi Kivity
2009-11-19 15:54         ` Gleb Natapov
2009-11-20 15:55           ` Ryan Harper
2009-11-23 16:52           ` Marcelo Tosatti
2009-11-25  9:55           ` Avi Kivity
2009-11-25 13:03           ` Marcelo Tosatti
2009-11-12 16:07   ` Marcelo Tosatti
2009-11-12 18:03     ` Gleb Natapov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091111193837.229269590@localhost.localdomain \
    --to=mtosatti@redhat.com \
    --cc=gleb@redhat.com \
    --cc=jan.kiszka@siemens.com \
    --cc=joerg.roedel@amd.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox