2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
10 #include <sys/signal.h>
11 #include "kern_util.h"
13 #include "sysdep/ptrace.h"
18 /* Set during early boot */
22 static char token(int fd, char *buf, int len, char stop)
30 n = read(fd, ptr, sizeof(*ptr));
33 else if(n != sizeof(*ptr)){
34 printk("Reading /proc/cpuinfo failed, "
35 "errno = %d\n", errno);
38 } while((c != '\n') && (c != stop) && (ptr < end));
41 printk("Failed to find '%c' in /proc/cpuinfo\n", stop);
48 static int check_cpu_feature(char *feature, int *have_it)
50 char buf[MAXTOKEN], c;
51 int fd, len = sizeof(buf)/sizeof(buf[0]), n;
53 printk("Checking for host processor %s support...", feature);
54 fd = open("/proc/cpuinfo", O_RDONLY);
56 printk("Couldn't open /proc/cpuinfo, errno = %d\n", errno);
63 c = token(fd, buf, len - 1, ':');
66 printk("Failed to find ':' in /proc/cpuinfo\n");
70 if(!strncmp(buf, "flags", strlen("flags"))) break;
73 n = read(fd, &c, sizeof(c));
75 printk("Failed to find newline in "
76 "/proc/cpuinfo, n = %d, errno = %d\n",
83 c = token(fd, buf, len - 1, ' ');
86 printk("Failed to find ':' in /proc/cpuinfo\n");
91 c = token(fd, buf, len - 1, ' ');
93 else if(c == '\n') break;
95 if(!strcmp(buf, feature)){
101 if(*have_it == 0) printk("No\n");
102 else if(*have_it == 1) printk("Yes\n");
107 void arch_check_bugs(void)
111 if(access("/proc/cpuinfo", R_OK)){
112 printk("/proc/cpuinfo not available - skipping CPU capability "
116 if(check_cpu_feature("cmov", &have_it)) cpu_has_cmov = have_it;
117 if(check_cpu_feature("xmm", &have_it)) cpu_has_xmm = have_it;
120 int arch_handle_signal(int sig, union uml_pt_regs *regs)
124 /* This is testing for a cmov (0x0f 0x4x) instruction causing a
127 if((sig != SIGILL) || (TASK_PID(get_current()) != 1)) return(0);
130 if((*((char *) ip) != 0x0f) || ((*((char *) (ip + 1)) & 0xf0) != 0x40))
133 if(cpu_has_cmov == 0)
134 panic("SIGILL caused by cmov, which this processor doesn't "
135 "implement, boot a filesystem compiled for older "
137 else if(cpu_has_cmov == 1)
138 panic("SIGILL caused by cmov, which this processor claims to "
140 else if(cpu_has_cmov == -1)
141 panic("SIGILL caused by cmov, couldn't tell if this processor "
142 "implements it, boot a filesystem compiled for older "
144 else panic("Bad value for cpu_has_cmov (%d)", cpu_has_cmov);
149 * Overrides for Emacs so that we follow Linus's tabbing style.
150 * Emacs will notice this stuff at the end of the file and automatically
151 * adjust the settings for this buffer only. This must remain at the end
153 * ---------------------------------------------------------------------------
155 * c-file-style: "linux"