amd64: assume the kernel supports RDFSBASE and RDGSBASE

There is no need to support pre-12.0 (and thus pre-ino64) kernels in a
15.x libc.

Continue to check if the CPU supports these features before using them
and fall back as required.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D50732
This commit is contained in:
Brooks Davis 2025-08-08 18:15:21 +01:00
parent af261a46af
commit 8d26a9da0c
5 changed files with 5 additions and 26 deletions

View file

@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
#define _WANT_P_OSREL
#include <sys/param.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
@ -41,7 +40,6 @@
static int
amd64_get_fsbase_cpu(void **addr)
{
*addr = (void *)rdfsbase();
return (0);
}
@ -49,15 +47,12 @@ amd64_get_fsbase_cpu(void **addr)
static int
amd64_get_fsbase_syscall(void **addr)
{
return (sysarch(AMD64_GET_FSBASE, addr));
}
DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **))
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
if ((cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_get_fsbase_cpu);
return (amd64_get_fsbase_syscall);
}

View file

@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
#define _WANT_P_OSREL
#include <sys/param.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
@ -41,7 +40,6 @@
static int
amd64_get_gsbase_cpu(void **addr)
{
*addr = (void *)rdgsbase();
return (0);
}
@ -49,15 +47,12 @@ amd64_get_gsbase_cpu(void **addr)
static int
amd64_get_gsbase_syscall(void **addr)
{
return (sysarch(AMD64_GET_GSBASE, addr));
}
DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **))
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
if ((cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_get_gsbase_cpu);
return (amd64_get_gsbase_syscall);
}

View file

@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
#define _WANT_P_OSREL
#include <sys/param.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
@ -41,7 +40,6 @@
static int
amd64_set_fsbase_cpu(void *addr)
{
wrfsbase((uintptr_t)addr);
return (0);
}
@ -49,15 +47,12 @@ amd64_set_fsbase_cpu(void *addr)
static int
amd64_set_fsbase_syscall(void *addr)
{
return (sysarch(AMD64_SET_FSBASE, &addr));
}
DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *))
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
if ((cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_set_fsbase_cpu);
return (amd64_set_fsbase_syscall);
}

View file

@ -30,7 +30,6 @@
* SUCH DAMAGE.
*/
#define _WANT_P_OSREL
#include <sys/param.h>
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
@ -41,7 +40,6 @@
static int
amd64_set_gsbase_cpu(void *addr)
{
wrgsbase((uintptr_t)addr);
return (0);
}
@ -49,15 +47,12 @@ amd64_set_gsbase_cpu(void *addr)
static int
amd64_set_gsbase_syscall(void *addr)
{
return (sysarch(AMD64_SET_GSBASE, &addr));
}
DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *))
{
if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
if ((cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
return (amd64_set_gsbase_cpu);
return (amd64_set_gsbase_syscall);
}

View file

@ -548,8 +548,7 @@ allocate_initial_tls(Obj_Entry *objs)
*/
if (__getosreldate() >= P_OSREL_TLSBASE)
sysarch(AMD64_SET_TLSBASE, &addr);
else if (__getosreldate() >= P_OSREL_WRFSBASE &&
(cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
else if ((cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0)
wrfsbase((uintptr_t)addr);
else
sysarch(AMD64_SET_FSBASE, &addr);