/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* Floating point configuration.
*/
#include <sys/privregs.h>
#include <sys/x86_archext.h>
#include <sys/archsystm.h>
/*
* If fpu_exists is non-zero, fpu_probe will attempt to use any
* hardware FPU (subject to other constraints, see below). If
* fpu_exists is zero, fpu_probe will report that there is no
* FPU even if there is one.
*/
/*
* Mechanism to save FPU state.
*/
#if defined(__amd64)
#endif
/*
* The variable fpu_ignored is provided to allow other code to
* determine whether emulation is being done because there is
*/
int fpu_ignored = 0;
/*
* Used by ppcopy and ppzero to determine whether or not to use the
* SSE-based pagecopy and pagezero routines
*/
int use_sse_pagecopy = 0;
int use_sse_pagezero = 0;
int use_sse_copy = 0;
#if defined(__i386)
/*
* The variable fpu_pentium_fdivbug is provided to allow other code to
* determine whether the system contains a Pentium with the FDIV problem.
*/
int fpu_pentium_fdivbug = 0;
#endif
#if defined(__xpv)
/*
* Use of SSE or otherwise is forcibly configured for us by the hypervisor.
*/
#define ENABLE_SSE()
#define DISABLE_SSE()
#else /* __xpv */
#endif /* __xpv */
/*
* Try and figure out what kind of FP capabilities we have, and
* set up the control registers accordingly.
*/
void
fpu_probe(void)
{
do {
if (fpu_initial_probe() != 0)
continue;
if (fpu_exists == 0) {
fpu_ignored = 1;
continue;
}
#if defined(__i386)
/*
* The test does some real floating point operations.
* Reset it back to previous state.
*/
(void) fpu_initial_probe();
if (fpu_pentium_fdivbug != 0) {
fpu_ignored = 1;
continue;
}
#endif
#ifndef __xpv
/*
* Check and see if the fpu is present by looking
* at the "extension type" bit. (While this used to
* indicate a 387DX coprocessor in days gone by,
* it's forced on by modern implementations for
* compatibility.)
*/
continue;
#endif
#if defined(__amd64)
/*
* SSE and SSE2 are required for the 64-bit ABI.
*
* If they're not present, we can in principal run
* 32-bit userland, though 64-bit processes will be hosed.
*
* (Perhaps we should complain more about this case!)
*/
ENABLE_SSE();
}
patch_xsave();
}
}
/*
* SSE and SSE2 are both optional, and we patch kernel
* code to exploit it when present.
*/
ENABLE_SSE();
patch_sse2();
}
}
patch_xsave();
} else {
patch_sse(); /* use fxrstor */
}
} else {
/*
* We will not likely to have a chip with AVX but not
* SSE. But to be safe we disable AVX if SSE is not
* enabled.
*/
/*
* (Just in case the BIOS decided we wanted SSE
* enabled when we didn't. See 4965674.)
*/
DISABLE_SSE();
}
#endif
}
/*
* Extract the mxcsr mask from our first fxsave
*/
fx->fx_mxcsr_mask = 0;
if (fx->fx_mxcsr_mask != 0) {
/*
* Override default mask initialized in fpu.c
*/
}
}
return;
/*CONSTANTCONDITION*/
} while (0);
/*
* No FPU hardware present
*/
DISABLE_SSE();
fpu_exists = 0;
}