Sun Dec 4 17:00:10 2011 UTC ()
add info on L2 TLBs and 1GB pages.


(chs)
diff -r1.12 -r1.13 src/sys/arch/x86/include/cacheinfo.h
diff -r1.25 -r1.26 src/usr.sbin/cpuctl/arch/i386.c

cvs diff -r1.12 -r1.13 src/sys/arch/x86/include/cacheinfo.h (expand / switch to unified diff)

--- src/sys/arch/x86/include/cacheinfo.h 2009/05/13 23:26:38 1.12
+++ src/sys/arch/x86/include/cacheinfo.h 2011/12/04 17:00:10 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cacheinfo.h,v 1.12 2009/05/13 23:26:38 pgoyette Exp $ */ 1/* $NetBSD: cacheinfo.h,v 1.13 2011/12/04 17:00:10 chs Exp $ */
2 2
3#ifndef _X86_CACHEINFO_H_ 3#ifndef _X86_CACHEINFO_H_
4#define _X86_CACHEINFO_H_ 4#define _X86_CACHEINFO_H_
5 5
6struct x86_cache_info { 6struct x86_cache_info {
7 uint8_t cai_index; 7 uint8_t cai_index;
8 uint8_t cai_desc; 8 uint8_t cai_desc;
9 uint8_t cai_associativity; 9 uint8_t cai_associativity;
10 u_int cai_totalsize; /* #entries for TLB, bytes for cache */ 10 u_int cai_totalsize; /* #entries for TLB, bytes for cache */
11 u_int cai_linesize; /* or page size for TLB */ 11 u_int cai_linesize; /* or page size for TLB */
12#ifndef _KERNEL 12#ifndef _KERNEL
13 const char *cai_string; 13 const char *cai_string;
14#endif 14#endif
@@ -16,28 +16,32 @@ struct x86_cache_info { @@ -16,28 +16,32 @@ struct x86_cache_info {
16 16
17#define CAI_ITLB 0 /* Instruction TLB (4K pages) */ 17#define CAI_ITLB 0 /* Instruction TLB (4K pages) */
18#define CAI_ITLB2 1 /* Instruction TLB (2/4M pages) */ 18#define CAI_ITLB2 1 /* Instruction TLB (2/4M pages) */
19#define CAI_DTLB 2 /* Data TLB (4K pages) */ 19#define CAI_DTLB 2 /* Data TLB (4K pages) */
20#define CAI_DTLB2 3 /* Data TLB (2/4M pages) */ 20#define CAI_DTLB2 3 /* Data TLB (2/4M pages) */
21#define CAI_ICACHE 4 /* Instruction cache */ 21#define CAI_ICACHE 4 /* Instruction cache */
22#define CAI_DCACHE 5 /* Data cache */ 22#define CAI_DCACHE 5 /* Data cache */
23#define CAI_L2CACHE 6 /* Level 2 cache */ 23#define CAI_L2CACHE 6 /* Level 2 cache */
24#define CAI_L3CACHE 7 /* Level 3 cache */ 24#define CAI_L3CACHE 7 /* Level 3 cache */
25#define CAI_L1_1GBITLB 8 /* L1 1GB Page instruction TLB */ 25#define CAI_L1_1GBITLB 8 /* L1 1GB Page instruction TLB */
26#define CAI_L1_1GBDTLB 9 /* L1 1GB Page data TLB */ 26#define CAI_L1_1GBDTLB 9 /* L1 1GB Page data TLB */
27#define CAI_L2_1GBITLB 10 /* L2 1GB Page instruction TLB */ 27#define CAI_L2_1GBITLB 10 /* L2 1GB Page instruction TLB */
28#define CAI_L2_1GBDTLB 11 /* L2 1GB Page data TLB */ 28#define CAI_L2_1GBDTLB 11 /* L2 1GB Page data TLB */
 29#define CAI_L2_ITLB 12 /* L2 Instruction TLB (4K pages) */
 30#define CAI_L2_ITLB2 13 /* L2 Instruction TLB (2/4M pages) */
 31#define CAI_L2_DTLB 14 /* L2 Data TLB (4K pages) */
 32#define CAI_L2_DTLB2 15 /* L2 Data TLB (2/4M pages) */
29 33
30#define CAI_COUNT 12 34#define CAI_COUNT 16
31 35
32/* 36/*
33 * AMD Cache Info: 37 * AMD Cache Info:
34 * 38 *
35 * Barcelona, Phenom: 39 * Barcelona, Phenom:
36 * 40 *
37 * Function 8000.0005 L1 TLB/Cache Information 41 * Function 8000.0005 L1 TLB/Cache Information
38 * EAX -- L1 TLB 2/4MB pages 42 * EAX -- L1 TLB 2/4MB pages
39 * EBX -- L1 TLB 4K pages 43 * EBX -- L1 TLB 4K pages
40 * ECX -- L1 D-cache 44 * ECX -- L1 D-cache
41 * EDX -- L1 I-cache 45 * EDX -- L1 I-cache
42 * 46 *
43 * Function 8000.0006 L2 TLB/Cache Information 47 * Function 8000.0006 L2 TLB/Cache Information

cvs diff -r1.25 -r1.26 src/usr.sbin/cpuctl/arch/i386.c (expand / switch to unified diff)

--- src/usr.sbin/cpuctl/arch/i386.c 2011/05/03 09:06:22 1.25
+++ src/usr.sbin/cpuctl/arch/i386.c 2011/12/04 17:00:10 1.26
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: i386.c,v 1.25 2011/05/03 09:06:22 jruoho Exp $ */ 1/* $NetBSD: i386.c,v 1.26 2011/12/04 17:00:10 chs Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank van der Linden, and by Jason R. Thorpe. 8 * by Frank van der Linden, and by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE. 55 * SUCH DAMAGE.
56 */ 56 */
57 57
58#include <sys/cdefs.h> 58#include <sys/cdefs.h>
59#ifndef lint 59#ifndef lint
60__RCSID("$NetBSD: i386.c,v 1.25 2011/05/03 09:06:22 jruoho Exp $"); 60__RCSID("$NetBSD: i386.c,v 1.26 2011/12/04 17:00:10 chs Exp $");
61#endif /* not lint */ 61#endif /* not lint */
62 62
63#include <sys/types.h> 63#include <sys/types.h>
64#include <sys/param.h> 64#include <sys/param.h>
65#include <sys/bitops.h> 65#include <sys/bitops.h>
66#include <sys/sysctl.h> 66#include <sys/sysctl.h>
67 67
68#include <string.h> 68#include <string.h>
69#include <stdio.h> 69#include <stdio.h>
70#include <stdlib.h> 70#include <stdlib.h>
71#include <err.h> 71#include <err.h>
72#include <assert.h> 72#include <assert.h>
73#include <math.h> 73#include <math.h>
@@ -172,26 +172,27 @@ static const char * const i386_intel_bra @@ -172,26 +172,27 @@ static const char * const i386_intel_bra
172 * AMD processors don't have Brand IDs, so we need these names for probe. 172 * AMD processors don't have Brand IDs, so we need these names for probe.
173 */ 173 */
174static const char * const amd_brand[] = { 174static const char * const amd_brand[] = {
175 "", 175 "",
176 "Duron", /* AMD Duron(tm) */ 176 "Duron", /* AMD Duron(tm) */
177 "MP", /* AMD Athlon(tm) MP */ 177 "MP", /* AMD Athlon(tm) MP */
178 "XP", /* AMD Athlon(tm) XP */ 178 "XP", /* AMD Athlon(tm) XP */
179 "4" /* AMD Athlon(tm) 4 */ 179 "4" /* AMD Athlon(tm) 4 */
180}; 180};
181 181
182static int cpu_vendor; 182static int cpu_vendor;
183static char cpu_brand_string[49]; 183static char cpu_brand_string[49];
184static char amd_brand_name[48]; 184static char amd_brand_name[48];
 185static int use_pae, largepagesize;
185 186
186static void via_cpu_probe(struct cpu_info *); 187static void via_cpu_probe(struct cpu_info *);
187static void amd_family6_probe(struct cpu_info *); 188static void amd_family6_probe(struct cpu_info *);
188static void intel_family_new_probe(struct cpu_info *); 189static void intel_family_new_probe(struct cpu_info *);
189static const char *intel_family6_name(struct cpu_info *); 190static const char *intel_family6_name(struct cpu_info *);
190static const char *amd_amd64_name(struct cpu_info *); 191static const char *amd_amd64_name(struct cpu_info *);
191static void amd_family5_setup(struct cpu_info *); 192static void amd_family5_setup(struct cpu_info *);
192static void transmeta_cpu_info(struct cpu_info *); 193static void transmeta_cpu_info(struct cpu_info *);
193static const char *print_cache_config(struct cpu_info *, int, const char *, 194static const char *print_cache_config(struct cpu_info *, int, const char *,
194 const char *); 195 const char *);
195static const char *print_tlb_config(struct cpu_info *, int, const char *, 196static const char *print_tlb_config(struct cpu_info *, int, const char *,
196 const char *); 197 const char *);
197static void amd_cpu_cacheinfo(struct cpu_info *); 198static void amd_cpu_cacheinfo(struct cpu_info *);
@@ -1370,26 +1371,29 @@ identifycpu(const char *cpuname) @@ -1370,26 +1371,29 @@ identifycpu(const char *cpuname)
1370 name = tmp; 1371 name = tmp;
1371 } 1372 }
1372 } 1373 }
1373  1374
1374 if (cpu_vendor == CPUVENDOR_IDT && family >= 6) 1375 if (cpu_vendor == CPUVENDOR_IDT && family >= 6)
1375 vendorname = "VIA"; 1376 vendorname = "VIA";
1376 } 1377 }
1377 } 1378 }
1378 1379
1379 ci->ci_cpu_class = class; 1380 ci->ci_cpu_class = class;
1380 1381
1381 sz = sizeof(ci->ci_tsc_freq); 1382 sz = sizeof(ci->ci_tsc_freq);
1382 (void)sysctlbyname("machdep.tsc_freq", &ci->ci_tsc_freq, &sz, NULL, 0); 1383 (void)sysctlbyname("machdep.tsc_freq", &ci->ci_tsc_freq, &sz, NULL, 0);
 1384 sz = sizeof(use_pae);
 1385 (void)sysctlbyname("machdep.pae", &use_pae, &sz, NULL, 0);
 1386 largepagesize = (use_pae ? 2 * 1024 * 1024 : 4 * 1024 * 1024);
1383 1387
1384 snprintf(cpu_model, sizeof(cpu_model), "%s%s%s%s%s%s%s (%s-class)", 1388 snprintf(cpu_model, sizeof(cpu_model), "%s%s%s%s%s%s%s (%s-class)",
1385 vendorname, 1389 vendorname,
1386 *modifier ? " " : "", modifier, 1390 *modifier ? " " : "", modifier,
1387 *name ? " " : "", name, 1391 *name ? " " : "", name,
1388 *brand ? " " : "", brand, 1392 *brand ? " " : "", brand,
1389 classnames[class]); 1393 classnames[class]);
1390 aprint_normal("%s: %s", cpuname, cpu_model); 1394 aprint_normal("%s: %s", cpuname, cpu_model);
1391 1395
1392 if (ci->ci_tsc_freq != 0) 1396 if (ci->ci_tsc_freq != 0)
1393 aprint_normal(", %qd.%02qd MHz", 1397 aprint_normal(", %qd.%02qd MHz",
1394 (ci->ci_tsc_freq + 4999) / 1000000, 1398 (ci->ci_tsc_freq + 4999) / 1000000,
1395 ((ci->ci_tsc_freq + 4999) / 10000) % 100); 1399 ((ci->ci_tsc_freq + 4999) / 10000) % 100);
@@ -1659,32 +1663,32 @@ amd_cpu_cacheinfo(struct cpu_info *ci) @@ -1659,32 +1663,32 @@ amd_cpu_cacheinfo(struct cpu_info *ci)
1659 /* No L1 cache info available. */ 1663 /* No L1 cache info available. */
1660 return; 1664 return;
1661 } 1665 }
1662 1666
1663 x86_cpuid(0x80000005, descs); 1667 x86_cpuid(0x80000005, descs);
1664 1668
1665 /* 1669 /*
1666 * K6-III and higher have large page TLBs. 1670 * K6-III and higher have large page TLBs.
1667 */ 1671 */
1668 if ((family == 5 && model >= 9) || family >= 6) { 1672 if ((family == 5 && model >= 9) || family >= 6) {
1669 cai = &ci->ci_cinfo[CAI_ITLB2]; 1673 cai = &ci->ci_cinfo[CAI_ITLB2];
1670 cai->cai_totalsize = AMD_L1_EAX_ITLB_ENTRIES(descs[0]); 1674 cai->cai_totalsize = AMD_L1_EAX_ITLB_ENTRIES(descs[0]);
1671 cai->cai_associativity = AMD_L1_EAX_ITLB_ASSOC(descs[0]); 1675 cai->cai_associativity = AMD_L1_EAX_ITLB_ASSOC(descs[0]);
1672 cai->cai_linesize = (4 * 1024 * 1024); 1676 cai->cai_linesize = largepagesize;
1673 1677
1674 cai = &ci->ci_cinfo[CAI_DTLB2]; 1678 cai = &ci->ci_cinfo[CAI_DTLB2];
1675 cai->cai_totalsize = AMD_L1_EAX_DTLB_ENTRIES(descs[0]); 1679 cai->cai_totalsize = AMD_L1_EAX_DTLB_ENTRIES(descs[0]);
1676 cai->cai_associativity = AMD_L1_EAX_DTLB_ASSOC(descs[0]); 1680 cai->cai_associativity = AMD_L1_EAX_DTLB_ASSOC(descs[0]);
1677 cai->cai_linesize = (4 * 1024 * 1024); 1681 cai->cai_linesize = largepagesize;
1678 } 1682 }
1679 1683
1680 cai = &ci->ci_cinfo[CAI_ITLB]; 1684 cai = &ci->ci_cinfo[CAI_ITLB];
1681 cai->cai_totalsize = AMD_L1_EBX_ITLB_ENTRIES(descs[1]); 1685 cai->cai_totalsize = AMD_L1_EBX_ITLB_ENTRIES(descs[1]);
1682 cai->cai_associativity = AMD_L1_EBX_ITLB_ASSOC(descs[1]); 1686 cai->cai_associativity = AMD_L1_EBX_ITLB_ASSOC(descs[1]);
1683 cai->cai_linesize = (4 * 1024); 1687 cai->cai_linesize = (4 * 1024);
1684 1688
1685 cai = &ci->ci_cinfo[CAI_DTLB]; 1689 cai = &ci->ci_cinfo[CAI_DTLB];
1686 cai->cai_totalsize = AMD_L1_EBX_DTLB_ENTRIES(descs[1]); 1690 cai->cai_totalsize = AMD_L1_EBX_DTLB_ENTRIES(descs[1]);
1687 cai->cai_associativity = AMD_L1_EBX_DTLB_ASSOC(descs[1]); 1691 cai->cai_associativity = AMD_L1_EBX_DTLB_ASSOC(descs[1]);
1688 cai->cai_linesize = (4 * 1024); 1692 cai->cai_linesize = (4 * 1024);
1689 1693
1690 cai = &ci->ci_cinfo[CAI_DCACHE]; 1694 cai = &ci->ci_cinfo[CAI_DCACHE];
@@ -1697,26 +1701,70 @@ amd_cpu_cacheinfo(struct cpu_info *ci) @@ -1697,26 +1701,70 @@ amd_cpu_cacheinfo(struct cpu_info *ci)
1697 cai->cai_associativity = AMD_L1_EDX_IC_ASSOC(descs[3]); 1701 cai->cai_associativity = AMD_L1_EDX_IC_ASSOC(descs[3]);
1698 cai->cai_linesize = AMD_L1_EDX_IC_LS(descs[3]); 1702 cai->cai_linesize = AMD_L1_EDX_IC_LS(descs[3]);
1699 1703
1700 /* 1704 /*
1701 * Determine L2 cache/TLB info. 1705 * Determine L2 cache/TLB info.
1702 */ 1706 */
1703 if (lfunc < 0x80000006) { 1707 if (lfunc < 0x80000006) {
1704 /* No L2 cache info available. */ 1708 /* No L2 cache info available. */
1705 return; 1709 return;
1706 } 1710 }
1707 1711
1708 x86_cpuid(0x80000006, descs); 1712 x86_cpuid(0x80000006, descs);
1709 1713
 1714 cai = &ci->ci_cinfo[CAI_L2_ITLB];
 1715 cai->cai_totalsize = AMD_L2_EBX_IUTLB_ENTRIES(descs[1]);
 1716 cai->cai_associativity = AMD_L2_EBX_IUTLB_ASSOC(descs[1]);
 1717 cai->cai_linesize = (4 * 1024);
 1718 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1719 cai->cai_associativity);
 1720 if (cp != NULL)
 1721 cai->cai_associativity = cp->cai_associativity;
 1722 else
 1723 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1724
 1725 cai = &ci->ci_cinfo[CAI_L2_ITLB2];
 1726 cai->cai_totalsize = AMD_L2_EAX_IUTLB_ENTRIES(descs[0]);
 1727 cai->cai_associativity = AMD_L2_EAX_IUTLB_ASSOC(descs[0]);
 1728 cai->cai_linesize = largepagesize;
 1729 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1730 cai->cai_associativity);
 1731 if (cp != NULL)
 1732 cai->cai_associativity = cp->cai_associativity;
 1733 else
 1734 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1735
 1736 cai = &ci->ci_cinfo[CAI_L2_DTLB];
 1737 cai->cai_totalsize = AMD_L2_EBX_DTLB_ENTRIES(descs[1]);
 1738 cai->cai_associativity = AMD_L2_EBX_DTLB_ASSOC(descs[1]);
 1739 cai->cai_linesize = (4 * 1024);
 1740 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1741 cai->cai_associativity);
 1742 if (cp != NULL)
 1743 cai->cai_associativity = cp->cai_associativity;
 1744 else
 1745 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1746
 1747 cai = &ci->ci_cinfo[CAI_L2_DTLB2];
 1748 cai->cai_totalsize = AMD_L2_EAX_DTLB_ENTRIES(descs[0]);
 1749 cai->cai_associativity = AMD_L2_EAX_DTLB_ASSOC(descs[0]);
 1750 cai->cai_linesize = largepagesize;
 1751 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1752 cai->cai_associativity);
 1753 if (cp != NULL)
 1754 cai->cai_associativity = cp->cai_associativity;
 1755 else
 1756 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1757
1710 cai = &ci->ci_cinfo[CAI_L2CACHE]; 1758 cai = &ci->ci_cinfo[CAI_L2CACHE];
1711 cai->cai_totalsize = AMD_L2_ECX_C_SIZE(descs[2]); 1759 cai->cai_totalsize = AMD_L2_ECX_C_SIZE(descs[2]);
1712 cai->cai_associativity = AMD_L2_ECX_C_ASSOC(descs[2]); 1760 cai->cai_associativity = AMD_L2_ECX_C_ASSOC(descs[2]);
1713 cai->cai_linesize = AMD_L2_ECX_C_LS(descs[2]); 1761 cai->cai_linesize = AMD_L2_ECX_C_LS(descs[2]);
1714 1762
1715 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info, 1763 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
1716 cai->cai_associativity); 1764 cai->cai_associativity);
1717 if (cp != NULL) 1765 if (cp != NULL)
1718 cai->cai_associativity = cp->cai_associativity; 1766 cai->cai_associativity = cp->cai_associativity;
1719 else 1767 else
1720 cai->cai_associativity = 0; /* XXX Unknown/reserved */ 1768 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1721 1769
1722 /* 1770 /*
@@ -1725,26 +1773,80 @@ amd_cpu_cacheinfo(struct cpu_info *ci) @@ -1725,26 +1773,80 @@ amd_cpu_cacheinfo(struct cpu_info *ci)
1725 if (family == 0x10) { 1773 if (family == 0x10) {
1726 cai = &ci->ci_cinfo[CAI_L3CACHE]; 1774 cai = &ci->ci_cinfo[CAI_L3CACHE];
1727 cai->cai_totalsize = AMD_L3_EDX_C_SIZE(descs[3]); 1775 cai->cai_totalsize = AMD_L3_EDX_C_SIZE(descs[3]);
1728 cai->cai_associativity = AMD_L3_EDX_C_ASSOC(descs[3]); 1776 cai->cai_associativity = AMD_L3_EDX_C_ASSOC(descs[3]);
1729 cai->cai_linesize = AMD_L3_EDX_C_LS(descs[3]); 1777 cai->cai_linesize = AMD_L3_EDX_C_LS(descs[3]);
1730 1778
1731 cp = cache_info_lookup(amd_cpuid_l3cache_assoc_info, 1779 cp = cache_info_lookup(amd_cpuid_l3cache_assoc_info,
1732 cai->cai_associativity); 1780 cai->cai_associativity);
1733 if (cp != NULL) 1781 if (cp != NULL)
1734 cai->cai_associativity = cp->cai_associativity; 1782 cai->cai_associativity = cp->cai_associativity;
1735 else 1783 else
1736 cai->cai_associativity = 0; /* XXX Unkn/Rsvd */ 1784 cai->cai_associativity = 0; /* XXX Unkn/Rsvd */
1737 } 1785 }
 1786
 1787 /*
 1788 * Determine 1GB TLB info.
 1789 */
 1790 if (lfunc < 0x80000019) {
 1791 /* No 1GB TLB info available. */
 1792 return;
 1793 }
 1794
 1795 x86_cpuid(0x80000019, descs);
 1796
 1797 cai = &ci->ci_cinfo[CAI_L1_1GBITLB];
 1798 cai->cai_totalsize = AMD_L1_1GB_EAX_IUTLB_ENTRIES(descs[0]);
 1799 cai->cai_associativity = AMD_L1_1GB_EAX_IUTLB_ASSOC(descs[0]);
 1800 cai->cai_linesize = (1024 * 1024 * 1024);
 1801 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1802 cai->cai_associativity);
 1803 if (cp != NULL)
 1804 cai->cai_associativity = cp->cai_associativity;
 1805 else
 1806 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1807
 1808 cai = &ci->ci_cinfo[CAI_L1_1GBDTLB];
 1809 cai->cai_totalsize = AMD_L1_1GB_EAX_DTLB_ENTRIES(descs[0]);
 1810 cai->cai_associativity = AMD_L1_1GB_EAX_DTLB_ASSOC(descs[0]);
 1811 cai->cai_linesize = (1024 * 1024 * 1024);
 1812 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1813 cai->cai_associativity);
 1814 if (cp != NULL)
 1815 cai->cai_associativity = cp->cai_associativity;
 1816 else
 1817 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1818
 1819 cai = &ci->ci_cinfo[CAI_L2_1GBITLB];
 1820 cai->cai_totalsize = AMD_L2_1GB_EBX_IUTLB_ENTRIES(descs[1]);
 1821 cai->cai_associativity = AMD_L2_1GB_EBX_IUTLB_ASSOC(descs[1]);
 1822 cai->cai_linesize = (1024 * 1024 * 1024);
 1823 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1824 cai->cai_associativity);
 1825 if (cp != NULL)
 1826 cai->cai_associativity = cp->cai_associativity;
 1827 else
 1828 cai->cai_associativity = 0; /* XXX Unknown/reserved */
 1829
 1830 cai = &ci->ci_cinfo[CAI_L2_1GBDTLB];
 1831 cai->cai_totalsize = AMD_L2_1GB_EBX_DUTLB_ENTRIES(descs[1]);
 1832 cai->cai_associativity = AMD_L2_1GB_EBX_DUTLB_ASSOC(descs[1]);
 1833 cai->cai_linesize = (1024 * 1024 * 1024);
 1834 cp = cache_info_lookup(amd_cpuid_l2cache_assoc_info,
 1835 cai->cai_associativity);
 1836 if (cp != NULL)
 1837 cai->cai_associativity = cp->cai_associativity;
 1838 else
 1839 cai->cai_associativity = 0; /* XXX Unknown/reserved */
1738} 1840}
1739 1841
1740static void 1842static void
1741via_cpu_cacheinfo(struct cpu_info *ci) 1843via_cpu_cacheinfo(struct cpu_info *ci)
1742{ 1844{
1743 struct x86_cache_info *cai; 1845 struct x86_cache_info *cai;
1744 int family, model, stepping; 1846 int family, model, stepping;
1745 u_int descs[4]; 1847 u_int descs[4];
1746 u_int lfunc; 1848 u_int lfunc;
1747 1849
1748 family = (ci->ci_signature >> 8) & 15; 1850 family = (ci->ci_signature >> 8) & 15;
1749 model = CPUID2MODEL(ci->ci_signature); 1851 model = CPUID2MODEL(ci->ci_signature);
1750 stepping = CPUID2STEPPING(ci->ci_signature); 1852 stepping = CPUID2STEPPING(ci->ci_signature);
@@ -1822,40 +1924,72 @@ x86_print_cacheinfo(struct cpu_info *ci) @@ -1822,40 +1924,72 @@ x86_print_cacheinfo(struct cpu_info *ci)
1822 1924
1823 if (ci->ci_cinfo[CAI_ICACHE].cai_totalsize != 0 || 1925 if (ci->ci_cinfo[CAI_ICACHE].cai_totalsize != 0 ||
1824 ci->ci_cinfo[CAI_DCACHE].cai_totalsize != 0) { 1926 ci->ci_cinfo[CAI_DCACHE].cai_totalsize != 0) {
1825 sep = print_cache_config(ci, CAI_ICACHE, "I-cache", NULL); 1927 sep = print_cache_config(ci, CAI_ICACHE, "I-cache", NULL);
1826 sep = print_cache_config(ci, CAI_DCACHE, "D-cache", sep); 1928 sep = print_cache_config(ci, CAI_DCACHE, "D-cache", sep);
1827 if (sep != NULL) 1929 if (sep != NULL)
1828 aprint_verbose("\n"); 1930 aprint_verbose("\n");
1829 } 1931 }
1830 if (ci->ci_cinfo[CAI_L2CACHE].cai_totalsize != 0) { 1932 if (ci->ci_cinfo[CAI_L2CACHE].cai_totalsize != 0) {
1831 sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache", NULL); 1933 sep = print_cache_config(ci, CAI_L2CACHE, "L2 cache", NULL);
1832 if (sep != NULL) 1934 if (sep != NULL)
1833 aprint_verbose("\n"); 1935 aprint_verbose("\n");
1834 } 1936 }
 1937 if (ci->ci_cinfo[CAI_L3CACHE].cai_totalsize != 0) {
 1938 sep = print_cache_config(ci, CAI_L3CACHE, "L3 cache", NULL);
 1939 if (sep != NULL)
 1940 aprint_verbose("\n");
 1941 }
1835 if (ci->ci_cinfo[CAI_ITLB].cai_totalsize != 0) { 1942 if (ci->ci_cinfo[CAI_ITLB].cai_totalsize != 0) {
1836 sep = print_tlb_config(ci, CAI_ITLB, "ITLB", NULL); 1943 sep = print_tlb_config(ci, CAI_ITLB, "ITLB", NULL);
1837 sep = print_tlb_config(ci, CAI_ITLB2, NULL, sep); 1944 sep = print_tlb_config(ci, CAI_ITLB2, NULL, sep);
1838 if (sep != NULL) 1945 if (sep != NULL)
1839 aprint_verbose("\n"); 1946 aprint_verbose("\n");
1840 } 1947 }
1841 if (ci->ci_cinfo[CAI_DTLB].cai_totalsize != 0) { 1948 if (ci->ci_cinfo[CAI_DTLB].cai_totalsize != 0) {
1842 sep = print_tlb_config(ci, CAI_DTLB, "DTLB", NULL); 1949 sep = print_tlb_config(ci, CAI_DTLB, "DTLB", NULL);
1843 sep = print_tlb_config(ci, CAI_DTLB2, NULL, sep); 1950 sep = print_tlb_config(ci, CAI_DTLB2, NULL, sep);
1844 if (sep != NULL) 1951 if (sep != NULL)
1845 aprint_verbose("\n"); 1952 aprint_verbose("\n");
1846 } 1953 }
1847 if (ci->ci_cinfo[CAI_L3CACHE].cai_totalsize != 0) { 1954 if (ci->ci_cinfo[CAI_L2_ITLB].cai_totalsize != 0) {
1848 sep = print_cache_config(ci, CAI_L3CACHE, "L3 cache", NULL); 1955 sep = print_tlb_config(ci, CAI_L2_ITLB, "L2 ITLB", NULL);
 1956 sep = print_tlb_config(ci, CAI_L2_ITLB2, NULL, sep);
 1957 if (sep != NULL)
 1958 aprint_verbose("\n");
 1959 }
 1960 if (ci->ci_cinfo[CAI_L2_DTLB].cai_totalsize != 0) {
 1961 sep = print_tlb_config(ci, CAI_L2_DTLB, "L2 DTLB", NULL);
 1962 sep = print_tlb_config(ci, CAI_L2_DTLB2, NULL, sep);
 1963 if (sep != NULL)
 1964 aprint_verbose("\n");
 1965 }
 1966 if (ci->ci_cinfo[CAI_L1_1GBITLB].cai_totalsize != 0) {
 1967 sep = print_tlb_config(ci, CAI_L1_1GBITLB, "L1 1GB page ITLB", NULL);
 1968 if (sep != NULL)
 1969 aprint_verbose("\n");
 1970 }
 1971 if (ci->ci_cinfo[CAI_L1_1GBDTLB].cai_totalsize != 0) {
 1972 sep = print_tlb_config(ci, CAI_L1_1GBDTLB, "L1 1GB page DTLB", NULL);
 1973 if (sep != NULL)
 1974 aprint_verbose("\n");
 1975 }
 1976 if (ci->ci_cinfo[CAI_L2_1GBITLB].cai_totalsize != 0) {
 1977 sep = print_tlb_config(ci, CAI_L2_1GBITLB, "L2 1GB page ITLB", NULL);
 1978 if (sep != NULL)
 1979 aprint_verbose("\n");
 1980 }
 1981 if (ci->ci_cinfo[CAI_L2_1GBDTLB].cai_totalsize != 0) {
 1982 sep = print_tlb_config(ci, CAI_L2_1GBDTLB, "L2 1GB page DTLB", NULL);
1849 if (sep != NULL) 1983 if (sep != NULL)
1850 aprint_verbose("\n"); 1984 aprint_verbose("\n");
1851 } 1985 }
1852} 1986}
1853 1987
1854static void 1988static void
1855powernow_probe(struct cpu_info *ci) 1989powernow_probe(struct cpu_info *ci)
1856{ 1990{
1857 uint32_t regs[4]; 1991 uint32_t regs[4];
1858 char buf[256]; 1992 char buf[256];
1859 1993
1860 x86_cpuid(0x80000007, regs); 1994 x86_cpuid(0x80000007, regs);
1861 1995