1.\" $OpenBSD: amd64_iopl.2,v 1.8 2015/09/10 17:55:21 schwarze Exp $ 2.\" $NetBSD: amd64_iopl.2,v 1.3 1996/02/27 22:57:25 jtc Exp $ 3.\" 4.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 5.\" All rights reserved. 6.\" 7.\" This code is derived from software contributed to The NetBSD Foundation 8.\" by John T. Kohl and Charles M. Hannum. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE 23.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29.\" POSSIBILITY OF SUCH DAMAGE. 30.\" 31.Dd $Mdocdate: September 10 2015 $ 32.Dt AMD64_IOPL 2 amd64 33.Os 34.Sh NAME 35.Nm amd64_iopl 36.Nd change the amd64 I/O privilege level 37.Sh SYNOPSIS 38.In sys/types.h 39.In machine/sysarch.h 40.Ft int 41.Fn amd64_iopl "int iopl" 42.Sh DESCRIPTION 43.Fn amd64_iopl 44sets the amd64 I/O privilege level to the value specified by 45.Ar iopl . 46.Pp 47This call may only be made by the superuser. 48Additionally, it is only permitted when the 49.Xr securelevel 7 50is less than or equal to 0 or the 51.Va machdep.allowaperture 52sysctl has been set to a non-zero value. 53.Pp 54.Sy Note: 55Code using the 56.Fn amd64_iopl 57function must be compiled using 58.Cm -lamd64 . 59.Sh RETURN VALUES 60Upon successful completion, 61.Fn amd64_iopl 62returns 0. 63Otherwise, a value of \-1 is returned and the global 64variable 65.Va errno 66is set to indicate the error. 67.Sh ERRORS 68.Fn amd64_iopl 69will fail if: 70.Bl -tag -width [EINVAL] 71.It Bq Er EPERM 72The caller was not the superuser, or the securelevel is greater than zero and 73.Va machdep.allowaperture 74has not been set to a non-zero value. 75.El 76.Sh SEE ALSO 77.Xr securelevel 7 78.Sh REFERENCES 79.Rs 80.%A Intel 81.%T AMD64 Microprocessor Programmer's Reference Manual 82.Re 83.Sh WARNING 84You can really hose your machine if you enable user-level I/O and 85write to hardware ports without care. 86