Print this page
OS-4368 lxbrand glibc abhors CPUID limits
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/man/man7d/cpuid.7d.man.txt
+++ new/usr/src/man/man7d/cpuid.7d.man.txt
1 1 CPUID(7D) Devices CPUID(7D)
2 2
3 3
4 4
5 5 NAME
6 6 cpuid - CPU identification driver
7 7
8 8 SYNOPSIS
9 9 /dev/cpu/self/cpuid
10 10
11 11
12 12 DESCRIPTION
13 13 SPARC and x86 system
14 14 This device provides implementation-private information via ioctls
15 15 about various aspects of the implementation to Solaris libraries and
16 16 utilities.
17 17
18 18 x86 systems only
19 19 This device also provides a file-like view of the namespace and return
20 20 values of the x86 cpuid instruction. The cpuid instruction takes a
21 21 single 32-bit integer function code, and returns four 32-bit integer
22 22 values corresponding to the input value that describe various aspects
23 23 of the capabilities and configuration of the processor.
24 24
25 25 The API for the character device consists of using the seek offset to
26 26 set the function code value, and using a read(2) or pread(2) of 16
27 27 bytes to fetch the four 32-bit return values of the instruction in the
28 28 order %eax, %ebx, %ecx and %edx.
29 29
30 30 No data can be written to the device. Like the cpuid instruction, no
31 31 special privileges are required to use the device.
32 32
33 33 The device is useful to enable low-level configuration information to
|
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
34 34 be extracted from the CPU without having to write any assembler code to
35 35 invoke the cpuid instruction directly. It also allows the kernel to
36 36 attempt to correct any erroneous data returned by the instruction
37 37 (prompted by occasional errors in the information exported by various
38 38 processor implementations over the years).
39 39
40 40 See the processor manufacturers documentation for further information
41 41 about the syntax and semantics of the wide variety of information
42 42 available from this instruction.
43 43
44 + Some systems can be configured to limit the cpuid opcodes which are
45 + accessible. While illumos handles this condition, other software may
46 + malfunction when such limits are enabled. Those settings are typically
47 + manipulated in the BIOS.
48 +
44 49 EXAMPLE
45 50 This example allows you to determine if the current x86 processor
46 51 supports "long mode," which is a necessary (but not sufficient)
47 52 condition for running the 64-bit Solaris kernel on the processor.
48 53
49 54 /*
50 55
51 56 #include <sys/types.h>
52 57 #include <sys/stat.h>
53 58 #include <fcntl.h>
54 59 #include <unistd.h>
55 60 #include <string.h>
56 61 #include <errno.h>
57 62 #include <stdio.h>
58 63
59 64 static const char devname[] = "/dev/cpu/self/cpuid";
60 65
61 66 /*ARGSUSED*/
62 67 int
63 68 main(int argc, char *argv[])
64 69 {
65 70 struct {
66 71 uint32_t r_eax, r_ebx, r_ecx, r_edx;
67 72 } _r, *rp = &_r;
68 73 int d;
69 74 char *s;
70 75
71 76 if ((d = open(devname, O_RDONLY)) == -1) {
72 77 perror(devname);
73 78 return (1);
74 79 }
75 80
76 81 if (pread(d, rp, sizeof (*rp), 0) != sizeof (*rp)) {
77 82 perror(devname);
78 83 goto fail;
79 84 }
80 85
81 86 s = (char *)&rp->r_ebx;
82 87 if (strncmp(s, "Auth" "cAMD" "enti", 12) != 0 &&
83 88 strncmp(s, "Genu" "ntel" "ineI", 12) != 0)
84 89 goto fail;
85 90
86 91 if (pread(d, rp, sizeof (*rp), 0x80000001) == sizeof (*rp)) {
87 92 /*
88 93 * Read extended feature word; check bit 29
89 94 */
90 95 (void) close(d);
91 96 if ((rp->r_edx >> 29) & 1) {
92 97 (void) printf("processor supports long mode\n");
93 98 return (0);
94 99 }
95 100 }
96 101 fail:
97 102 (void) close(d);
98 103 return (1);
99 104 }
100 105
101 106
102 107 ERRORS
103 108 ENXIO
104 109 Results from attempting to read data from the device on a
105 110 system that does not support the CPU identification
106 111 interfaces
107 112
108 113
109 114 EINVAL
110 115 Results from reading from an offset larger than UINT_MAX, or
111 116 attempting to read with a size that is not multiple of 16
112 117 bytes.
113 118
114 119
115 120 FILES
116 121 /dev/cpu/self/cpuid
117 122 Provides access to CPU identification data.
118 123
119 124
120 125 ATTRIBUTES
121 126 See attributes(5) for descriptions of the following attributes:
122 127
123 128
124 129
125 130
126 131 +--------------------+-----------------+
127 132 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
128 133 +--------------------+-----------------+
129 134 |Interface Stability | Evolving |
130 135 +--------------------+-----------------+
131 136
132 137 SEE ALSO
133 138 psrinfo(1M), prtconf(1M), pread(2), read(2), attributes(5)
134 139
135 140
136 141
137 142 April 9, 2016 CPUID(7D)
|
↓ open down ↓ |
84 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX