~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/um/bugs_32.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3  * Licensed under the GPL
  4  */
  5 
  6 #include <arch.h>
  7 #include <signal.h>
  8 #include <kern_util.h>
  9 #include <longjmp.h>
 10 #include <sysdep/ptrace.h>
 11 #include <generated/asm-offsets.h>
 12 
 13 /* Set during early boot */
 14 static int host_has_cmov = 1;
 15 static jmp_buf cmov_test_return;
 16 
 17 static void cmov_sigill_test_handler(int sig)
 18 {
 19         host_has_cmov = 0;
 20         longjmp(cmov_test_return, 1);
 21 }
 22 
 23 void arch_check_bugs(void)
 24 {
 25         struct sigaction old, new;
 26 
 27         printk(UM_KERN_INFO "Checking for host processor cmov support...");
 28         new.sa_handler = cmov_sigill_test_handler;
 29 
 30         /* Make sure that SIGILL is enabled after the handler longjmps back */
 31         new.sa_flags = SA_NODEFER;
 32         sigemptyset(&new.sa_mask);
 33         sigaction(SIGILL, &new, &old);
 34 
 35         if (setjmp(cmov_test_return) == 0) {
 36                 unsigned long foo = 0;
 37                 __asm__ __volatile__("cmovz %0, %1" : "=r" (foo) : "" (foo));
 38                 printk(UM_KERN_CONT "Yes\n");
 39         } else
 40                 printk(UM_KERN_CONT "No\n");
 41 
 42         sigaction(SIGILL, &old, &new);
 43 }
 44 
 45 void arch_examine_signal(int sig, struct uml_pt_regs *regs)
 46 {
 47         unsigned char tmp[2];
 48 
 49         /*
 50          * This is testing for a cmov (0x0f 0x4x) instruction causing a
 51          * SIGILL in init.
 52          */
 53         if ((sig != SIGILL) || (get_current_pid() != 1))
 54                 return;
 55 
 56         if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2)) {
 57                 printk(UM_KERN_ERR "SIGILL in init, could not read "
 58                        "instructions!\n");
 59                 return;
 60         }
 61 
 62         if ((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
 63                 return;
 64 
 65         if (host_has_cmov == 0)
 66                 printk(UM_KERN_ERR "SIGILL caused by cmov, which this "
 67                        "processor doesn't implement.  Boot a filesystem "
 68                        "compiled for older processors");
 69         else if (host_has_cmov == 1)
 70                 printk(UM_KERN_ERR "SIGILL caused by cmov, which this "
 71                        "processor claims to implement");
 72         else
 73                 printk(UM_KERN_ERR "Bad value for host_has_cmov (%d)",
 74                         host_has_cmov);
 75 }
 76 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php