diff options
author | Avi Kivity <avi@qumranet.com> | 2007-06-14 09:27:40 -0400 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2007-06-15 05:30:59 -0400 |
commit | 7702fd1f6fea57921f2e643d27a23a2d0394499c (patch) | |
tree | 9a5275fb2f5eaccc491bfe5d9617c3da7f69aa5a /drivers/kvm/kvm_main.c | |
parent | 22b1a9203ea634ac0ee5240e021613da3328275f (diff) |
KVM: Prevent guest fpu state from leaking into the host
The lazy fpu changes did not take into account that some vmexit handlers
can sleep. Move loading the guest state into the inner loop so that it
can be reloaded if necessary, and move loading the host state into
vmx_vcpu_put() so it can be performed whenever we relinquish the vcpu.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r-- | drivers/kvm/kvm_main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index da985b31b17e..8f1f07adb04e 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c | |||
@@ -253,6 +253,28 @@ int kvm_write_guest(struct kvm_vcpu *vcpu, gva_t addr, unsigned long size, | |||
253 | } | 253 | } |
254 | EXPORT_SYMBOL_GPL(kvm_write_guest); | 254 | EXPORT_SYMBOL_GPL(kvm_write_guest); |
255 | 255 | ||
256 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu) | ||
257 | { | ||
258 | if (!vcpu->fpu_active || vcpu->guest_fpu_loaded) | ||
259 | return; | ||
260 | |||
261 | vcpu->guest_fpu_loaded = 1; | ||
262 | fx_save(vcpu->host_fx_image); | ||
263 | fx_restore(vcpu->guest_fx_image); | ||
264 | } | ||
265 | EXPORT_SYMBOL_GPL(kvm_load_guest_fpu); | ||
266 | |||
267 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) | ||
268 | { | ||
269 | if (!vcpu->guest_fpu_loaded) | ||
270 | return; | ||
271 | |||
272 | vcpu->guest_fpu_loaded = 0; | ||
273 | fx_save(vcpu->guest_fx_image); | ||
274 | fx_restore(vcpu->host_fx_image); | ||
275 | } | ||
276 | EXPORT_SYMBOL_GPL(kvm_put_guest_fpu); | ||
277 | |||
256 | /* | 278 | /* |
257 | * Switches to specified vcpu, until a matching vcpu_put() | 279 | * Switches to specified vcpu, until a matching vcpu_put() |
258 | */ | 280 | */ |