diff options
Diffstat (limited to 'arch/x86/kvm/x86.c')
-rw-r--r-- | arch/x86/kvm/x86.c | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 05a8b1a2300d..094b5d96ab14 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -555,6 +555,25 @@ void kvm_lmsw(struct kvm_vcpu *vcpu, unsigned long msw) | |||
555 | } | 555 | } |
556 | EXPORT_SYMBOL_GPL(kvm_lmsw); | 556 | EXPORT_SYMBOL_GPL(kvm_lmsw); |
557 | 557 | ||
558 | static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu) | ||
559 | { | ||
560 | if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) && | ||
561 | !vcpu->guest_xcr0_loaded) { | ||
562 | /* kvm_set_xcr() also depends on this */ | ||
563 | xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0); | ||
564 | vcpu->guest_xcr0_loaded = 1; | ||
565 | } | ||
566 | } | ||
567 | |||
568 | static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu) | ||
569 | { | ||
570 | if (vcpu->guest_xcr0_loaded) { | ||
571 | if (vcpu->arch.xcr0 != host_xcr0) | ||
572 | xsetbv(XCR_XFEATURE_ENABLED_MASK, host_xcr0); | ||
573 | vcpu->guest_xcr0_loaded = 0; | ||
574 | } | ||
575 | } | ||
576 | |||
558 | int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) | 577 | int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) |
559 | { | 578 | { |
560 | u64 xcr0; | 579 | u64 xcr0; |
@@ -571,8 +590,8 @@ int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) | |||
571 | return 1; | 590 | return 1; |
572 | if (xcr0 & ~host_xcr0) | 591 | if (xcr0 & ~host_xcr0) |
573 | return 1; | 592 | return 1; |
593 | kvm_put_guest_xcr0(vcpu); | ||
574 | vcpu->arch.xcr0 = xcr0; | 594 | vcpu->arch.xcr0 = xcr0; |
575 | vcpu->guest_xcr0_loaded = 0; | ||
576 | return 0; | 595 | return 0; |
577 | } | 596 | } |
578 | 597 | ||
@@ -5614,25 +5633,6 @@ static void inject_pending_event(struct kvm_vcpu *vcpu) | |||
5614 | } | 5633 | } |
5615 | } | 5634 | } |
5616 | 5635 | ||
5617 | static void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu) | ||
5618 | { | ||
5619 | if (kvm_read_cr4_bits(vcpu, X86_CR4_OSXSAVE) && | ||
5620 | !vcpu->guest_xcr0_loaded) { | ||
5621 | /* kvm_set_xcr() also depends on this */ | ||
5622 | xsetbv(XCR_XFEATURE_ENABLED_MASK, vcpu->arch.xcr0); | ||
5623 | vcpu->guest_xcr0_loaded = 1; | ||
5624 | } | ||
5625 | } | ||
5626 | |||
5627 | static void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu) | ||
5628 | { | ||
5629 | if (vcpu->guest_xcr0_loaded) { | ||
5630 | if (vcpu->arch.xcr0 != host_xcr0) | ||
5631 | xsetbv(XCR_XFEATURE_ENABLED_MASK, host_xcr0); | ||
5632 | vcpu->guest_xcr0_loaded = 0; | ||
5633 | } | ||
5634 | } | ||
5635 | |||
5636 | static void process_nmi(struct kvm_vcpu *vcpu) | 5636 | static void process_nmi(struct kvm_vcpu *vcpu) |
5637 | { | 5637 | { |
5638 | unsigned limit = 2; | 5638 | unsigned limit = 2; |