Print this page
OS-4368 lxbrand glibc abhors CPUID limits
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/man/man7d/cpuid.7d
+++ new/usr/src/man/man7d/cpuid.7d
1 1 '\" te
2 2 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
3 +.\" Copyright 2015, Joyent, Inc.
3 4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 7 .TH CPUID 7D "April 9, 2016"
7 8 .SH NAME
8 9 cpuid \- CPU identification driver
9 10 .SH SYNOPSIS
10 11 .LP
11 12 .nf
12 13 \fB/dev/cpu/self/cpuid\fR
13 14 .fi
14 15
15 16 .SH DESCRIPTION
16 17 .SS "SPARC and x86 system"
17 18 .LP
18 19 This device provides implementation-private information via ioctls about
19 20 various aspects of the implementation to Solaris libraries and utilities.
20 21 .SS "x86 systems only"
21 22 .LP
22 23 This device also provides a file-like view of the namespace and return values
23 24 of the x86 cpuid instruction. The cpuid instruction takes a single 32-bit
24 25 integer function code, and returns four 32-bit integer values corresponding to
25 26 the input value that describe various aspects of the capabilities and
26 27 configuration of the processor.
27 28 .LP
28 29 The API for the character device consists of using the seek offset to set the
29 30 function code value, and using a \fBread\fR(2) or \fBpread\fR(2) of 16 bytes to
30 31 fetch the four 32-bit return values of the instruction in the order %\fBeax\fR,
31 32 %\fBebx\fR, %\fBecx\fR and %\fBedx\fR.
32 33 .LP
33 34 No data can be written to the device. Like the \fBcpuid\fR instruction, no
34 35 special privileges are required to use the device.
35 36 .LP
|
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
36 37 The device is useful to enable low-level configuration information to be
37 38 extracted from the CPU without having to write any assembler code to invoke the
38 39 \fBcpuid\fR instruction directly. It also allows the kernel to attempt to
39 40 correct any erroneous data returned by the instruction (prompted by occasional
40 41 errors in the information exported by various processor implementations over
41 42 the years).
42 43 .LP
43 44 See the processor manufacturers documentation for further information about the
44 45 syntax and semantics of the wide variety of information available from this
45 46 instruction.
47 +.LP
48 +Some systems can be configured to limit the cpuid opcodes which are accessible.
49 +While illumos handles this condition, other software may malfunction when such
50 +limits are enabled. Those settings are typically manipulated in the BIOS.
46 51 .SH EXAMPLE
47 52 .LP
48 53 This example allows you to determine if the current x86 processor supports
49 54 "long mode," which is a necessary (but not sufficient) condition for running
50 55 the 64-bit Solaris kernel on the processor.
51 56 .sp
52 57 .in +2
53 58 .nf
54 59 /*
55 60
56 61 #include <sys/types.h>
57 62 #include <sys/stat.h>
58 63 #include <fcntl.h>
59 64 #include <unistd.h>
60 65 #include <string.h>
61 66 #include <errno.h>
62 67 #include <stdio.h>
63 68
64 69 static const char devname[] = "/dev/cpu/self/cpuid";
65 70
66 71 /*ARGSUSED*/
67 72 int
68 73 main(int argc, char *argv[])
69 74 {
70 75 struct {
71 76 uint32_t r_eax, r_ebx, r_ecx, r_edx;
72 77 } _r, *rp = &_r;
73 78 int d;
74 79 char *s;
75 80
76 81 if ((d = open(devname, O_RDONLY)) == -1) {
77 82 perror(devname);
78 83 return (1);
79 84 }
80 85
81 86 if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) {
82 87 perror(devname);
83 88 goto fail;
84 89 }
85 90
86 91 s = (char *)&rp->r_ebx;
87 92 if (strncmp(s, "Auth" "cAMD" "enti", 12) != 0 &&
88 93 strncmp(s, "Genu" "ntel" "ineI", 12) != 0)
89 94 goto fail;
90 95
91 96 if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) {
92 97 /*
93 98 * Read extended feature word; check bit 29
94 99 */
95 100 (void) close(d);
96 101 if ((rp->r_edx >> 29) & 1) {
97 102 (void) printf("processor supports long mode\en");
98 103 return (0);
99 104 }
100 105 }
101 106 fail:
102 107 (void) close(d);
103 108 return (1);
104 109 }
105 110 .fi
106 111 .in -2
107 112
108 113 .SH ERRORS
109 114 .ne 2
110 115 .na
111 116 \fBENXIO\fR
112 117 .ad
113 118 .RS 10n
114 119 Results from attempting to read data from the device on a system that does not
115 120 support the CPU identification interfaces
116 121 .RE
117 122
118 123 .sp
119 124 .ne 2
120 125 .na
121 126 \fBEINVAL\fR
122 127 .ad
123 128 .RS 10n
124 129 Results from reading from an offset larger than UINT_MAX, or attempting to read
125 130 with a size that is not multiple of 16 bytes.
126 131 .RE
127 132
128 133 .SH FILES
129 134 .ne 2
130 135 .na
131 136 \fB\fB/dev/cpu/self/cpuid\fR\fR
132 137 .ad
133 138 .RS 23n
134 139 Provides access to CPU identification data.
135 140 .RE
136 141
137 142 .SH ATTRIBUTES
138 143 .LP
139 144 See \fBattributes\fR(5) for descriptions of the following attributes:
140 145 .sp
141 146
142 147 .sp
143 148 .TS
144 149 box;
145 150 c | c
146 151 l | l .
147 152 ATTRIBUTE TYPE ATTRIBUTE VALUE
148 153 _
149 154 Interface Stability Evolving
150 155 .TE
151 156
152 157 .SH SEE ALSO
153 158 .LP
154 159 \fBpsrinfo\fR(1M), \fBprtconf\fR(1M), \fBpread\fR(2), \fBread\fR(2),
155 160 \fBattributes\fR(5)
|
↓ open down ↓ |
100 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX