Date: Mon, 19 Nov 2018 05:56:47 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r340608 - stable/12/lib/libc/amd64/sys Message-ID: <201811190556.wAJ5ul0Z006046@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Mon Nov 19 05:56:46 2018 New Revision: 340608 URL: https://svnweb.freebsd.org/changeset/base/340608 Log: MFC r339898: Convert amd64_get/set_fs/gsbase to ifunc. Deleted: stable/12/lib/libc/amd64/sys/amd64_detect_rdfsgsbase.c stable/12/lib/libc/amd64/sys/amd64_detect_rdfsgsbase.h Modified: stable/12/lib/libc/amd64/sys/Makefile.inc stable/12/lib/libc/amd64/sys/amd64_get_fsbase.c stable/12/lib/libc/amd64/sys/amd64_get_gsbase.c stable/12/lib/libc/amd64/sys/amd64_set_fsbase.c stable/12/lib/libc/amd64/sys/amd64_set_gsbase.c Directory Properties: stable/12/ (props changed) Modified: stable/12/lib/libc/amd64/sys/Makefile.inc ============================================================================== --- stable/12/lib/libc/amd64/sys/Makefile.inc Mon Nov 19 05:47:31 2018 (r340607) +++ stable/12/lib/libc/amd64/sys/Makefile.inc Mon Nov 19 05:56:46 2018 (r340608) @@ -2,7 +2,6 @@ # $FreeBSD$ SRCS+= \ - amd64_detect_rdfsgsbase.c \ amd64_get_fsbase.c \ amd64_get_gsbase.c \ amd64_set_fsbase.c \ Modified: stable/12/lib/libc/amd64/sys/amd64_get_fsbase.c ============================================================================== --- stable/12/lib/libc/amd64/sys/amd64_get_fsbase.c Mon Nov 19 05:47:31 2018 (r340607) +++ stable/12/lib/libc/amd64/sys/amd64_get_fsbase.c Mon Nov 19 05:56:46 2018 (r340608) @@ -2,7 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2003 Peter Wemm - * Copyright (c) 2017 The FreeBSD Foundation + * Copyright (c) 2017, 2018 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by Konstantin Belousov @@ -33,18 +33,35 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/types.h> +#define IN_RTLD 1 +#include <sys/param.h> +#undef IN_RTLD #include <machine/cpufunc.h> +#include <machine/specialreg.h> #include <machine/sysarch.h> -#include "amd64_detect_rdfsgsbase.h" +#include <x86/ifunc.h> +#include "libc_private.h" -int -amd64_get_fsbase(void **addr) +static int +amd64_get_fsbase_cpu(void **addr) { - if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) { - *addr = (void *)rdfsbase(); - return (0); - } + *addr = (void *)rdfsbase(); + return (0); +} + +static int +amd64_get_fsbase_syscall(void **addr) +{ + return (sysarch(AMD64_GET_FSBASE, addr)); +} + +DEFINE_UIFUNC(, int, amd64_get_fsbase, (void **), static) +{ + + if (__getosreldate() >= P_OSREL_WRFSBASE && + (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0) + return (amd64_get_fsbase_cpu); + return (amd64_get_fsbase_syscall); } Modified: stable/12/lib/libc/amd64/sys/amd64_get_gsbase.c ============================================================================== --- stable/12/lib/libc/amd64/sys/amd64_get_gsbase.c Mon Nov 19 05:47:31 2018 (r340607) +++ stable/12/lib/libc/amd64/sys/amd64_get_gsbase.c Mon Nov 19 05:56:46 2018 (r340608) @@ -2,7 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2003 Peter Wemm - * Copyright (c) 2017 The FreeBSD Foundation + * Copyright (c) 2017, 2018 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by Konstantin Belousov @@ -33,18 +33,35 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/types.h> +#define IN_RTLD 1 +#include <sys/param.h> +#undef IN_RTLD #include <machine/cpufunc.h> +#include <machine/specialreg.h> #include <machine/sysarch.h> -#include "amd64_detect_rdfsgsbase.h" +#include <x86/ifunc.h> +#include "libc_private.h" -int -amd64_get_gsbase(void **addr) +static int +amd64_get_gsbase_cpu(void **addr) { - if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) { - *addr = (void *)rdgsbase(); - return (0); - } + *addr = (void *)rdgsbase(); + return (0); +} + +static int +amd64_get_gsbase_syscall(void **addr) +{ + return (sysarch(AMD64_GET_GSBASE, addr)); +} + +DEFINE_UIFUNC(, int, amd64_get_gsbase, (void **), static) +{ + + if (__getosreldate() >= P_OSREL_WRFSBASE && + (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0) + return (amd64_get_gsbase_cpu); + return (amd64_get_gsbase_syscall); } Modified: stable/12/lib/libc/amd64/sys/amd64_set_fsbase.c ============================================================================== --- stable/12/lib/libc/amd64/sys/amd64_set_fsbase.c Mon Nov 19 05:47:31 2018 (r340607) +++ stable/12/lib/libc/amd64/sys/amd64_set_fsbase.c Mon Nov 19 05:56:46 2018 (r340608) @@ -2,7 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2003 Peter Wemm - * Copyright (c) 2017 The FreeBSD Foundation + * Copyright (c) 2017, 2018 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by Konstantin Belousov @@ -33,18 +33,35 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/types.h> +#define IN_RTLD 1 +#include <sys/param.h> +#undef IN_RTLD #include <machine/cpufunc.h> +#include <machine/specialreg.h> #include <machine/sysarch.h> -#include "amd64_detect_rdfsgsbase.h" +#include <x86/ifunc.h> +#include "libc_private.h" -int -amd64_set_fsbase(void *addr) +static int +amd64_set_fsbase_cpu(void *addr) { - if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) { - wrfsbase((uintptr_t)addr); - return (0); - } + wrfsbase((uintptr_t)addr); + return (0); +} + +static int +amd64_set_fsbase_syscall(void *addr) +{ + return (sysarch(AMD64_SET_FSBASE, &addr)); +} + +DEFINE_UIFUNC(, int, amd64_set_fsbase, (void *), static) +{ + + if (__getosreldate() >= P_OSREL_WRFSBASE && + (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0) + return (amd64_set_fsbase_cpu); + return (amd64_set_fsbase_syscall); } Modified: stable/12/lib/libc/amd64/sys/amd64_set_gsbase.c ============================================================================== --- stable/12/lib/libc/amd64/sys/amd64_set_gsbase.c Mon Nov 19 05:47:31 2018 (r340607) +++ stable/12/lib/libc/amd64/sys/amd64_set_gsbase.c Mon Nov 19 05:56:46 2018 (r340608) @@ -2,7 +2,7 @@ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD * * Copyright (c) 2003 Peter Wemm - * Copyright (c) 2017 The FreeBSD Foundation + * Copyright (c) 2017, 2018 The FreeBSD Foundation * All rights reserved. * * Portions of this software were developed by Konstantin Belousov @@ -33,18 +33,35 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <sys/types.h> +#define IN_RTLD 1 +#include <sys/param.h> +#undef IN_RTLD #include <machine/cpufunc.h> +#include <machine/specialreg.h> #include <machine/sysarch.h> -#include "amd64_detect_rdfsgsbase.h" +#include <x86/ifunc.h> +#include "libc_private.h" -int -amd64_set_gsbase(void *addr) +static int +amd64_set_gsbase_cpu(void *addr) { - if (amd64_detect_rdfsgsbase() == RDFSGS_SUPPORTED) { - wrgsbase((uintptr_t)addr); - return (0); - } + wrgsbase((uintptr_t)addr); + return (0); +} + +static int +amd64_set_gsbase_syscall(void *addr) +{ + return (sysarch(AMD64_SET_GSBASE, &addr)); +} + +DEFINE_UIFUNC(, int, amd64_set_gsbase, (void *), static) +{ + + if (__getosreldate() >= P_OSREL_WRFSBASE && + (cpu_stdext_feature & CPUID_STDEXT_FSGSBASE) != 0) + return (amd64_set_gsbase_cpu); + return (amd64_set_gsbase_syscall); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811190556.wAJ5ul0Z006046>