FreeBSD/sys/i386/isa/npx.c
/*
 * Enable XSAVE if supported and allowed by user.
 * Calculate the xsave_mask.
 */
Enable XSAVE if supported and allowed by user.
Enable XSAVE if supported and allowed by user .
static void
npxinit_bsp1(void)
{
	u_int cp[4];
	uint64_t xsave_mask_user;
	if (cpu_fxsr && (cpu_feature2 & CPUID2_XSAVE) != 0) {
		use_xsave = 1;
		TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave);
	}
	if (!use_xsave)
		return;
	cpuid_count(0xd, 0x0, cp);
	xsave_mask = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE;
	if ((cp[0] & xsave_mask) != xsave_mask)
		panic("CPU0 does not support X87 or SSE: %x", cp[0]);
	xsave_mask = ((uint64_t)cp[3] << 32) | cp[0];
	xsave_mask_user = xsave_mask;
	TUNABLE_QUAD_FETCH("hw.xsave_mask", &xsave_mask_user);
	xsave_mask_user |= XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE;
	xsave_mask &= xsave_mask_user;
	if ((xsave_mask & XFEATURE_AVX512) != XFEATURE_AVX512)
		xsave_mask &= ~XFEATURE_AVX512;
	if ((xsave_mask & XFEATURE_MPX) != XFEATURE_MPX)
		xsave_mask &= ~XFEATURE_MPX;
	cpuid_count(0xd, 0x1, cp);
	if ((cp[0] & CPUID_EXTSTATE_XSAVEOPT) != 0)
		use_xsaveopt = 1;
}
static void npxinit_bsp1 ( void ) { u_int cp [ 4 ] ; uint64_t xsave_mask_user ; if ( cpu_fxsr && ( cpu_feature2 & CPUID2_XSAVE ) != 0 ) { use_xsave = 1 ; TUNABLE_INT_FETCH ( " " , & use_xsave ) ; } if ( ! use_xsave ) return ; cpuid_count ( 0xd , 0x0 , cp ) ; xsave_mask = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE ; if ( ( cp [ 0 ] & xsave_mask ) != xsave_mask ) panic ( " " , cp [ 0 ] ) ; xsave_mask = ( ( uint64_t ) cp [ 3 ] << 32 ) | cp [ 0 ] ; xsave_mask_user = xsave_mask ; TUNABLE_QUAD_FETCH ( " " , & xsave_mask_user ) ; xsave_mask_user |= XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE ; xsave_mask &= xsave_mask_user ; if ( ( xsave_mask & XFEATURE_AVX512 ) != XFEATURE_AVX512 ) xsave_mask &= ~ XFEATURE_AVX512 ; if ( ( xsave_mask & XFEATURE_MPX ) != XFEATURE_MPX ) xsave_mask &= ~ XFEATURE_MPX ; cpuid_count ( 0xd , 0x1 , cp ) ; if ( ( cp [ 0 ] & CPUID_EXTSTATE_XSAVEOPT ) != 0 ) use_xsaveopt = 1 ; }
Enable XSAVE if supported and allowed by user.
Enable XSAVE if supported and allowed by user .