diff options
author | Avi Kivity <avi@redhat.com> | 2010-01-21 08:31:48 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2010-03-01 10:36:04 -0500 |
commit | 3eeb3288bcbf64da90afc26389b8844df7c34912 (patch) | |
tree | 1b7bc55641015605da0b415a928ecf39aac64a2e /arch/x86/kvm/x86.c | |
parent | 6b52d18605f580bdffaffd48c8da228c3e848deb (diff) |
KVM: Add a helper for checking if the guest is in protected mode
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4db0c8a9082e..a4a7d1892f72 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -3786,8 +3786,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu) | |||
3786 | * hypercall generates UD from non zero cpl and real mode | 3786 | * hypercall generates UD from non zero cpl and real mode |
3787 | * per HYPER-V spec | 3787 | * per HYPER-V spec |
3788 | */ | 3788 | */ |
3789 | if (kvm_x86_ops->get_cpl(vcpu) != 0 || | 3789 | if (kvm_x86_ops->get_cpl(vcpu) != 0 || !is_protmode(vcpu)) { |
3790 | !kvm_read_cr0_bits(vcpu, X86_CR0_PE)) { | ||
3791 | kvm_queue_exception(vcpu, UD_VECTOR); | 3790 | kvm_queue_exception(vcpu, UD_VECTOR); |
3792 | return 0; | 3791 | return 0; |
3793 | } | 3792 | } |
@@ -4751,7 +4750,7 @@ int kvm_load_segment_descriptor(struct kvm_vcpu *vcpu, u16 selector, | |||
4751 | { | 4750 | { |
4752 | struct kvm_segment kvm_seg; | 4751 | struct kvm_segment kvm_seg; |
4753 | 4752 | ||
4754 | if (is_vm86_segment(vcpu, seg) || !(kvm_read_cr0_bits(vcpu, X86_CR0_PE))) | 4753 | if (is_vm86_segment(vcpu, seg) || !is_protmode(vcpu)) |
4755 | return kvm_load_realmode_segment(vcpu, selector, seg); | 4754 | return kvm_load_realmode_segment(vcpu, selector, seg); |
4756 | if (load_segment_descriptor_to_kvm_desct(vcpu, selector, &kvm_seg)) | 4755 | if (load_segment_descriptor_to_kvm_desct(vcpu, selector, &kvm_seg)) |
4757 | return 1; | 4756 | return 1; |
@@ -5103,7 +5102,7 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu, | |||
5103 | /* Older userspace won't unhalt the vcpu on reset. */ | 5102 | /* Older userspace won't unhalt the vcpu on reset. */ |
5104 | if (kvm_vcpu_is_bsp(vcpu) && kvm_rip_read(vcpu) == 0xfff0 && | 5103 | if (kvm_vcpu_is_bsp(vcpu) && kvm_rip_read(vcpu) == 0xfff0 && |
5105 | sregs->cs.selector == 0xf000 && sregs->cs.base == 0xffff0000 && | 5104 | sregs->cs.selector == 0xf000 && sregs->cs.base == 0xffff0000 && |
5106 | !(kvm_read_cr0_bits(vcpu, X86_CR0_PE))) | 5105 | !is_protmode(vcpu)) |
5107 | vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; | 5106 | vcpu->arch.mp_state = KVM_MP_STATE_RUNNABLE; |
5108 | 5107 | ||
5109 | vcpu_put(vcpu); | 5108 | vcpu_put(vcpu); |