aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorDexuan Cui <dexuan.cui@intel.com>2010-06-09 23:27:12 -0400
committerAvi Kivity <avi@redhat.com>2010-08-01 03:46:31 -0400
commit2acf923e38fb6a4ce0c57115decbb38d334902ac (patch)
tree51a0fba243c857a3bc373ab152c6374c804df224 /arch/x86/kvm/vmx.c
parentf495c6e5e8fdc972162241df5bdff5bcebb4dc33 (diff)
KVM: VMX: Enable XSAVE/XRSTOR for guest
This patch enable guest to use XSAVE/XRSTOR instructions. We assume that host_xcr0 would use all possible bits that OS supported. And we loaded xcr0 in the same way we handled fpu - do it as late as we can. Signed-off-by: Dexuan Cui <dexuan.cui@intel.com> Signed-off-by: Sheng Yang <sheng@linux.intel.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 26ba61d6af8c..864a1b6d155a 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -37,6 +37,8 @@
37#include <asm/vmx.h> 37#include <asm/vmx.h>
38#include <asm/virtext.h> 38#include <asm/virtext.h>
39#include <asm/mce.h> 39#include <asm/mce.h>
40#include <asm/i387.h>
41#include <asm/xcr.h>
40 42
41#include "trace.h" 43#include "trace.h"
42 44
@@ -3390,6 +3392,16 @@ static int handle_wbinvd(struct kvm_vcpu *vcpu)
3390 return 1; 3392 return 1;
3391} 3393}
3392 3394
3395static int handle_xsetbv(struct kvm_vcpu *vcpu)
3396{
3397 u64 new_bv = kvm_read_edx_eax(vcpu);
3398 u32 index = kvm_register_read(vcpu, VCPU_REGS_RCX);
3399
3400 if (kvm_set_xcr(vcpu, index, new_bv) == 0)
3401 skip_emulated_instruction(vcpu);
3402 return 1;
3403}
3404
3393static int handle_apic_access(struct kvm_vcpu *vcpu) 3405static int handle_apic_access(struct kvm_vcpu *vcpu)
3394{ 3406{
3395 return emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DONE; 3407 return emulate_instruction(vcpu, 0, 0, 0) == EMULATE_DONE;
@@ -3668,6 +3680,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
3668 [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold, 3680 [EXIT_REASON_TPR_BELOW_THRESHOLD] = handle_tpr_below_threshold,
3669 [EXIT_REASON_APIC_ACCESS] = handle_apic_access, 3681 [EXIT_REASON_APIC_ACCESS] = handle_apic_access,
3670 [EXIT_REASON_WBINVD] = handle_wbinvd, 3682 [EXIT_REASON_WBINVD] = handle_wbinvd,
3683 [EXIT_REASON_XSETBV] = handle_xsetbv,
3671 [EXIT_REASON_TASK_SWITCH] = handle_task_switch, 3684 [EXIT_REASON_TASK_SWITCH] = handle_task_switch,
3672 [EXIT_REASON_MCE_DURING_VMENTRY] = handle_machine_check, 3685 [EXIT_REASON_MCE_DURING_VMENTRY] = handle_machine_check,
3673 [EXIT_REASON_EPT_VIOLATION] = handle_ept_violation, 3686 [EXIT_REASON_EPT_VIOLATION] = handle_ept_violation,