2 * Copyright (c) 1992 Terrence R. Lambert.
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * Copyright (c) 1997 KATO Takenori.
5 * Copyright (c) 2008 The DragonFly Project.
8 * This code is derived from software contributed to Berkeley by
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * from: Id: machdep.c,v 1.193 1996/06/18 01:22:04 bde Exp
44 #include <sys/param.h>
46 #include <sys/eventhandler.h>
47 #include <sys/systm.h>
48 #include <sys/kernel.h>
49 #include <sys/sysctl.h>
50 #include <sys/power.h>
52 #include <machine/asmacros.h>
53 #include <machine/clock.h>
54 #include <machine/cputypes.h>
55 #include <machine/frame.h>
56 #include <machine/segments.h>
57 #include <machine/specialreg.h>
58 #include <machine/md_var.h>
59 #include <machine/npx.h>
61 /* XXX - should be in header file: */
62 void printcpuinfo(void);
63 void identify_cpu(void);
64 void earlysetcpuclass(void);
65 void panicifcpuunsupported(void);
67 static u_int find_cpu_vendor_id(void);
68 static void print_AMD_info(void);
69 static void print_AMD_assoc(int i);
70 static void print_via_padlock_info(void);
71 static void print_xsave_info(void);
74 char machine[] = "x86_64";
75 SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD,
76 machine, 0, "Machine class");
78 static char cpu_model[128];
79 SYSCTL_STRING(_hw, HW_MODEL, model, CTLFLAG_RD,
80 cpu_model, 0, "Machine model");
82 static int hw_clockrate;
83 SYSCTL_INT(_hw, OID_AUTO, clockrate, CTLFLAG_RD,
84 &hw_clockrate, 0, "CPU instruction clock rate");
86 static char cpu_brand[48];
92 { "Clawhammer", CPUCLASS_K8 }, /* CPU_CLAWHAMMER */
93 { "Sledgehammer", CPUCLASS_K8 }, /* CPU_SLEDGEHAMMER */
100 { INTEL_VENDOR_ID, CPU_VENDOR_INTEL }, /* GenuineIntel */
101 { AMD_VENDOR_ID, CPU_VENDOR_AMD }, /* AuthenticAMD */
102 { CENTAUR_VENDOR_ID, CPU_VENDOR_CENTAUR }, /* CentaurHauls */
106 static int cpu_cores;
107 static int cpu_logical;
116 cpu_class = x86_64_cpus[cpu_type].cpu_class;
118 strncpy(cpu_model, x86_64_cpus[cpu_type].cpu_name, sizeof (cpu_model));
120 /* Check for extended CPUID information and a processor name. */
121 if (cpu_exthigh >= 0x80000004) {
123 for (i = 0x80000002; i < 0x80000005; i++) {
125 memcpy(brand, regs, sizeof(regs));
126 brand += sizeof(regs);
130 switch (cpu_vendor_id) {
131 case CPU_VENDOR_INTEL:
132 /* Please make up your mind folks! */
133 strcat(cpu_model, "EM64T");
137 * Values taken from AMD Processor Recognition
138 * http://www.amd.com/K6/k6docs/pdf/20734g.pdf
139 * (also describes ``Features'' encodings.
141 strcpy(cpu_model, "AMD ");
142 if ((cpu_id & 0xf00) == 0xf00)
143 strcat(cpu_model, "AMD64 Processor");
145 strcat(cpu_model, "Unknown");
147 case CPU_VENDOR_CENTAUR:
148 strcpy(cpu_model, "VIA ");
149 if ((cpu_id & 0xff0) == 0x6f0)
150 strcat(cpu_model, "Nano Processor");
152 strcat(cpu_model, "Unknown");
155 strcat(cpu_model, "Unknown");
160 * Replace cpu_model with cpu_brand minus leading spaces if
164 while (*brand == ' ')
167 strcpy(cpu_model, brand);
169 kprintf("%s (", cpu_model);
172 hw_clockrate = (tsc_frequency + 5000) / 1000000;
173 kprintf("%jd.%02d-MHz ",
174 (intmax_t)(tsc_frequency + 4999) / 1000000,
175 (u_int)((tsc_frequency + 4999) / 10000) % 100);
179 kprintf("Unknown"); /* will panic below... */
181 kprintf("-class CPU)\n");
183 kprintf(" Origin=\"%s\"", cpu_vendor);
185 kprintf(" Id=0x%x", cpu_id);
187 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
188 cpu_vendor_id == CPU_VENDOR_AMD ||
189 cpu_vendor_id == CPU_VENDOR_CENTAUR) {
190 kprintf(" Family=0x%x", CPUID_TO_FAMILY(cpu_id));
191 kprintf(" Model=0x%x", CPUID_TO_MODEL(cpu_id));
192 kprintf(" Stepping=%u", cpu_id & CPUID_STEPPING);
195 u_int cmp = 1, htt = 1;
199 * Here we should probably set up flags indicating
200 * whether or not various features are available.
201 * The interesting ones are probably VME, PSE, PAE,
202 * and PGE. The code already assumes without bothering
203 * to check that all CPUs >= Pentium have a TSC and
206 kprintf("\n Features=0x%pb%i",
208 "\001FPU" /* Integral FPU */
209 "\002VME" /* Extended VM86 mode support */
210 "\003DE" /* Debugging Extensions (CR4.DE) */
211 "\004PSE" /* 4MByte page tables */
212 "\005TSC" /* Timestamp counter */
213 "\006MSR" /* Machine specific registers */
214 "\007PAE" /* Physical address extension */
215 "\010MCE" /* Machine Check support */
216 "\011CX8" /* CMPEXCH8 instruction */
217 "\012APIC" /* SMP local APIC */
218 "\013oldMTRR" /* Previous implementation of MTRR */
219 "\014SEP" /* Fast System Call */
220 "\015MTRR" /* Memory Type Range Registers */
221 "\016PGE" /* PG_G (global bit) support */
222 "\017MCA" /* Machine Check Architecture */
223 "\020CMOV" /* CMOV instruction */
224 "\021PAT" /* Page attributes table */
225 "\022PSE36" /* 36 bit address space support */
226 "\023PN" /* Processor Serial number */
227 "\024CLFLUSH" /* Has the CLFLUSH instruction */
229 "\026DTS" /* Debug Trace Store */
230 "\027ACPI" /* ACPI support */
231 "\030MMX" /* MMX instructions */
232 "\031FXSR" /* FXSAVE/FXRSTOR */
233 "\032SSE" /* Streaming SIMD Extensions */
234 "\033SSE2" /* Streaming SIMD Extensions #2 */
235 "\034SS" /* Self snoop */
236 "\035HTT" /* Hyperthreading (see EBX bit 16-23) */
237 "\036TM" /* Thermal Monitor clock slowdown */
238 "\037IA64" /* CPU can execute IA64 instructions */
239 "\040PBE" /* Pending Break Enable */
242 if (cpu_feature2 != 0) {
243 kprintf("\n Features2=0x%pb%i",
245 "\001SSE3" /* SSE3 */
246 "\002PCLMULQDQ" /* Carry-Less Mul Quadword */
247 "\003DTES64" /* 64-bit Debug Trace */
248 "\004MON" /* MONITOR/MWAIT Instructions */
249 "\005DS_CPL" /* CPL Qualified Debug Store */
250 "\006VMX" /* Virtual Machine Extensions */
251 "\007SMX" /* Safer Mode Extensions */
252 "\010EST" /* Enhanced SpeedStep */
253 "\011TM2" /* Thermal Monitor 2 */
254 "\012SSSE3" /* SSSE3 */
255 "\013CNXT-ID" /* L1 context ID available */
256 "\014SDBG" /* IA-32 silicon debug */
257 "\015FMA" /* Fused Multiply Add */
258 "\016CX16" /* CMPXCHG16B Instruction */
259 "\017xTPR" /* Send Task Priority Messages */
260 "\020PDCM" /* Perf/Debug Capability MSR */
262 "\022PCID" /* Process-context Identifiers */
263 "\023DCA" /* Direct Cache Access */
264 "\024SSE4.1" /* SSE 4.1 */
265 "\025SSE4.2" /* SSE 4.2 */
266 "\026x2APIC" /* xAPIC Extensions */
267 "\027MOVBE" /* MOVBE Instruction */
268 "\030POPCNT" /* POPCNT Instruction */
269 "\031TSCDLT" /* TSC-Deadline Timer */
270 "\032AESNI" /* AES Crypto */
271 "\033XSAVE" /* XSAVE/XRSTOR States */
272 "\034OSXSAVE" /* OS-Enabled State Management */
273 "\035AVX" /* Advanced Vector Extensions */
274 "\036F16C" /* Half-precision conversions */
275 "\037RDRND" /* RDRAND RNG function */
276 "\040VMM" /* Running on a hypervisor */
280 if ((cpu_feature2 & CPUID2_XSAVE) != 0)
283 if (cpu_ia32_arch_caps != 0) {
284 kprintf("\n IA32_ARCH_CAPS=0x%pb%i",
292 "\007IF_PSCHANGE_MC_NO"
295 (u_int)cpu_ia32_arch_caps
300 * AMD64 Architecture Programmer's Manual Volume 3:
301 * General-Purpose and System Instructions
302 * http://www.amd.com/us-en/assets/content_type/white_papers_and_tech_docs/24594.pdf
304 * IA-32 Intel Architecture Software Developer's Manual,
305 * Volume 2A: Instruction Set Reference, A-M
306 * ftp://download.intel.com/design/Pentium4/manuals/25366617.pdf
308 if (amd_feature != 0) {
309 kprintf("\n AMD Features=0x%pb%i",
311 "\001<s0>" /* Same */
312 "\002<s1>" /* Same */
313 "\003<s2>" /* Same */
314 "\004<s3>" /* Same */
315 "\005<s4>" /* Same */
316 "\006<s5>" /* Same */
317 "\007<s6>" /* Same */
318 "\010<s7>" /* Same */
319 "\011<s8>" /* Same */
320 "\012<s9>" /* Same */
321 "\013<b10>" /* Undefined */
322 "\014SYSCALL" /* Have SYSCALL/SYSRET */
323 "\015<s12>" /* Same */
324 "\016<s13>" /* Same */
325 "\017<s14>" /* Same */
326 "\020<s15>" /* Same */
327 "\021<s16>" /* Same */
328 "\022<s17>" /* Same */
329 "\023<b18>" /* Reserved, unknown */
330 "\024MP" /* Multiprocessor Capable */
331 "\025NX" /* Has EFER.NXE, NX */
332 "\026<b21>" /* Undefined */
333 "\027MMX+" /* AMD MMX Extensions */
334 "\030<s23>" /* Same */
335 "\031<s24>" /* Same */
336 "\032FFXSR" /* Fast FXSAVE/FXRSTOR */
337 "\033Page1GB" /* 1-GB large page support */
338 "\034RDTSCP" /* RDTSCP */
339 "\035<b28>" /* Undefined */
340 "\036LM" /* 64 bit long mode */
341 "\0373DNow!+" /* AMD 3DNow! Extensions */
342 "\0403DNow!" /* AMD 3DNow! */
346 if (amd_feature2 != 0) {
347 kprintf("\n AMD Features2=0x%pb%i",
349 "\001LAHF" /* LAHF/SAHF in long mode */
350 "\002CMP" /* CMP legacy */
351 "\003SVM" /* Secure Virtual Mode */
352 "\004ExtAPIC" /* Extended APIC register */
353 "\005CR8" /* CR8 in legacy mode */
354 "\006ABM" /* LZCNT instruction */
355 "\007SSE4A" /* SSE4A */
356 "\010MAS" /* Misaligned SSE mode */
357 "\011Prefetch" /* 3DNow! Prefetch/PrefetchW */
358 "\012OSVW" /* OS visible workaround */
359 "\013IBS" /* Instruction based sampling */
360 "\014XOP" /* XOP extended instructions */
361 "\015SKINIT" /* SKINIT/STGI */
362 "\016WDT" /* Watchdog timer */
364 "\020LWP" /* Lightweight Profiling */
365 "\021FMA4" /* 4-operand FMA instructions */
366 "\022TCE" /* Translation Cache Extension */
368 "\024NodeId" /* NodeId MSR support */
370 "\026TBM" /* Trailing Bit Manipulation */
371 "\027Topology" /* Topology Extensions */
372 "\030PCX_CORE" /* Core Performance Counter */
373 "\031PCX_NB" /* NB Performance Counter */
374 "\032SPM" /* Streaming Perf Monitor */
375 "\033DBE" /* Data Breakpoint Extension */
376 "\034PTSC" /* Performance TSC */
377 "\035PCX_L2I" /* L2I Performance Counter */
378 "\036MWAITX" /* MONITORX/MWAITX instructions */
379 "\037ADMSKX" /* Address Mask Extension */
384 if (cpu_stdext_feature != 0) {
385 kprintf("\n Structured Extended "
388 /* RDFSBASE/RDGSBASE/WRFSBASE/WRGSBASE */
390 /* IA32_TSC_ADJUST MSR */
392 /* Bit Manipulation Instructions */
394 /* Hardware Lock Elision */
396 /* Advanced Vector Instructions 2 */
398 /* FDP_EXCPTN_ONLY */
400 /* Supervisor Mode Execution Prot. */
402 /* Bit Manipulation Instructions 2 */
404 /* Enhanced REP MOVSB/STOSB */
406 /* Invalidate Processor Context ID */
408 /* Restricted Transactional Memory */
410 /* Platform QoS Monitoring */
412 /* Deprecate FPU CS/DS values */
414 /* Intel Memory Protection Extensions */
416 /* Platform QoS Enforcement */
418 /* AVX512 Foundation */
420 /* AVX512 Double/Quadword */
426 /* Supervisor Mode Access Prevention */
428 /* AVX512 Integer Fused Multiply Add */
430 /* Formerly PCOMMIT */
432 /* Cache Line FLUSH OPTimized */
434 /* Cache Line Write Back */
436 /* Processor Trace */
438 /* AVX512 Prefetch */
440 /* AVX512 Exponential and Reciprocal */
442 /* AVX512 Conflict Detection */
446 /* AVX512 Byte and Word */
448 /* AVX512 Vector Length */
454 if (cpu_stdext_feature2 != 0) {
455 kprintf("\n Structured Extended "
472 "\017AVX512VPOPCNTDQ"
476 "\031BUS_LOCK_DETECT"
487 if (cpu_stdext_feature3 != 0) {
488 kprintf("\n Structured Extended "
495 "\011AVX512VP2INTERSECT"
514 if (cpu_thermal_feature != 0) {
515 kprintf("\n Thermal and PM Features=0x%pb%i",
517 /* Digital temperature sensor */
521 /* APIC-Timer-always-running */
523 /* Power limit notification controls */
525 /* Clock modulation duty cycle extension */
527 /* Package thermal management */
529 /* Hardware P-states */
531 , cpu_thermal_feature);
534 if (cpu_mwait_feature != 0) {
535 kprintf("\n MONITOR/MWAIT Features=0x%pb%i",
537 /* Enumeration of Monitor-Mwait extension */
539 /* interrupts as break-event for MWAIT */
541 , cpu_mwait_feature);
544 if (cpu_vendor_id == CPU_VENDOR_CENTAUR)
545 print_via_padlock_info();
548 * INVALID CPU TOPOLOGY INFORMATION PRINT
549 * DEPRECATED - CPU_TOPOLOGY_DETECTION moved to
550 * - sys/platform/pc64/x86_64/mp_machdep.c
551 * - sys/kern/subr_cpu_topology
555 if ((cpu_feature & CPUID_HTT) &&
556 cpu_vendor_id == CPU_VENDOR_AMD)
557 cpu_feature &= ~CPUID_HTT;
561 * If this CPU supports HTT or CMP then mention the
562 * number of physical/logical cores it contains.
565 if (cpu_feature & CPUID_HTT)
566 htt = (cpu_procinfo & CPUID_HTT_CORES) >> 16;
567 if (cpu_vendor_id == CPU_VENDOR_AMD &&
568 (amd_feature2 & AMDID2_CMP))
569 cmp = (cpu_procinfo2 & AMDID_CMP_CORES) + 1;
570 else if (cpu_vendor_id == CPU_VENDOR_INTEL &&
572 cpuid_count(4, 0, regs);
573 if ((regs[0] & 0x1f) != 0)
574 cmp = ((regs[0] >> 26) & 0x3f) + 1;
579 * XXX For Intel CPUs, this is max number of cores per
580 * package, not the actual cores per package.
584 cpu_logical = htt / cmp;
587 kprintf("\n Cores per package: %d", cpu_cores);
588 if (cpu_logical > 1) {
589 kprintf("\n Logical CPUs per core: %d",
596 /* Avoid ugly blank lines: only print newline when we have to. */
597 if (*cpu_vendor || cpu_id)
600 if (cpu_stdext_feature & (CPUID_STDEXT_SMAP | CPUID_STDEXT_SMEP)) {
601 kprintf("CPU Special Features Installed:");
602 if (cpu_stdext_feature & CPUID_STDEXT_SMAP)
604 if (cpu_stdext_feature & CPUID_STDEXT_SMEP)
610 if (cpu_vendor_id == CPU_VENDOR_AMD)
616 panicifcpuunsupported(void)
620 #error "You need to specify a cpu type"
623 * Now that we have told the user what they have,
624 * let them know if that machine type isn't configured.
631 panic("CPU class not configured");
639 /* Update TSC freq with the value indicated by the caller. */
641 tsc_freq_changed(void *arg, const struct cf_level *level, int status)
643 /* If there was an error during the transition, don't do anything. */
647 /* Total setting for this level gives the new frequency in MHz. */
648 hw_clockrate = level->total_set.freq;
651 EVENTHANDLER_DEFINE(cpufreq_post_change, tsc_freq_changed, NULL,
652 EVENTHANDLER_PRI_ANY);
656 * Final stage of CPU identification.
662 u_int cpu_stdext_disable;
666 ((u_int *)&cpu_vendor)[0] = regs[1];
667 ((u_int *)&cpu_vendor)[1] = regs[3];
668 ((u_int *)&cpu_vendor)[2] = regs[2];
669 cpu_vendor[12] = '\0';
670 cpu_vendor_id = find_cpu_vendor_id();
674 cpu_procinfo = regs[1];
675 cpu_feature = regs[3];
676 cpu_feature2 = regs[2];
680 cpu_mwait_feature = regs[2];
681 if (cpu_mwait_feature & CPUID_MWAIT_EXT) {
682 cpu_mwait_extemu = regs[3];
683 /* At least one C1 */
684 if (CPUID_MWAIT_CX_SUBCNT(cpu_mwait_extemu, 1) == 0) {
685 /* No C1 at all, no MWAIT EXT then */
686 cpu_mwait_feature &= ~CPUID_MWAIT_EXT;
687 cpu_mwait_extemu = 0;
693 cpu_thermal_feature = regs[0];
696 cpuid_count(7, 0, regs);
697 cpu_stdext_feature = regs[1];
700 * Some hypervisors fail to filter out unsupported
701 * extended features. For now, disable the
702 * extensions, activation of which requires setting a
703 * bit in CR4, and which VM monitors do not support.
705 if (cpu_feature2 & CPUID2_VMM) {
706 cpu_stdext_disable = CPUID_STDEXT_FSGSBASE |
709 cpu_stdext_disable = 0;
711 TUNABLE_INT_FETCH("hw.cpu_stdext_disable", &cpu_stdext_disable);
714 * Some hypervisors fail to implement
715 * MSR_IA32_ARCH_CAPABILITIES, catch any problems.
717 cpu_stdext_feature &= ~cpu_stdext_disable;
718 cpu_stdext_feature2 = regs[2];
719 cpu_stdext_feature3 = regs[3];
720 if (cpu_stdext_feature3 & CPUID_STDEXT3_ARCH_CAP) {
721 if (rdmsr_safe(MSR_IA32_ARCH_CAPABILITIES,
722 &cpu_ia32_arch_caps))
724 kprintf("Warning: MSR_IA32_ARCH_CAPABILITIES "
725 "cannot be accessed\n");
730 if (cpu_vendor_id == CPU_VENDOR_INTEL ||
731 cpu_vendor_id == CPU_VENDOR_AMD ||
732 cpu_vendor_id == CPU_VENDOR_CENTAUR) {
733 do_cpuid(0x80000000, regs);
734 cpu_exthigh = regs[0];
736 if (cpu_exthigh >= 0x80000001) {
737 do_cpuid(0x80000001, regs);
738 amd_feature = regs[3] & ~(cpu_feature & 0x0183f3ff);
739 amd_feature2 = regs[2];
741 if (cpu_exthigh >= 0x80000008) {
742 do_cpuid(0x80000008, regs);
743 cpu_procinfo2 = regs[2];
747 cpu_type = CPU_CLAWHAMMER;
749 if (cpu_feature & CPUID_SSE2)
750 cpu_mi_feature |= CPU_MI_BZERONT;
752 if (cpu_feature2 & CPUID2_MON)
753 cpu_mi_feature |= CPU_MI_MONITOR;
756 * We do assume that all CPUs have the same
759 if ((cpu_feature & CPUID_SSE) && (cpu_feature & CPUID_FXSR))
764 find_cpu_vendor_id(void)
768 for (i = 0; i < NELEM(cpu_vendors); i++)
769 if (strcmp(cpu_vendor, cpu_vendors[i].vendor) == 0)
770 return (cpu_vendors[i].vendor_id);
775 print_AMD_assoc(int i)
778 kprintf(", fully associative\n");
780 kprintf(", %d-way associative\n", i);
784 print_AMD_l2_assoc(int i)
787 case 0: kprintf(", disabled/not present\n"); break;
788 case 1: kprintf(", direct mapped\n"); break;
789 case 2: kprintf(", 2-way associative\n"); break;
790 case 4: kprintf(", 4-way associative\n"); break;
791 case 6: kprintf(", 8-way associative\n"); break;
792 case 8: kprintf(", 16-way associative\n"); break;
793 case 15: kprintf(", fully associative\n"); break;
794 default: kprintf(", reserved configuration\n"); break;
803 if (cpu_exthigh < 0x80000005)
806 do_cpuid(0x80000005, regs);
807 kprintf("L1 2MB data TLB: %d entries", (regs[0] >> 16) & 0xff);
808 print_AMD_assoc(regs[0] >> 24);
810 kprintf("L1 2MB instruction TLB: %d entries", regs[0] & 0xff);
811 print_AMD_assoc((regs[0] >> 8) & 0xff);
813 kprintf("L1 4KB data TLB: %d entries", (regs[1] >> 16) & 0xff);
814 print_AMD_assoc(regs[1] >> 24);
816 kprintf("L1 4KB instruction TLB: %d entries", regs[1] & 0xff);
817 print_AMD_assoc((regs[1] >> 8) & 0xff);
819 kprintf("L1 data cache: %d kbytes", regs[2] >> 24);
820 kprintf(", %d bytes/line", regs[2] & 0xff);
821 kprintf(", %d lines/tag", (regs[2] >> 8) & 0xff);
822 print_AMD_assoc((regs[2] >> 16) & 0xff);
824 kprintf("L1 instruction cache: %d kbytes", regs[3] >> 24);
825 kprintf(", %d bytes/line", regs[3] & 0xff);
826 kprintf(", %d lines/tag", (regs[3] >> 8) & 0xff);
827 print_AMD_assoc((regs[3] >> 16) & 0xff);
829 if (cpu_exthigh >= 0x80000006) {
830 do_cpuid(0x80000006, regs);
831 if ((regs[0] >> 16) != 0) {
832 kprintf("L2 2MB data TLB: %d entries",
833 (regs[0] >> 16) & 0xfff);
834 print_AMD_l2_assoc(regs[0] >> 28);
835 kprintf("L2 2MB instruction TLB: %d entries",
837 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
839 kprintf("L2 2MB unified TLB: %d entries",
841 print_AMD_l2_assoc((regs[0] >> 28) & 0xf);
843 if ((regs[1] >> 16) != 0) {
844 kprintf("L2 4KB data TLB: %d entries",
845 (regs[1] >> 16) & 0xfff);
846 print_AMD_l2_assoc(regs[1] >> 28);
848 kprintf("L2 4KB instruction TLB: %d entries",
849 (regs[1] >> 16) & 0xfff);
850 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
852 kprintf("L2 4KB unified TLB: %d entries",
853 (regs[1] >> 16) & 0xfff);
854 print_AMD_l2_assoc((regs[1] >> 28) & 0xf);
856 kprintf("L2 unified cache: %d kbytes", regs[2] >> 16);
857 kprintf(", %d bytes/line", regs[2] & 0xff);
858 kprintf(", %d lines/tag", (regs[2] >> 8) & 0x0f);
859 print_AMD_l2_assoc((regs[2] >> 12) & 0x0f);
864 print_via_padlock_info(void)
868 /* Check for supported models. */
869 switch (cpu_id & 0xff0) {
871 if ((cpu_id & 0xf) < 3)
881 do_cpuid(0xc0000000, regs);
882 if (regs[0] >= 0xc0000001)
883 do_cpuid(0xc0000001, regs);
887 kprintf("\n VIA Padlock Features=0x%pb%i",
891 "\011AES-CTR" /* ACE2 */
892 "\013SHA1,SHA256" /* PHE */
898 print_xsave_info(void)
902 cpuid_count(0xd, 0x1, regs);
906 kprintf("\n XSAVE Features=0x%pb%i",