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

TOMOYO Linux Cross Reference
Linux/arch/x86/kernel/cpu/match.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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
  2 #include <asm/cpu_device_id.h>
  3 #include <asm/cpufeature.h>
  4 #include <linux/cpu.h>
  5 #include <linux/export.h>
  6 #include <linux/slab.h>
  7 
  8 /**
  9  * x86_match_cpu - match current CPU again an array of x86_cpu_ids
 10  * @match: Pointer to array of x86_cpu_ids. Last entry terminated with
 11  *         {}.
 12  *
 13  * Return the entry if the current CPU matches the entries in the
 14  * passed x86_cpu_id match table. Otherwise NULL.  The match table
 15  * contains vendor (X86_VENDOR_*), family, model and feature bits or
 16  * respective wildcard entries.
 17  *
 18  * A typical table entry would be to match a specific CPU
 19  *
 20  * X86_MATCH_VFM_FEATURE(INTEL_BROADWELL, X86_FEATURE_ANY, NULL);
 21  *
 22  * Fields can be wildcarded with %X86_VENDOR_ANY, %X86_FAMILY_ANY,
 23  * %X86_MODEL_ANY, %X86_FEATURE_ANY (except for vendor)
 24  *
 25  * asm/cpu_device_id.h contains a set of useful macros which are shortcuts
 26  * for various common selections. The above can be shortened to:
 27  *
 28  * X86_MATCH_VFM(INTEL_BROADWELL, NULL);
 29  *
 30  * Arrays used to match for this should also be declared using
 31  * MODULE_DEVICE_TABLE(x86cpu, ...)
 32  *
 33  * This always matches against the boot cpu, assuming models and features are
 34  * consistent over all CPUs.
 35  */
 36 const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match)
 37 {
 38         const struct x86_cpu_id *m;
 39         struct cpuinfo_x86 *c = &boot_cpu_data;
 40 
 41         for (m = match; m->flags & X86_CPU_ID_FLAG_ENTRY_VALID; m++) {
 42                 if (m->vendor != X86_VENDOR_ANY && c->x86_vendor != m->vendor)
 43                         continue;
 44                 if (m->family != X86_FAMILY_ANY && c->x86 != m->family)
 45                         continue;
 46                 if (m->model != X86_MODEL_ANY && c->x86_model != m->model)
 47                         continue;
 48                 if (m->steppings != X86_STEPPING_ANY &&
 49                     !(BIT(c->x86_stepping) & m->steppings))
 50                         continue;
 51                 if (m->feature != X86_FEATURE_ANY && !cpu_has(c, m->feature))
 52                         continue;
 53                 return m;
 54         }
 55         return NULL;
 56 }
 57 EXPORT_SYMBOL(x86_match_cpu);
 58 
 59 static const struct x86_cpu_desc *
 60 x86_match_cpu_with_stepping(const struct x86_cpu_desc *match)
 61 {
 62         struct cpuinfo_x86 *c = &boot_cpu_data;
 63         const struct x86_cpu_desc *m;
 64 
 65         for (m = match; m->x86_family | m->x86_model; m++) {
 66                 if (c->x86_vendor != m->x86_vendor)
 67                         continue;
 68                 if (c->x86 != m->x86_family)
 69                         continue;
 70                 if (c->x86_model != m->x86_model)
 71                         continue;
 72                 if (c->x86_stepping != m->x86_stepping)
 73                         continue;
 74                 return m;
 75         }
 76         return NULL;
 77 }
 78 
 79 bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table)
 80 {
 81         const struct x86_cpu_desc *res = x86_match_cpu_with_stepping(table);
 82 
 83         if (!res || res->x86_microcode_rev > boot_cpu_data.microcode)
 84                 return false;
 85 
 86         return true;
 87 }
 88 EXPORT_SYMBOL_GPL(x86_cpu_has_min_microcode_rev);
 89 

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