提交 eab4b8aa 编写于 作者: A Avi Kivity

KVM: VMX: Optimize vmx_get_cpl()

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: NAvi Kivity <avi@redhat.com>
上级 07708c4a
...@@ -1773,16 +1773,13 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu, ...@@ -1773,16 +1773,13 @@ static void vmx_get_segment(struct kvm_vcpu *vcpu,
static int vmx_get_cpl(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 */ if (!(vcpu->arch.cr0 & X86_CR0_PE)) /* if real mode */
return 0; return 0;
if (vmx_get_rflags(vcpu) & X86_EFLAGS_VM) /* if virtual 8086 */ if (vmx_get_rflags(vcpu) & X86_EFLAGS_VM) /* if virtual 8086 */
return 3; return 3;
vmx_get_segment(vcpu, &kvm_seg, VCPU_SREG_CS); return vmcs_read16(GUEST_CS_SELECTOR) & 3;
return kvm_seg.selector & 3;
} }
static u32 vmx_segment_access_rights(struct kvm_segment *var) static u32 vmx_segment_access_rights(struct kvm_segment *var)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册