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

TOMOYO Linux Cross Reference
Linux/arch/x86/boot/cpu.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 // SPDX-License-Identifier: GPL-2.0-only
  2 /* -*- linux-c -*- ------------------------------------------------------- *
  3  *
  4  *   Copyright (C) 1991, 1992 Linus Torvalds
  5  *   Copyright 2007-2008 rPath, Inc. - All Rights Reserved
  6  *
  7  * ----------------------------------------------------------------------- */
  8 
  9 /*
 10  * arch/x86/boot/cpu.c
 11  *
 12  * Check for obligatory CPU features and abort if the features are not
 13  * present.
 14  */
 15 
 16 #include "boot.h"
 17 #include "cpustr.h"
 18 
 19 static char *cpu_name(int level)
 20 {
 21         static char buf[6];
 22 
 23         if (level == 64) {
 24                 return "x86-64";
 25         } else {
 26                 if (level == 15)
 27                         level = 6;
 28                 sprintf(buf, "i%d86", level);
 29                 return buf;
 30         }
 31 }
 32 
 33 static void show_cap_strs(u32 *err_flags)
 34 {
 35         int i, j;
 36         const unsigned char *msg_strs = (const unsigned char *)x86_cap_strs;
 37         for (i = 0; i < NCAPINTS; i++) {
 38                 u32 e = err_flags[i];
 39                 for (j = 0; j < 32; j++) {
 40                         if (msg_strs[0] < i ||
 41                             (msg_strs[0] == i && msg_strs[1] < j)) {
 42                                 /* Skip to the next string */
 43                                 msg_strs += 2;
 44                                 while (*msg_strs++)
 45                                         ;
 46                         }
 47                         if (e & 1) {
 48                                 if (msg_strs[0] == i &&
 49                                     msg_strs[1] == j &&
 50                                     msg_strs[2])
 51                                         printf("%s ", msg_strs+2);
 52                                 else
 53                                         printf("%d:%d ", i, j);
 54                         }
 55                         e >>= 1;
 56                 }
 57         }
 58 }
 59 
 60 int validate_cpu(void)
 61 {
 62         u32 *err_flags;
 63         int cpu_level, req_level;
 64 
 65         check_cpu(&cpu_level, &req_level, &err_flags);
 66 
 67         if (cpu_level < req_level) {
 68                 printf("This kernel requires an %s CPU, ",
 69                        cpu_name(req_level));
 70                 printf("but only detected an %s CPU.\n",
 71                        cpu_name(cpu_level));
 72                 return -1;
 73         }
 74 
 75         if (err_flags) {
 76                 puts("This kernel requires the following features "
 77                      "not present on the CPU:\n");
 78                 show_cap_strs(err_flags);
 79                 putchar('\n');
 80                 return -1;
 81         } else if (check_knl_erratum()) {
 82                 return -1;
 83         } else {
 84                 return 0;
 85         }
 86 }
 87 

~ [ 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