Project

General

Profile

Submit #3264 » 2-always-use-XSAVE.diff

Anonymous, 01/15/2021 11:44 PM

View differences:

sys/platform/pc64/x86_64/initcpu.c
char cpu_vendor[20]; /* CPU Origin code */
u_int cpu_vendor_id; /* CPU vendor ID */
u_int cpu_fxsr; /* SSE enabled */
u_int cpu_xsave; /* AVX enabled by OS*/
u_int cpu_xsave; /* Using XSAVE */
u_int cpu_clflush_line_size = 32; /* Default CLFLUSH line size */
u_int cpu_stdext_feature;
u_int cpu_stdext_feature2;
......
}
#if !defined(CPU_DISABLE_AVX)
/*Check for XSAVE and AVX support and enable if available.*/
if ((cpu_feature2 & CPUID2_AVX) && (cpu_feature2 & CPUID2_XSAVE)
&& (cpu_feature & CPUID_SSE)) {
/* Use XSAVE if supported. */
if (cpu_feature2 & CPUID2_XSAVE) {
load_cr4(rcr4() | CR4_XSAVE);
/* Adjust size of savefpu in npx.h before adding to mask.*/
npx_xcr0_mask = CPU_XFEATURE_X87 | CPU_XFEATURE_SSE |
CPU_XFEATURE_YMM;
npx_xcr0_mask = CPU_XFEATURE_X87 | CPU_XFEATURE_SSE;
if (cpu_feature2 & CPUID2_AVX) {
npx_xcr0_mask |= CPU_XFEATURE_YMM;
}
xsetbv(0, npx_xcr0_mask);
cpu_xsave = 1;
sys/platform/pc64/x86_64/npx.c
bcopy(td->td_savefpu, mctx->mc_fpregs, sizeof(*td->td_savefpu));
td->td_flags &= ~TDF_USINGFP;
#ifndef CPU_DISABLE_AVX
if (cpu_xsave)
if (npx_xcr0_mask & CPU_XFEATURE_YMM)
mctx->mc_fpformat = _MC_FPFMT_YMM;
else
#endif
(2-2/2)