public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* KVM: VMX: fix incorrect cached cpl value with real/v8086 modes
@ 2012-12-19 13:29 Marcelo Tosatti
       [not found] ` <CAEbWair0awmpB9QXFGXJmooSsHg3B6P3uZrmLcyzs=T70TS7VA@mail.gmail.com>
  2013-01-03 13:49 ` KVM: VMX: fix incorrect cached cpl value with real/v8086 modes (v2) Marcelo Tosatti
  0 siblings, 2 replies; 14+ messages in thread
From: Marcelo Tosatti @ 2012-12-19 13:29 UTC (permalink / raw)
  To: Gleb Natapov, Avi Kivity; +Cc: kvm



CPL is always 0 when in real mode, and always 3 when virtual 8086 mode.

Using values other than those can cause failures on operations that check CPL.

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

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index a4ecf7c..3abe433 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3215,13 +3215,6 @@ static u64 vmx_get_segment_base(struct kvm_vcpu *vcpu, int seg)
 
 static int __vmx_get_cpl(struct kvm_vcpu *vcpu)
 {
-	if (!is_protmode(vcpu))
-		return 0;
-
-	if (!is_long_mode(vcpu)
-	    && (kvm_get_rflags(vcpu) & X86_EFLAGS_VM)) /* if virtual 8086 */
-		return 3;
-
 	return vmx_read_guest_seg_selector(to_vmx(vcpu), VCPU_SREG_CS) & 3;
 }
 
@@ -3229,6 +3222,13 @@ static int vmx_get_cpl(struct kvm_vcpu *vcpu)
 {
 	struct vcpu_vmx *vmx = to_vmx(vcpu);
 
+	if (!is_protmode(vcpu))
+		return 0;
+
+	if (!is_long_mode(vcpu)
+	    && (kvm_get_rflags(vcpu) & X86_EFLAGS_VM)) /* if virtual 8086 */
+		return 3;
+
 	/*
 	 * If we enter real mode with cs.sel & 3 != 0, the normal CPL calculations
 	 * fail; use the cache instead.

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-01-08 10:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-19 13:29 KVM: VMX: fix incorrect cached cpl value with real/v8086 modes Marcelo Tosatti
     [not found] ` <CAEbWair0awmpB9QXFGXJmooSsHg3B6P3uZrmLcyzs=T70TS7VA@mail.gmail.com>
2012-12-25 12:48   ` Gleb Natapov
2012-12-25 21:37     ` Marcelo Tosatti
2012-12-26  5:25       ` Gleb Natapov
2012-12-26 13:25         ` Marcelo Tosatti
2012-12-26 13:33           ` Gleb Natapov
2013-01-01 23:36             ` Marcelo Tosatti
2013-01-03  8:11               ` Gleb Natapov
2013-01-03 13:19                 ` Marcelo Tosatti
2013-01-04 11:16                   ` Gleb Natapov
2013-01-01 23:41   ` Marcelo Tosatti
2013-01-03 13:49 ` KVM: VMX: fix incorrect cached cpl value with real/v8086 modes (v2) Marcelo Tosatti
2013-01-07 21:27   ` KVM: VMX: fix incorrect cached cpl value with real/v8086 modes (v3) Marcelo Tosatti
2013-01-08 10:56     ` Gleb Natapov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox