Make fpusave() and fpurestore() on amd64 ifuncs.
From now on, linking amd64 kernel requires either lld or newer ld.bfd. Reviewed by: jhb (as part of the large patch) Discussed with: emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D13838
This commit is contained in:
parent
2f759f25d2
commit
852722fdfd
@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/specialreg.h>
|
#include <machine/specialreg.h>
|
||||||
#include <machine/segments.h>
|
#include <machine/segments.h>
|
||||||
#include <machine/ucontext.h>
|
#include <machine/ucontext.h>
|
||||||
|
#include <x86/ifunc.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Floating point support.
|
* Floating point support.
|
||||||
@ -151,24 +152,58 @@ struct xsave_area_elm_descr {
|
|||||||
u_int size;
|
u_int size;
|
||||||
} *xsave_area_desc;
|
} *xsave_area_desc;
|
||||||
|
|
||||||
void
|
static void
|
||||||
fpusave(void *addr)
|
fpusave_xsave(void *addr)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (use_xsave)
|
|
||||||
xsave((char *)addr, xsave_mask);
|
xsave((char *)addr, xsave_mask);
|
||||||
else
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fpurestore_xrstor(void *addr)
|
||||||
|
{
|
||||||
|
|
||||||
|
xrstor((char *)addr, xsave_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fpusave_fxsave(void *addr)
|
||||||
|
{
|
||||||
|
|
||||||
fxsave((char *)addr);
|
fxsave((char *)addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
fpurestore(void *addr)
|
fpurestore_fxrstor(void *addr)
|
||||||
|
{
|
||||||
|
|
||||||
|
fxrstor((char *)addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_xsave(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (use_xsave)
|
if (use_xsave)
|
||||||
xrstor((char *)addr, xsave_mask);
|
return;
|
||||||
else
|
if ((cpu_feature2 & CPUID2_XSAVE) == 0)
|
||||||
fxrstor((char *)addr);
|
return;
|
||||||
|
use_xsave = 1;
|
||||||
|
TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_IFUNC(, void, fpusave, (void *), static)
|
||||||
|
{
|
||||||
|
|
||||||
|
init_xsave();
|
||||||
|
return (use_xsave ? fpusave_xsave : fpusave_fxsave);
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFINE_IFUNC(, void, fpurestore, (void *), static)
|
||||||
|
{
|
||||||
|
|
||||||
|
init_xsave();
|
||||||
|
return (use_xsave ? fpurestore_xrstor : fpurestore_fxrstor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -207,13 +242,8 @@ fpuinit_bsp1(void)
|
|||||||
uint64_t xsave_mask_user;
|
uint64_t xsave_mask_user;
|
||||||
bool old_wp;
|
bool old_wp;
|
||||||
|
|
||||||
if ((cpu_feature2 & CPUID2_XSAVE) != 0) {
|
|
||||||
use_xsave = 1;
|
|
||||||
TUNABLE_INT_FETCH("hw.use_xsave", &use_xsave);
|
|
||||||
}
|
|
||||||
if (!use_xsave)
|
if (!use_xsave)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cpuid_count(0xd, 0x0, cp);
|
cpuid_count(0xd, 0x0, cp);
|
||||||
xsave_mask = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE;
|
xsave_mask = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE;
|
||||||
if ((cp[0] & xsave_mask) != xsave_mask)
|
if ((cp[0] & xsave_mask) != xsave_mask)
|
||||||
|
Loading…
Reference in New Issue
Block a user