From 52522202a7beb6f9795b0e95b9510e2c365f6b76 Mon Sep 17 00:00:00 2001 From: guenther Date: Sun, 7 Jan 2018 18:54:44 +0000 Subject: [PATCH] amd64_{get,set}_fsbase() are superfluous and unused; delete them. Delete unused/never-implemented sysarch defines and structs while here. ports check and ok naddy@ ok deraadt@ mlarkin@ --- lib/libarch/amd64/Makefile | 6 +- lib/libarch/amd64/amd64_get_fsbase.2 | 97 ---------------------------- lib/libarch/amd64/amd64_get_fsbase.c | 42 ------------ lib/libarch/amd64/amd64_set_fsbase.c | 42 ------------ sys/arch/amd64/amd64/sys_machdep.c | 52 +-------------- sys/arch/amd64/include/sysarch.h | 51 +-------------- 6 files changed, 5 insertions(+), 285 deletions(-) delete mode 100644 lib/libarch/amd64/amd64_get_fsbase.2 delete mode 100644 lib/libarch/amd64/amd64_get_fsbase.c delete mode 100644 lib/libarch/amd64/amd64_set_fsbase.c diff --git a/lib/libarch/amd64/Makefile b/lib/libarch/amd64/Makefile index 1e8a5286818..8e376acfccc 100644 --- a/lib/libarch/amd64/Makefile +++ b/lib/libarch/amd64/Makefile @@ -1,13 +1,13 @@ -# $OpenBSD: Makefile,v 1.13 2016/03/30 06:38:41 jmc Exp $ +# $OpenBSD: Makefile,v 1.14 2018/01/07 18:54:44 guenther Exp $ # $NetBSD: Makefile,v 1.1 1996/02/21 02:45:47 jtk Exp $ MANSUBDIR=amd64 -MAN+= amd64_iopl.2 amd64_get_fsbase.2 +MAN+= amd64_iopl.2 .if ${MACHINE_ARCH} == "amd64" .PATH: ${LIBC}/amd64 NOPIC= -SRCS+= amd64_iopl.c amd64_get_fsbase.c amd64_set_fsbase.c +SRCS+= amd64_iopl.c .include .else NOPROG= diff --git a/lib/libarch/amd64/amd64_get_fsbase.2 b/lib/libarch/amd64/amd64_get_fsbase.2 deleted file mode 100644 index 12a275dc501..00000000000 --- a/lib/libarch/amd64/amd64_get_fsbase.2 +++ /dev/null @@ -1,97 +0,0 @@ -.\" $OpenBSD: amd64_get_fsbase.2,v 1.5 2016/03/30 06:58:06 jmc Exp $ -.\" $NetBSD: i386_get_ioperm.2,v 1.3 1996/02/27 22:57:17 jtc Exp $ -.\" -.\" Copyright (c) 1996 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by John T. Kohl and Charles M. Hannum. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd $Mdocdate: March 30 2016 $ -.Dt AMD64_GET_FSBASE 2 amd64 -.Os -.Sh NAME -.Nm amd64_get_fsbase , -.Nm amd64_set_fsbase -.Nd manage amd64 per-thread %fs base address -.Sh SYNOPSIS -.In sys/types.h -.In machine/sysarch.h -.Ft int -.Fn amd64_get_fsbase "void **base" -.Ft int -.Fn amd64_set_fsbase "void *base" -.Sh DESCRIPTION -.Fn amd64_get_fsbase -copies the current base address of the %fs segment into the memory -referenced by -.Fa base . -.Pp -.Fn amd64_set_fsbase -sets the base address of the %fs segment to the address -.Fa base . -.Pp -The segment base address is local to each thread. -The initial thread of a new process inherits its segment base address -from the parent thread. -.Xr __tfork 3 -sets the initial segment base address for threads that it creates. -.Pp -.Sy Note: -Code using the -.Fn amd64_get_fsbase -and -.Fn amd64_set_fsbase -functions must be compiled using -.Cm -lamd64 . -.Sh RETURN VALUES -Upon successful completion, -.Fn amd64_get_fsbase -and -.Fn amd64_set_fsbase -return 0. -Otherwise, a value of \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn amd64_get_fsbase -will fail if: -.Bl -tag -width [EINVAL] -.It Bq Er EFAULT -.Fa base -points outside the process's allocated address space. -.El -.Sh SEE ALSO -.Xr fork 2 , -.Xr __tfork 3 -.Sh WARNING -The ELF Thread-Local Storage ABI reserves %fs for its own use and -requires that the dynamic linker and thread library set it to -reference data-structures internal to and shared between them. -Programs should use the __thread storage class keyword instead of -using these calls. -To be maximally portable, -programs that require per-thread data should use the -.Fn pthread_key_create -interface. diff --git a/lib/libarch/amd64/amd64_get_fsbase.c b/lib/libarch/amd64/amd64_get_fsbase.c deleted file mode 100644 index 60d278c4965..00000000000 --- a/lib/libarch/amd64/amd64_get_fsbase.c +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: amd64_get_fsbase.c,v 1.2 2012/12/05 23:19:58 deraadt Exp $ */ -/* $NetBSD: i386_get_ioperm.c,v 1.2 1996/02/27 22:57:22 jtc Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by John T. Kohl and Charles M. Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include -#include - -int -amd64_get_fsbase(void **base) -{ - return sysarch(AMD64_GET_FSBASE, base); -} diff --git a/lib/libarch/amd64/amd64_set_fsbase.c b/lib/libarch/amd64/amd64_set_fsbase.c deleted file mode 100644 index 7d4fac8f19a..00000000000 --- a/lib/libarch/amd64/amd64_set_fsbase.c +++ /dev/null @@ -1,42 +0,0 @@ -/* $OpenBSD: amd64_set_fsbase.c,v 1.2 2012/12/05 23:19:58 deraadt Exp $ */ -/* $NetBSD: i386_set_ioperm.c,v 1.2 1996/02/27 22:57:31 jtc Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by John T. Kohl and Charles M. Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include -#include - -int -amd64_set_fsbase(void *base) -{ - return sysarch(AMD64_SET_FSBASE, &base); -} diff --git a/sys/arch/amd64/amd64/sys_machdep.c b/sys/arch/amd64/amd64/sys_machdep.c index 249fd466689..aa28fba509c 100644 --- a/sys/arch/amd64/amd64/sys_machdep.c +++ b/sys/arch/amd64/amd64/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.18 2017/10/14 04:44:43 jsg Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.19 2018/01/07 18:54:44 guenther Exp $ */ /* $NetBSD: sys_machdep.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */ /*- @@ -39,11 +39,6 @@ #include #include -#include - -#if defined(PERFCTRS) && 0 -#include -#endif extern struct vm_map *kernel_map; @@ -82,29 +77,6 @@ amd64_iopl(struct proc *p, void *args, register_t *retval) return 0; } -int -amd64_get_fsbase(struct proc *p, void *args) -{ - void *base = tcb_get(p); - - return (copyout(&base, args, sizeof(base))); -} - -int -amd64_set_fsbase(struct proc *p, void *args) -{ - int error; - void *base; - - if ((error = copyin(args, &base, sizeof(base))) != 0) - return (error); - - if (TCB_INVALID(base)) - return EINVAL; - tcb_set(p, base); - return 0; -} - int sys_sysarch(struct proc *p, void *v, register_t *retval) { @@ -119,28 +91,6 @@ sys_sysarch(struct proc *p, void *v, register_t *retval) error = amd64_iopl(p, SCARG(uap, parms), retval); break; -#if defined(PERFCTRS) && 0 - case AMD64_PMC_INFO: - error = pmc_info(p, SCARG(uap, parms), retval); - break; - - case AMD64_PMC_STARTSTOP: - error = pmc_startstop(p, SCARG(uap, parms), retval); - break; - - case AMD64_PMC_READ: - error = pmc_read(p, SCARG(uap, parms), retval); - break; -#endif - - case AMD64_GET_FSBASE: - error = amd64_get_fsbase(p, SCARG(uap, parms)); - break; - - case AMD64_SET_FSBASE: - error = amd64_set_fsbase(p, SCARG(uap, parms)); - break; - default: error = EINVAL; break; diff --git a/sys/arch/amd64/include/sysarch.h b/sys/arch/amd64/include/sysarch.h index e139fc763b4..d59506441de 100644 --- a/sys/arch/amd64/include/sysarch.h +++ b/sys/arch/amd64/include/sysarch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysarch.h,v 1.13 2013/05/05 19:25:57 tedu Exp $ */ +/* $OpenBSD: sysarch.h,v 1.14 2018/01/07 18:54:44 guenther Exp $ */ /* $NetBSD: sysarch.h,v 1.1 2003/04/26 18:39:48 fvdl Exp $ */ #ifndef _MACHINE_SYSARCH_H_ @@ -8,68 +8,19 @@ * Architecture specific syscalls (amd64) */ #define AMD64_IOPL 2 -#define AMD64_GET_IOPERM 3 -#define AMD64_SET_IOPERM 4 -#define AMD64_VM86 5 -#define AMD64_PMC_INFO 8 -#define AMD64_PMC_STARTSTOP 9 -#define AMD64_PMC_READ 10 -#define AMD64_GET_FSBASE 11 -#define AMD64_SET_FSBASE 12 struct amd64_iopl_args { int iopl; }; -struct amd64_pmc_info_args { - int type; - int flags; -}; - -#define PMC_TYPE_NONE 0 -#define PMC_TYPE_I586 1 -#define PMC_TYPE_I686 2 - -#define PMC_INFO_HASTSC 0x01 - -#define PMC_NCOUNTERS 2 - -struct amd64_pmc_startstop_args { - int counter; - u_int64_t val; - u_int8_t event; - u_int8_t unit; - u_int8_t compare; - u_int8_t flags; -}; - -#define PMC_SETUP_KERNEL 0x01 -#define PMC_SETUP_USER 0x02 -#define PMC_SETUP_EDGE 0x04 -#define PMC_SETUP_INV 0x08 - -struct amd64_pmc_read_args { - int counter; - u_int64_t val; - u_int64_t time; -}; - - #ifdef _KERNEL int amd64_iopl(struct proc *, void *, register_t *); -int amd64_set_fsbase(struct proc *, void *); -int amd64_get_fsbase(struct proc *, void *); #else #include __BEGIN_DECLS int amd64_iopl(int); -int amd64_pmc_info(struct amd64_pmc_info_args *); -int amd64_pmc_startstop(struct amd64_pmc_startstop_args *); -int amd64_pmc_read(struct amd64_pmc_read_args *); -int amd64_set_fsbase(void *); -int amd64_get_fsbase(void **); int sysarch(int, void *); __END_DECLS #endif -- 2.20.1