diff options
author | Wei Gang <gang.wei@intel.com> | 2011-02-21 09:11:57 +0000 |
---|---|---|
committer | Wei Gang <gang.wei@intel.com> | 2011-02-21 09:11:57 +0000 |
commit | 3af87a7ece7f27a537a006196873ca9fda696616 (patch) | |
tree | 5fd8c0199526ccb8651a76da2b334223b6e41b7d /xen/arch/x86/i387.c | |
parent | 0dba10b8e37f3f63ed9f5ed449d9e9e0c8c9f1aa (diff) | |
download | xen-3af87a7ece7f27a537a006196873ca9fda696616.tar.gz xen-3af87a7ece7f27a537a006196873ca9fda696616.tar.bz2 xen-3af87a7ece7f27a537a006196873ca9fda696616.zip |
x86: add strictly sanity check for XSAVE/XRSTOR
Replace most checks on cpu_has_xsave with checks on new fn
xsave_enabled(), do additional sanity checks in the new fn.
Signed-off-by: Wei Gang <gang.wei@intel.com>
Signed-off-by: Keir Fraser <keir.xen@gmail.com>
Diffstat (limited to 'xen/arch/x86/i387.c')
-rw-r--r-- | xen/arch/x86/i387.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/xen/arch/x86/i387.c b/xen/arch/x86/i387.c index 5c96da0456..7d0a9fa3f5 100644 --- a/xen/arch/x86/i387.c +++ b/xen/arch/x86/i387.c @@ -69,7 +69,7 @@ void setup_fpu(struct vcpu *v) if ( v->fpu_dirtied ) return; - if ( cpu_has_xsave ) + if ( xsave_enabled(v) ) { /* * XCR0 normally represents what guest OS set. In case of Xen itself, @@ -116,7 +116,7 @@ void save_init_fpu(struct vcpu *v) if ( cr0 & X86_CR0_TS ) clts(); - if ( cpu_has_xsave ) + if ( xsave_enabled(v) ) { /* XCR0 normally represents what guest OS set. In case of Xen itself, * we set all accumulated feature mask before doing save/restore. @@ -316,6 +316,17 @@ void xsave_free_save_area(struct vcpu *v) v->arch.xsave_area = NULL; } +bool_t xsave_enabled(const struct vcpu *v) +{ + if ( cpu_has_xsave ) + { + ASSERT(xsave_cntxt_size >= XSAVE_AREA_MIN_SIZE); + ASSERT(v->arch.xsave_area); + } + + return cpu_has_xsave; +} + /* * Local variables: * mode: C |