Skip to content

Commit

Permalink
KVM: VMX: Optimize vmx_get_cpl()
Browse files Browse the repository at this point in the history
In long mode, vm86 mode is disallowed, so we need not check for
it.  Reading rflags.vm may require a VMREAD, so it is expensive.

Signed-off-by: Avi Kivity <avi@redhat.com>
  • Loading branch information
Avi Kivity committed May 11, 2011
1 parent 6de1273 commit f4c63e5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2120,7 +2120,8 @@ static int vmx_get_cpl(struct kvm_vcpu *vcpu)
if (!is_protmode(vcpu))
return 0;

if (kvm_get_rflags(vcpu) & X86_EFLAGS_VM) /* if virtual 8086 */
if (!is_long_mode(vcpu)
&& (kvm_get_rflags(vcpu) & X86_EFLAGS_VM)) /* if virtual 8086 */
return 3;

return vmcs_read16(GUEST_CS_SELECTOR) & 3;
Expand Down

0 comments on commit f4c63e5

Please sign in to comment.