From 33215118f385998dcf93e2dc39dc3241a3595c0c Mon Sep 17 00:00:00 2001 From: Eduardo Habkost <ehabkost@redhat.com> Date: Mon, 21 Sep 2009 14:25:19 -0300 Subject: [PATCH 1/3] KVM: VMX: Optimize vmx_get_cpl() RH-Author: Marcelo Tosatti <mtosatti@redhat.com> Message-id: <20090918045602.GB30186@amt.cnet> Patchwork-id: 3442 O-Subject: [RHEL-5.4.z KVM PATCH] KVM: VMX: Optimize vmx_get_cpl() Bugzilla: 524126 RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com> RH-Acked-by: Andrea Arcangeli <aarcange@redhat.com> From: Avi Kivity <avi@redhat.com> 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> (cherry picked from commit eab4b8aa34fc64e3a91358e1612e6d059396193b) Bugzilla: 524125 Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- arch/x86/kvm/vmx.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 3f1f928..6a553d3 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1680,16 +1680,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) -- 1.6.3.rc4.29.g8146