[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] x86/xstate: re-use valid_xcr0() for boot-time checks
commit e927a3b89ae82ac875aafedbefd6b4bc46201b7d Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue May 4 10:50:32 2021 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Tue May 4 10:50:32 2021 +0200 x86/xstate: re-use valid_xcr0() for boot-time checks Instead of (just partially) open-coding it, re-use the function after suitably moving it up. Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- xen/arch/x86/xstate.c | 58 ++++++++++++++++++++++++++------------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c index 3794d9a5a5..d49413b745 100644 --- a/xen/arch/x86/xstate.c +++ b/xen/arch/x86/xstate.c @@ -574,6 +574,34 @@ unsigned int xstate_ctxt_size(u64 xcr0) return _xstate_ctxt_size(xcr0); } +static bool valid_xcr0(uint64_t xcr0) +{ + /* FP must be unconditionally set. */ + if ( !(xcr0 & X86_XCR0_FP) ) + return false; + + /* YMM depends on SSE. */ + if ( (xcr0 & X86_XCR0_YMM) && !(xcr0 & X86_XCR0_SSE) ) + return false; + + if ( xcr0 & (X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM) ) + { + /* OPMASK, ZMM, and HI_ZMM require YMM. */ + if ( !(xcr0 & X86_XCR0_YMM) ) + return false; + + /* OPMASK, ZMM, and HI_ZMM must be the same. */ + if ( ~xcr0 & (X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM) ) + return false; + } + + /* BNDREGS and BNDCSR must be the same. */ + if ( !(xcr0 & X86_XCR0_BNDREGS) != !(xcr0 & X86_XCR0_BNDCSR) ) + return false; + + return true; +} + /* Collect the information of processor's extended state */ void xstate_init(struct cpuinfo_x86 *c) { @@ -609,10 +637,9 @@ void xstate_init(struct cpuinfo_x86 *c) } cpuid_count(XSTATE_CPUID, 0, &eax, &ebx, &ecx, &edx); - - BUG_ON((eax & XSTATE_FP_SSE) != XSTATE_FP_SSE); - BUG_ON((eax & X86_XCR0_YMM) && !(eax & X86_XCR0_SSE)); feature_mask = (((u64)edx << 32) | eax) & XCNTXT_MASK; + BUG_ON(!valid_xcr0(feature_mask)); + BUG_ON(!(feature_mask & X86_XCR0_SSE)); /* * Set CR4_OSXSAVE and run "cpuid" to get xsave_cntxt_size. @@ -642,31 +669,6 @@ void xstate_init(struct cpuinfo_x86 *c) BUG(); } -static bool valid_xcr0(u64 xcr0) -{ - /* FP must be unconditionally set. */ - if ( !(xcr0 & X86_XCR0_FP) ) - return false; - - /* YMM depends on SSE. */ - if ( (xcr0 & X86_XCR0_YMM) && !(xcr0 & X86_XCR0_SSE) ) - return false; - - if ( xcr0 & (X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM) ) - { - /* OPMASK, ZMM, and HI_ZMM require YMM. */ - if ( !(xcr0 & X86_XCR0_YMM) ) - return false; - - /* OPMASK, ZMM, and HI_ZMM must be the same. */ - if ( ~xcr0 & (X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM) ) - return false; - } - - /* BNDREGS and BNDCSR must be the same. */ - return !(xcr0 & X86_XCR0_BNDREGS) == !(xcr0 & X86_XCR0_BNDCSR); -} - int validate_xstate(const struct domain *d, uint64_t xcr0, uint64_t xcr0_accum, const struct xsave_hdr *hdr) { -- generated by git-patchbot for /home/xen/git/xen.git#master
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |