diff options
Diffstat (limited to 'arch/powerpc/kvm/booke.h')
-rw-r--r-- | arch/powerpc/kvm/booke.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h index d53bcf2558f5..62c4fe55d19b 100644 --- a/arch/powerpc/kvm/booke.h +++ b/arch/powerpc/kvm/booke.h | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/types.h> | 23 | #include <linux/types.h> |
24 | #include <linux/kvm_host.h> | 24 | #include <linux/kvm_host.h> |
25 | #include <asm/kvm_ppc.h> | 25 | #include <asm/kvm_ppc.h> |
26 | #include <asm/switch_to.h> | ||
26 | #include "timing.h" | 27 | #include "timing.h" |
27 | 28 | ||
28 | /* interrupt priortity ordering */ | 29 | /* interrupt priortity ordering */ |
@@ -96,4 +97,34 @@ enum int_class { | |||
96 | 97 | ||
97 | void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type); | 98 | void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type); |
98 | 99 | ||
100 | /* | ||
101 | * Load up guest vcpu FP state if it's needed. | ||
102 | * It also set the MSR_FP in thread so that host know | ||
103 | * we're holding FPU, and then host can help to save | ||
104 | * guest vcpu FP state if other threads require to use FPU. | ||
105 | * This simulates an FP unavailable fault. | ||
106 | * | ||
107 | * It requires to be called with preemption disabled. | ||
108 | */ | ||
109 | static inline void kvmppc_load_guest_fp(struct kvm_vcpu *vcpu) | ||
110 | { | ||
111 | #ifdef CONFIG_PPC_FPU | ||
112 | if (vcpu->fpu_active && !(current->thread.regs->msr & MSR_FP)) { | ||
113 | load_up_fpu(); | ||
114 | current->thread.regs->msr |= MSR_FP; | ||
115 | } | ||
116 | #endif | ||
117 | } | ||
118 | |||
119 | /* | ||
120 | * Save guest vcpu FP state into thread. | ||
121 | * It requires to be called with preemption disabled. | ||
122 | */ | ||
123 | static inline void kvmppc_save_guest_fp(struct kvm_vcpu *vcpu) | ||
124 | { | ||
125 | #ifdef CONFIG_PPC_FPU | ||
126 | if (vcpu->fpu_active && (current->thread.regs->msr & MSR_FP)) | ||
127 | giveup_fpu(current); | ||
128 | #endif | ||
129 | } | ||
99 | #endif /* __KVM_BOOKE_H__ */ | 130 | #endif /* __KVM_BOOKE_H__ */ |