diff options
Diffstat (limited to 'arch/um/sys-i386/bugs.c')
-rw-r--r-- | arch/um/sys-i386/bugs.c | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/arch/um/sys-i386/bugs.c b/arch/um/sys-i386/bugs.c index 797945cd3df2..fc991184850c 100644 --- a/arch/um/sys-i386/bugs.c +++ b/arch/um/sys-i386/bugs.c | |||
@@ -12,8 +12,6 @@ | |||
12 | #include "user.h" | 12 | #include "user.h" |
13 | #include "sysdep/archsetjmp.h" | 13 | #include "sysdep/archsetjmp.h" |
14 | 14 | ||
15 | #define MAXTOKEN 64 | ||
16 | |||
17 | /* Set during early boot */ | 15 | /* Set during early boot */ |
18 | int host_has_cmov = 1; | 16 | int host_has_cmov = 1; |
19 | static jmp_buf cmov_test_return; | 17 | static jmp_buf cmov_test_return; |
@@ -46,139 +44,8 @@ static void test_for_host_cmov(void) | |||
46 | sigaction(SIGILL, &old, &new); | 44 | sigaction(SIGILL, &old, &new); |
47 | } | 45 | } |
48 | 46 | ||
49 | static char token(int fd, char *buf, int len, char stop) | ||
50 | { | ||
51 | int n; | ||
52 | char *ptr, *end, c; | ||
53 | |||
54 | ptr = buf; | ||
55 | end = &buf[len]; | ||
56 | do { | ||
57 | n = os_read_file(fd, ptr, sizeof(*ptr)); | ||
58 | c = *ptr++; | ||
59 | if (n != sizeof(*ptr)) { | ||
60 | if (n == 0) | ||
61 | return 0; | ||
62 | printk(UM_KERN_ERR "Reading /proc/cpuinfo failed, " | ||
63 | "err = %d\n", -n); | ||
64 | if (n < 0) | ||
65 | return n; | ||
66 | else return -EIO; | ||
67 | } | ||
68 | } while ((c != '\n') && (c != stop) && (ptr < end)); | ||
69 | |||
70 | if (ptr == end) { | ||
71 | printk(UM_KERN_ERR "Failed to find '%c' in /proc/cpuinfo\n", | ||
72 | stop); | ||
73 | return -1; | ||
74 | } | ||
75 | *(ptr - 1) = '\0'; | ||
76 | return c; | ||
77 | } | ||
78 | |||
79 | static int find_cpuinfo_line(int fd, char *key, char *scratch, int len) | ||
80 | { | ||
81 | int n; | ||
82 | char c; | ||
83 | |||
84 | scratch[len - 1] = '\0'; | ||
85 | while (1) { | ||
86 | c = token(fd, scratch, len - 1, ':'); | ||
87 | if (c <= 0) | ||
88 | return 0; | ||
89 | else if (c != ':') { | ||
90 | printk(UM_KERN_ERR "Failed to find ':' in " | ||
91 | "/proc/cpuinfo\n"); | ||
92 | return 0; | ||
93 | } | ||
94 | |||
95 | if (!strncmp(scratch, key, strlen(key))) | ||
96 | return 1; | ||
97 | |||
98 | do { | ||
99 | n = os_read_file(fd, &c, sizeof(c)); | ||
100 | if (n != sizeof(c)) { | ||
101 | printk(UM_KERN_ERR "Failed to find newline in " | ||
102 | "/proc/cpuinfo, err = %d\n", -n); | ||
103 | return 0; | ||
104 | } | ||
105 | } while (c != '\n'); | ||
106 | } | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static int check_cpu_flag(char *feature, int *have_it) | ||
111 | { | ||
112 | char buf[MAXTOKEN], c; | ||
113 | int fd, len = ARRAY_SIZE(buf); | ||
114 | |||
115 | printk(UM_KERN_INFO "Checking for host processor %s support...", | ||
116 | feature); | ||
117 | fd = os_open_file("/proc/cpuinfo", of_read(OPENFLAGS()), 0); | ||
118 | if (fd < 0) { | ||
119 | printk(UM_KERN_ERR "Couldn't open /proc/cpuinfo, err = %d\n", | ||
120 | -fd); | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | *have_it = 0; | ||
125 | if (!find_cpuinfo_line(fd, "flags", buf, ARRAY_SIZE(buf))) | ||
126 | goto out; | ||
127 | |||
128 | c = token(fd, buf, len - 1, ' '); | ||
129 | if (c < 0) | ||
130 | goto out; | ||
131 | else if (c != ' ') { | ||
132 | printk(UM_KERN_ERR "Failed to find ' ' in /proc/cpuinfo\n"); | ||
133 | goto out; | ||
134 | } | ||
135 | |||
136 | while (1) { | ||
137 | c = token(fd, buf, len - 1, ' '); | ||
138 | if (c < 0) | ||
139 | goto out; | ||
140 | else if (c == '\n') | ||
141 | break; | ||
142 | |||
143 | if (!strcmp(buf, feature)) { | ||
144 | *have_it = 1; | ||
145 | goto out; | ||
146 | } | ||
147 | } | ||
148 | out: | ||
149 | if (*have_it == 0) | ||
150 | printk("No\n"); | ||
151 | else if (*have_it == 1) | ||
152 | printk("Yes\n"); | ||
153 | os_close_file(fd); | ||
154 | return 1; | ||
155 | } | ||
156 | |||
157 | #if 0 /* | ||
158 | * This doesn't work in tt mode, plus it's causing compilation problems | ||
159 | * for some people. | ||
160 | */ | ||
161 | static void disable_lcall(void) | ||
162 | { | ||
163 | struct modify_ldt_ldt_s ldt; | ||
164 | int err; | ||
165 | |||
166 | bzero(&ldt, sizeof(ldt)); | ||
167 | ldt.entry_number = 7; | ||
168 | ldt.base_addr = 0; | ||
169 | ldt.limit = 0; | ||
170 | err = modify_ldt(1, &ldt, sizeof(ldt)); | ||
171 | if (err) | ||
172 | printk(UM_KERN_ERR "Failed to disable lcall7 - errno = %d\n", | ||
173 | errno); | ||
174 | } | ||
175 | #endif | ||
176 | |||
177 | void arch_init_thread(void) | 47 | void arch_init_thread(void) |
178 | { | 48 | { |
179 | #if 0 | ||
180 | disable_lcall(); | ||
181 | #endif | ||
182 | } | 49 | } |
183 | 50 | ||
184 | void arch_check_bugs(void) | 51 | void arch_check_bugs(void) |
@@ -209,10 +76,6 @@ int arch_handle_signal(int sig, struct uml_pt_regs *regs) | |||
209 | else if (host_has_cmov == 1) | 76 | else if (host_has_cmov == 1) |
210 | panic("SIGILL caused by cmov, which this processor claims to " | 77 | panic("SIGILL caused by cmov, which this processor claims to " |
211 | "implement"); | 78 | "implement"); |
212 | else if (host_has_cmov == -1) | ||
213 | panic("SIGILL caused by cmov, couldn't tell if this processor " | ||
214 | "implements it, boot a filesystem compiled for older " | ||
215 | "processors"); | ||
216 | else panic("Bad value for host_has_cmov (%d)", host_has_cmov); | 79 | else panic("Bad value for host_has_cmov (%d)", host_has_cmov); |
217 | return 0; | 80 | return 0; |
218 | } | 81 | } |