KVM: VMX: Optimize vmx_get_cpl()
authorAvi Kivity <avi@redhat.com>
Tue, 4 Aug 2009 12:02:54 +0000 (15:02 +0300)
committerAvi Kivity <avi@redhat.com>
Thu, 10 Sep 2009 05:33:21 +0000 (08:33 +0300)
Instead of calling vmx_get_segment() (which reads a whole bunch of
vmcs fields), read only the cs selector which contains the cpl.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/vmx.c

index 32e6d2031ba26d8522d29be13c7656aaf0be3dbc..0ba706e87c50a2cc5bfd01e7502d89ce2a51972f 100644 (file)
@@ -1773,16 +1773,13 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu,
 
 static int vmx_get_cpl(struct kvm_vcpu *vcpu)
 {
-       struct kvm_segment kvm_seg;
-
        if (!(vcpu->arch.cr0 & X86_CR0_PE)) /* if real mode */
                return 0;
 
        if (vmx_get_rflags(vcpu) & X86_EFLAGS_VM) /* if virtual 8086 */
                return 3;
 
-       vmx_get_segment(vcpu, &kvm_seg, VCPU_SREG_CS);
-       return kvm_seg.selector & 3;
+       return vmcs_read16(GUEST_CS_SELECTOR) & 3;
 }
 
 static u32 vmx_segment_access_rights(struct kvm_segment *var)