ia64/xen-unstable

changeset 14252:c371b6b26753

linux 2.6.18: eliminate Xen special: intel_cacheinfo.c

arch/i386/kernel/cpu/intel_cacheinfo-xen.c is identical to
arch/i386/kernel/cpu/intel_cacheinfo.c, hence the Xen special can be
removed.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Mon Mar 05 13:30:52 2007 +0000 (2007-03-05)
parents 1359e04a8fb3
children 192b59b472bc
files linux-2.6-xen-sparse/arch/i386/kernel/cpu/intel_cacheinfo-xen.c linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/cpu/intel_cacheinfo-xen.c	Mon Mar 05 13:27:51 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,774 +0,0 @@
     1.4 -/*
     1.5 - *      Routines to indentify caches on Intel CPU.
     1.6 - *
     1.7 - *      Changes:
     1.8 - *      Venkatesh Pallipadi	: Adding cache identification through cpuid(4)
     1.9 - *		Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure.
    1.10 - *	Andi Kleen		: CPUID4 emulation on AMD.
    1.11 - */
    1.12 -
    1.13 -#include <linux/init.h>
    1.14 -#include <linux/slab.h>
    1.15 -#include <linux/device.h>
    1.16 -#include <linux/compiler.h>
    1.17 -#include <linux/cpu.h>
    1.18 -#include <linux/sched.h>
    1.19 -
    1.20 -#include <asm/processor.h>
    1.21 -#include <asm/smp.h>
    1.22 -
    1.23 -#define LVL_1_INST	1
    1.24 -#define LVL_1_DATA	2
    1.25 -#define LVL_2		3
    1.26 -#define LVL_3		4
    1.27 -#define LVL_TRACE	5
    1.28 -
    1.29 -struct _cache_table
    1.30 -{
    1.31 -	unsigned char descriptor;
    1.32 -	char cache_type;
    1.33 -	short size;
    1.34 -};
    1.35 -
    1.36 -/* all the cache descriptor types we care about (no TLB or trace cache entries) */
    1.37 -static struct _cache_table cache_table[] __cpuinitdata =
    1.38 -{
    1.39 -	{ 0x06, LVL_1_INST, 8 },	/* 4-way set assoc, 32 byte line size */
    1.40 -	{ 0x08, LVL_1_INST, 16 },	/* 4-way set assoc, 32 byte line size */
    1.41 -	{ 0x0a, LVL_1_DATA, 8 },	/* 2 way set assoc, 32 byte line size */
    1.42 -	{ 0x0c, LVL_1_DATA, 16 },	/* 4-way set assoc, 32 byte line size */
    1.43 -	{ 0x22, LVL_3,      512 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.44 -	{ 0x23, LVL_3,      1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.45 -	{ 0x25, LVL_3,      2048 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.46 -	{ 0x29, LVL_3,      4096 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.47 -	{ 0x2c, LVL_1_DATA, 32 },	/* 8-way set assoc, 64 byte line size */
    1.48 -	{ 0x30, LVL_1_INST, 32 },	/* 8-way set assoc, 64 byte line size */
    1.49 -	{ 0x39, LVL_2,      128 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.50 -	{ 0x3a, LVL_2,      192 },	/* 6-way set assoc, sectored cache, 64 byte line size */
    1.51 -	{ 0x3b, LVL_2,      128 },	/* 2-way set assoc, sectored cache, 64 byte line size */
    1.52 -	{ 0x3c, LVL_2,      256 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.53 -	{ 0x3d, LVL_2,      384 },	/* 6-way set assoc, sectored cache, 64 byte line size */
    1.54 -	{ 0x3e, LVL_2,      512 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.55 -	{ 0x41, LVL_2,      128 },	/* 4-way set assoc, 32 byte line size */
    1.56 -	{ 0x42, LVL_2,      256 },	/* 4-way set assoc, 32 byte line size */
    1.57 -	{ 0x43, LVL_2,      512 },	/* 4-way set assoc, 32 byte line size */
    1.58 -	{ 0x44, LVL_2,      1024 },	/* 4-way set assoc, 32 byte line size */
    1.59 -	{ 0x45, LVL_2,      2048 },	/* 4-way set assoc, 32 byte line size */
    1.60 -	{ 0x46, LVL_3,      4096 },	/* 4-way set assoc, 64 byte line size */
    1.61 -	{ 0x47, LVL_3,      8192 },	/* 8-way set assoc, 64 byte line size */
    1.62 -	{ 0x49, LVL_3,      4096 },	/* 16-way set assoc, 64 byte line size */
    1.63 -	{ 0x4a, LVL_3,      6144 },	/* 12-way set assoc, 64 byte line size */
    1.64 -	{ 0x4b, LVL_3,      8192 },	/* 16-way set assoc, 64 byte line size */
    1.65 -	{ 0x4c, LVL_3,     12288 },	/* 12-way set assoc, 64 byte line size */
    1.66 -	{ 0x4d, LVL_3,     16384 },	/* 16-way set assoc, 64 byte line size */
    1.67 -	{ 0x60, LVL_1_DATA, 16 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.68 -	{ 0x66, LVL_1_DATA, 8 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.69 -	{ 0x67, LVL_1_DATA, 16 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.70 -	{ 0x68, LVL_1_DATA, 32 },	/* 4-way set assoc, sectored cache, 64 byte line size */
    1.71 -	{ 0x70, LVL_TRACE,  12 },	/* 8-way set assoc */
    1.72 -	{ 0x71, LVL_TRACE,  16 },	/* 8-way set assoc */
    1.73 -	{ 0x72, LVL_TRACE,  32 },	/* 8-way set assoc */
    1.74 -	{ 0x73, LVL_TRACE,  64 },	/* 8-way set assoc */
    1.75 -	{ 0x78, LVL_2,    1024 },	/* 4-way set assoc, 64 byte line size */
    1.76 -	{ 0x79, LVL_2,     128 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.77 -	{ 0x7a, LVL_2,     256 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.78 -	{ 0x7b, LVL_2,     512 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.79 -	{ 0x7c, LVL_2,    1024 },	/* 8-way set assoc, sectored cache, 64 byte line size */
    1.80 -	{ 0x7d, LVL_2,    2048 },	/* 8-way set assoc, 64 byte line size */
    1.81 -	{ 0x7f, LVL_2,     512 },	/* 2-way set assoc, 64 byte line size */
    1.82 -	{ 0x82, LVL_2,     256 },	/* 8-way set assoc, 32 byte line size */
    1.83 -	{ 0x83, LVL_2,     512 },	/* 8-way set assoc, 32 byte line size */
    1.84 -	{ 0x84, LVL_2,    1024 },	/* 8-way set assoc, 32 byte line size */
    1.85 -	{ 0x85, LVL_2,    2048 },	/* 8-way set assoc, 32 byte line size */
    1.86 -	{ 0x86, LVL_2,     512 },	/* 4-way set assoc, 64 byte line size */
    1.87 -	{ 0x87, LVL_2,    1024 },	/* 8-way set assoc, 64 byte line size */
    1.88 -	{ 0x00, 0, 0}
    1.89 -};
    1.90 -
    1.91 -
    1.92 -enum _cache_type
    1.93 -{
    1.94 -	CACHE_TYPE_NULL	= 0,
    1.95 -	CACHE_TYPE_DATA = 1,
    1.96 -	CACHE_TYPE_INST = 2,
    1.97 -	CACHE_TYPE_UNIFIED = 3
    1.98 -};
    1.99 -
   1.100 -union _cpuid4_leaf_eax {
   1.101 -	struct {
   1.102 -		enum _cache_type	type:5;
   1.103 -		unsigned int		level:3;
   1.104 -		unsigned int		is_self_initializing:1;
   1.105 -		unsigned int		is_fully_associative:1;
   1.106 -		unsigned int		reserved:4;
   1.107 -		unsigned int		num_threads_sharing:12;
   1.108 -		unsigned int		num_cores_on_die:6;
   1.109 -	} split;
   1.110 -	u32 full;
   1.111 -};
   1.112 -
   1.113 -union _cpuid4_leaf_ebx {
   1.114 -	struct {
   1.115 -		unsigned int		coherency_line_size:12;
   1.116 -		unsigned int		physical_line_partition:10;
   1.117 -		unsigned int		ways_of_associativity:10;
   1.118 -	} split;
   1.119 -	u32 full;
   1.120 -};
   1.121 -
   1.122 -union _cpuid4_leaf_ecx {
   1.123 -	struct {
   1.124 -		unsigned int		number_of_sets:32;
   1.125 -	} split;
   1.126 -	u32 full;
   1.127 -};
   1.128 -
   1.129 -struct _cpuid4_info {
   1.130 -	union _cpuid4_leaf_eax eax;
   1.131 -	union _cpuid4_leaf_ebx ebx;
   1.132 -	union _cpuid4_leaf_ecx ecx;
   1.133 -	unsigned long size;
   1.134 -	cpumask_t shared_cpu_map;
   1.135 -};
   1.136 -
   1.137 -unsigned short			num_cache_leaves;
   1.138 -
   1.139 -/* AMD doesn't have CPUID4. Emulate it here to report the same
   1.140 -   information to the user.  This makes some assumptions about the machine:
   1.141 -   No L3, L2 not shared, no SMT etc. that is currently true on AMD CPUs.
   1.142 -
   1.143 -   In theory the TLBs could be reported as fake type (they are in "dummy").
   1.144 -   Maybe later */
   1.145 -union l1_cache {
   1.146 -	struct {
   1.147 -		unsigned line_size : 8;
   1.148 -		unsigned lines_per_tag : 8;
   1.149 -		unsigned assoc : 8;
   1.150 -		unsigned size_in_kb : 8;
   1.151 -	};
   1.152 -	unsigned val;
   1.153 -};
   1.154 -
   1.155 -union l2_cache {
   1.156 -	struct {
   1.157 -		unsigned line_size : 8;
   1.158 -		unsigned lines_per_tag : 4;
   1.159 -		unsigned assoc : 4;
   1.160 -		unsigned size_in_kb : 16;
   1.161 -	};
   1.162 -	unsigned val;
   1.163 -};
   1.164 -
   1.165 -static const unsigned short assocs[] = {
   1.166 -	[1] = 1, [2] = 2, [4] = 4, [6] = 8,
   1.167 -	[8] = 16,
   1.168 -	[0xf] = 0xffff // ??
   1.169 -	};
   1.170 -static const unsigned char levels[] = { 1, 1, 2 };
   1.171 -static const unsigned char types[] = { 1, 2, 3 };
   1.172 -
   1.173 -static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
   1.174 -		       union _cpuid4_leaf_ebx *ebx,
   1.175 -		       union _cpuid4_leaf_ecx *ecx)
   1.176 -{
   1.177 -	unsigned dummy;
   1.178 -	unsigned line_size, lines_per_tag, assoc, size_in_kb;
   1.179 -	union l1_cache l1i, l1d;
   1.180 -	union l2_cache l2;
   1.181 -
   1.182 -	eax->full = 0;
   1.183 -	ebx->full = 0;
   1.184 -	ecx->full = 0;
   1.185 -
   1.186 -	cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val);
   1.187 -	cpuid(0x80000006, &dummy, &dummy, &l2.val, &dummy);
   1.188 -
   1.189 -	if (leaf > 2 || !l1d.val || !l1i.val || !l2.val)
   1.190 -		return;
   1.191 -
   1.192 -	eax->split.is_self_initializing = 1;
   1.193 -	eax->split.type = types[leaf];
   1.194 -	eax->split.level = levels[leaf];
   1.195 -	eax->split.num_threads_sharing = 0;
   1.196 -	eax->split.num_cores_on_die = current_cpu_data.x86_max_cores - 1;
   1.197 -
   1.198 -	if (leaf <= 1) {
   1.199 -		union l1_cache *l1 = leaf == 0 ? &l1d : &l1i;
   1.200 -		assoc = l1->assoc;
   1.201 -		line_size = l1->line_size;
   1.202 -		lines_per_tag = l1->lines_per_tag;
   1.203 -		size_in_kb = l1->size_in_kb;
   1.204 -	} else {
   1.205 -		assoc = l2.assoc;
   1.206 -		line_size = l2.line_size;
   1.207 -		lines_per_tag = l2.lines_per_tag;
   1.208 -		/* cpu_data has errata corrections for K7 applied */
   1.209 -		size_in_kb = current_cpu_data.x86_cache_size;
   1.210 -	}
   1.211 -
   1.212 -	if (assoc == 0xf)
   1.213 -		eax->split.is_fully_associative = 1;
   1.214 -	ebx->split.coherency_line_size = line_size - 1;
   1.215 -	ebx->split.ways_of_associativity = assocs[assoc] - 1;
   1.216 -	ebx->split.physical_line_partition = lines_per_tag - 1;
   1.217 -	ecx->split.number_of_sets = (size_in_kb * 1024) / line_size /
   1.218 -		(ebx->split.ways_of_associativity + 1) - 1;
   1.219 -}
   1.220 -
   1.221 -static int __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf)
   1.222 -{
   1.223 -	union _cpuid4_leaf_eax 	eax;
   1.224 -	union _cpuid4_leaf_ebx 	ebx;
   1.225 -	union _cpuid4_leaf_ecx 	ecx;
   1.226 -	unsigned		edx;
   1.227 -
   1.228 -	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD)
   1.229 -		amd_cpuid4(index, &eax, &ebx, &ecx);
   1.230 -	else
   1.231 -		cpuid_count(4, index, &eax.full, &ebx.full, &ecx.full,  &edx);
   1.232 -	if (eax.split.type == CACHE_TYPE_NULL)
   1.233 -		return -EIO; /* better error ? */
   1.234 -
   1.235 -	this_leaf->eax = eax;
   1.236 -	this_leaf->ebx = ebx;
   1.237 -	this_leaf->ecx = ecx;
   1.238 -	this_leaf->size = (ecx.split.number_of_sets + 1) *
   1.239 -		(ebx.split.coherency_line_size + 1) *
   1.240 -		(ebx.split.physical_line_partition + 1) *
   1.241 -		(ebx.split.ways_of_associativity + 1);
   1.242 -	return 0;
   1.243 -}
   1.244 -
   1.245 -/* will only be called once; __init is safe here */
   1.246 -static int __init find_num_cache_leaves(void)
   1.247 -{
   1.248 -	unsigned int		eax, ebx, ecx, edx;
   1.249 -	union _cpuid4_leaf_eax	cache_eax;
   1.250 -	int 			i = -1;
   1.251 -
   1.252 -	do {
   1.253 -		++i;
   1.254 -		/* Do cpuid(4) loop to find out num_cache_leaves */
   1.255 -		cpuid_count(4, i, &eax, &ebx, &ecx, &edx);
   1.256 -		cache_eax.full = eax;
   1.257 -	} while (cache_eax.split.type != CACHE_TYPE_NULL);
   1.258 -	return i;
   1.259 -}
   1.260 -
   1.261 -unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c)
   1.262 -{
   1.263 -	unsigned int trace = 0, l1i = 0, l1d = 0, l2 = 0, l3 = 0; /* Cache sizes */
   1.264 -	unsigned int new_l1d = 0, new_l1i = 0; /* Cache sizes from cpuid(4) */
   1.265 -	unsigned int new_l2 = 0, new_l3 = 0, i; /* Cache sizes from cpuid(4) */
   1.266 -	unsigned int l2_id = 0, l3_id = 0, num_threads_sharing, index_msb;
   1.267 -#ifdef CONFIG_X86_HT
   1.268 -	unsigned int cpu = (c == &boot_cpu_data) ? 0 : (c - cpu_data);
   1.269 -#endif
   1.270 -
   1.271 -	if (c->cpuid_level > 3) {
   1.272 -		static int is_initialized;
   1.273 -
   1.274 -		if (is_initialized == 0) {
   1.275 -			/* Init num_cache_leaves from boot CPU */
   1.276 -			num_cache_leaves = find_num_cache_leaves();
   1.277 -			is_initialized++;
   1.278 -		}
   1.279 -
   1.280 -		/*
   1.281 -		 * Whenever possible use cpuid(4), deterministic cache
   1.282 -		 * parameters cpuid leaf to find the cache details
   1.283 -		 */
   1.284 -		for (i = 0; i < num_cache_leaves; i++) {
   1.285 -			struct _cpuid4_info this_leaf;
   1.286 -
   1.287 -			int retval;
   1.288 -
   1.289 -			retval = cpuid4_cache_lookup(i, &this_leaf);
   1.290 -			if (retval >= 0) {
   1.291 -				switch(this_leaf.eax.split.level) {
   1.292 -				    case 1:
   1.293 -					if (this_leaf.eax.split.type ==
   1.294 -							CACHE_TYPE_DATA)
   1.295 -						new_l1d = this_leaf.size/1024;
   1.296 -					else if (this_leaf.eax.split.type ==
   1.297 -							CACHE_TYPE_INST)
   1.298 -						new_l1i = this_leaf.size/1024;
   1.299 -					break;
   1.300 -				    case 2:
   1.301 -					new_l2 = this_leaf.size/1024;
   1.302 -					num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;
   1.303 -					index_msb = get_count_order(num_threads_sharing);
   1.304 -					l2_id = c->apicid >> index_msb;
   1.305 -					break;
   1.306 -				    case 3:
   1.307 -					new_l3 = this_leaf.size/1024;
   1.308 -					num_threads_sharing = 1 + this_leaf.eax.split.num_threads_sharing;
   1.309 -					index_msb = get_count_order(num_threads_sharing);
   1.310 -					l3_id = c->apicid >> index_msb;
   1.311 -					break;
   1.312 -				    default:
   1.313 -					break;
   1.314 -				}
   1.315 -			}
   1.316 -		}
   1.317 -	}
   1.318 -	/*
   1.319 -	 * Don't use cpuid2 if cpuid4 is supported. For P4, we use cpuid2 for
   1.320 -	 * trace cache
   1.321 -	 */
   1.322 -	if ((num_cache_leaves == 0 || c->x86 == 15) && c->cpuid_level > 1) {
   1.323 -		/* supports eax=2  call */
   1.324 -		int i, j, n;
   1.325 -		int regs[4];
   1.326 -		unsigned char *dp = (unsigned char *)regs;
   1.327 -		int only_trace = 0;
   1.328 -
   1.329 -		if (num_cache_leaves != 0 && c->x86 == 15)
   1.330 -			only_trace = 1;
   1.331 -
   1.332 -		/* Number of times to iterate */
   1.333 -		n = cpuid_eax(2) & 0xFF;
   1.334 -
   1.335 -		for ( i = 0 ; i < n ; i++ ) {
   1.336 -			cpuid(2, &regs[0], &regs[1], &regs[2], &regs[3]);
   1.337 -
   1.338 -			/* If bit 31 is set, this is an unknown format */
   1.339 -			for ( j = 0 ; j < 3 ; j++ ) {
   1.340 -				if ( regs[j] < 0 ) regs[j] = 0;
   1.341 -			}
   1.342 -
   1.343 -			/* Byte 0 is level count, not a descriptor */
   1.344 -			for ( j = 1 ; j < 16 ; j++ ) {
   1.345 -				unsigned char des = dp[j];
   1.346 -				unsigned char k = 0;
   1.347 -
   1.348 -				/* look up this descriptor in the table */
   1.349 -				while (cache_table[k].descriptor != 0)
   1.350 -				{
   1.351 -					if (cache_table[k].descriptor == des) {
   1.352 -						if (only_trace && cache_table[k].cache_type != LVL_TRACE)
   1.353 -							break;
   1.354 -						switch (cache_table[k].cache_type) {
   1.355 -						case LVL_1_INST:
   1.356 -							l1i += cache_table[k].size;
   1.357 -							break;
   1.358 -						case LVL_1_DATA:
   1.359 -							l1d += cache_table[k].size;
   1.360 -							break;
   1.361 -						case LVL_2:
   1.362 -							l2 += cache_table[k].size;
   1.363 -							break;
   1.364 -						case LVL_3:
   1.365 -							l3 += cache_table[k].size;
   1.366 -							break;
   1.367 -						case LVL_TRACE:
   1.368 -							trace += cache_table[k].size;
   1.369 -							break;
   1.370 -						}
   1.371 -
   1.372 -						break;
   1.373 -					}
   1.374 -
   1.375 -					k++;
   1.376 -				}
   1.377 -			}
   1.378 -		}
   1.379 -	}
   1.380 -
   1.381 -	if (new_l1d)
   1.382 -		l1d = new_l1d;
   1.383 -
   1.384 -	if (new_l1i)
   1.385 -		l1i = new_l1i;
   1.386 -
   1.387 -	if (new_l2) {
   1.388 -		l2 = new_l2;
   1.389 -#ifdef CONFIG_X86_HT
   1.390 -		cpu_llc_id[cpu] = l2_id;
   1.391 -#endif
   1.392 -	}
   1.393 -
   1.394 -	if (new_l3) {
   1.395 -		l3 = new_l3;
   1.396 -#ifdef CONFIG_X86_HT
   1.397 -		cpu_llc_id[cpu] = l3_id;
   1.398 -#endif
   1.399 -	}
   1.400 -
   1.401 -	if (trace)
   1.402 -		printk (KERN_INFO "CPU: Trace cache: %dK uops", trace);
   1.403 -	else if ( l1i )
   1.404 -		printk (KERN_INFO "CPU: L1 I cache: %dK", l1i);
   1.405 -
   1.406 -	if (l1d)
   1.407 -		printk(", L1 D cache: %dK\n", l1d);
   1.408 -	else
   1.409 -		printk("\n");
   1.410 -
   1.411 -	if (l2)
   1.412 -		printk(KERN_INFO "CPU: L2 cache: %dK\n", l2);
   1.413 -
   1.414 -	if (l3)
   1.415 -		printk(KERN_INFO "CPU: L3 cache: %dK\n", l3);
   1.416 -
   1.417 -	c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d));
   1.418 -
   1.419 -	return l2;
   1.420 -}
   1.421 -
   1.422 -/* pointer to _cpuid4_info array (for each cache leaf) */
   1.423 -static struct _cpuid4_info *cpuid4_info[NR_CPUS];
   1.424 -#define CPUID4_INFO_IDX(x,y)    (&((cpuid4_info[x])[y]))
   1.425 -
   1.426 -#ifdef CONFIG_SMP
   1.427 -static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index)
   1.428 -{
   1.429 -	struct _cpuid4_info	*this_leaf, *sibling_leaf;
   1.430 -	unsigned long num_threads_sharing;
   1.431 -	int index_msb, i;
   1.432 -	struct cpuinfo_x86 *c = cpu_data;
   1.433 -
   1.434 -	this_leaf = CPUID4_INFO_IDX(cpu, index);
   1.435 -	num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing;
   1.436 -
   1.437 -	if (num_threads_sharing == 1)
   1.438 -		cpu_set(cpu, this_leaf->shared_cpu_map);
   1.439 -	else {
   1.440 -		index_msb = get_count_order(num_threads_sharing);
   1.441 -
   1.442 -		for_each_online_cpu(i) {
   1.443 -			if (c[i].apicid >> index_msb ==
   1.444 -			    c[cpu].apicid >> index_msb) {
   1.445 -				cpu_set(i, this_leaf->shared_cpu_map);
   1.446 -				if (i != cpu && cpuid4_info[i])  {
   1.447 -					sibling_leaf = CPUID4_INFO_IDX(i, index);
   1.448 -					cpu_set(cpu, sibling_leaf->shared_cpu_map);
   1.449 -				}
   1.450 -			}
   1.451 -		}
   1.452 -	}
   1.453 -}
   1.454 -static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index)
   1.455 -{
   1.456 -	struct _cpuid4_info	*this_leaf, *sibling_leaf;
   1.457 -	int sibling;
   1.458 -
   1.459 -	this_leaf = CPUID4_INFO_IDX(cpu, index);
   1.460 -	for_each_cpu_mask(sibling, this_leaf->shared_cpu_map) {
   1.461 -		sibling_leaf = CPUID4_INFO_IDX(sibling, index);	
   1.462 -		cpu_clear(cpu, sibling_leaf->shared_cpu_map);
   1.463 -	}
   1.464 -}
   1.465 -#else
   1.466 -static void __init cache_shared_cpu_map_setup(unsigned int cpu, int index) {}
   1.467 -static void __init cache_remove_shared_cpu_map(unsigned int cpu, int index) {}
   1.468 -#endif
   1.469 -
   1.470 -static void free_cache_attributes(unsigned int cpu)
   1.471 -{
   1.472 -	kfree(cpuid4_info[cpu]);
   1.473 -	cpuid4_info[cpu] = NULL;
   1.474 -}
   1.475 -
   1.476 -static int __cpuinit detect_cache_attributes(unsigned int cpu)
   1.477 -{
   1.478 -	struct _cpuid4_info	*this_leaf;
   1.479 -	unsigned long 		j;
   1.480 -	int 			retval;
   1.481 -	cpumask_t		oldmask;
   1.482 -
   1.483 -	if (num_cache_leaves == 0)
   1.484 -		return -ENOENT;
   1.485 -
   1.486 -	cpuid4_info[cpu] = kmalloc(
   1.487 -	    sizeof(struct _cpuid4_info) * num_cache_leaves, GFP_KERNEL);
   1.488 -	if (unlikely(cpuid4_info[cpu] == NULL))
   1.489 -		return -ENOMEM;
   1.490 -	memset(cpuid4_info[cpu], 0,
   1.491 -	    sizeof(struct _cpuid4_info) * num_cache_leaves);
   1.492 -
   1.493 -	oldmask = current->cpus_allowed;
   1.494 -	retval = set_cpus_allowed(current, cpumask_of_cpu(cpu));
   1.495 -	if (retval)
   1.496 -		goto out;
   1.497 -
   1.498 -	/* Do cpuid and store the results */
   1.499 -	retval = 0;
   1.500 -	for (j = 0; j < num_cache_leaves; j++) {
   1.501 -		this_leaf = CPUID4_INFO_IDX(cpu, j);
   1.502 -		retval = cpuid4_cache_lookup(j, this_leaf);
   1.503 -		if (unlikely(retval < 0))
   1.504 -			break;
   1.505 -		cache_shared_cpu_map_setup(cpu, j);
   1.506 -	}
   1.507 -	set_cpus_allowed(current, oldmask);
   1.508 -
   1.509 -out:
   1.510 -	if (retval)
   1.511 -		free_cache_attributes(cpu);
   1.512 -	return retval;
   1.513 -}
   1.514 -
   1.515 -#ifdef CONFIG_SYSFS
   1.516 -
   1.517 -#include <linux/kobject.h>
   1.518 -#include <linux/sysfs.h>
   1.519 -
   1.520 -extern struct sysdev_class cpu_sysdev_class; /* from drivers/base/cpu.c */
   1.521 -
   1.522 -/* pointer to kobject for cpuX/cache */
   1.523 -static struct kobject * cache_kobject[NR_CPUS];
   1.524 -
   1.525 -struct _index_kobject {
   1.526 -	struct kobject kobj;
   1.527 -	unsigned int cpu;
   1.528 -	unsigned short index;
   1.529 -};
   1.530 -
   1.531 -/* pointer to array of kobjects for cpuX/cache/indexY */
   1.532 -static struct _index_kobject *index_kobject[NR_CPUS];
   1.533 -#define INDEX_KOBJECT_PTR(x,y)    (&((index_kobject[x])[y]))
   1.534 -
   1.535 -#define show_one_plus(file_name, object, val)				\
   1.536 -static ssize_t show_##file_name						\
   1.537 -			(struct _cpuid4_info *this_leaf, char *buf)	\
   1.538 -{									\
   1.539 -	return sprintf (buf, "%lu\n", (unsigned long)this_leaf->object + val); \
   1.540 -}
   1.541 -
   1.542 -show_one_plus(level, eax.split.level, 0);
   1.543 -show_one_plus(coherency_line_size, ebx.split.coherency_line_size, 1);
   1.544 -show_one_plus(physical_line_partition, ebx.split.physical_line_partition, 1);
   1.545 -show_one_plus(ways_of_associativity, ebx.split.ways_of_associativity, 1);
   1.546 -show_one_plus(number_of_sets, ecx.split.number_of_sets, 1);
   1.547 -
   1.548 -static ssize_t show_size(struct _cpuid4_info *this_leaf, char *buf)
   1.549 -{
   1.550 -	return sprintf (buf, "%luK\n", this_leaf->size / 1024);
   1.551 -}
   1.552 -
   1.553 -static ssize_t show_shared_cpu_map(struct _cpuid4_info *this_leaf, char *buf)
   1.554 -{
   1.555 -	char mask_str[NR_CPUS];
   1.556 -	cpumask_scnprintf(mask_str, NR_CPUS, this_leaf->shared_cpu_map);
   1.557 -	return sprintf(buf, "%s\n", mask_str);
   1.558 -}
   1.559 -
   1.560 -static ssize_t show_type(struct _cpuid4_info *this_leaf, char *buf) {
   1.561 -	switch(this_leaf->eax.split.type) {
   1.562 -	    case CACHE_TYPE_DATA:
   1.563 -		return sprintf(buf, "Data\n");
   1.564 -		break;
   1.565 -	    case CACHE_TYPE_INST:
   1.566 -		return sprintf(buf, "Instruction\n");
   1.567 -		break;
   1.568 -	    case CACHE_TYPE_UNIFIED:
   1.569 -		return sprintf(buf, "Unified\n");
   1.570 -		break;
   1.571 -	    default:
   1.572 -		return sprintf(buf, "Unknown\n");
   1.573 -		break;
   1.574 -	}
   1.575 -}
   1.576 -
   1.577 -struct _cache_attr {
   1.578 -	struct attribute attr;
   1.579 -	ssize_t (*show)(struct _cpuid4_info *, char *);
   1.580 -	ssize_t (*store)(struct _cpuid4_info *, const char *, size_t count);
   1.581 -};
   1.582 -
   1.583 -#define define_one_ro(_name) \
   1.584 -static struct _cache_attr _name = \
   1.585 -	__ATTR(_name, 0444, show_##_name, NULL)
   1.586 -
   1.587 -define_one_ro(level);
   1.588 -define_one_ro(type);
   1.589 -define_one_ro(coherency_line_size);
   1.590 -define_one_ro(physical_line_partition);
   1.591 -define_one_ro(ways_of_associativity);
   1.592 -define_one_ro(number_of_sets);
   1.593 -define_one_ro(size);
   1.594 -define_one_ro(shared_cpu_map);
   1.595 -
   1.596 -static struct attribute * default_attrs[] = {
   1.597 -	&type.attr,
   1.598 -	&level.attr,
   1.599 -	&coherency_line_size.attr,
   1.600 -	&physical_line_partition.attr,
   1.601 -	&ways_of_associativity.attr,
   1.602 -	&number_of_sets.attr,
   1.603 -	&size.attr,
   1.604 -	&shared_cpu_map.attr,
   1.605 -	NULL
   1.606 -};
   1.607 -
   1.608 -#define to_object(k) container_of(k, struct _index_kobject, kobj)
   1.609 -#define to_attr(a) container_of(a, struct _cache_attr, attr)
   1.610 -
   1.611 -static ssize_t show(struct kobject * kobj, struct attribute * attr, char * buf)
   1.612 -{
   1.613 -	struct _cache_attr *fattr = to_attr(attr);
   1.614 -	struct _index_kobject *this_leaf = to_object(kobj);
   1.615 -	ssize_t ret;
   1.616 -
   1.617 -	ret = fattr->show ?
   1.618 -		fattr->show(CPUID4_INFO_IDX(this_leaf->cpu, this_leaf->index),
   1.619 -			buf) :
   1.620 -	       	0;
   1.621 -	return ret;
   1.622 -}
   1.623 -
   1.624 -static ssize_t store(struct kobject * kobj, struct attribute * attr,
   1.625 -		     const char * buf, size_t count)
   1.626 -{
   1.627 -	return 0;
   1.628 -}
   1.629 -
   1.630 -static struct sysfs_ops sysfs_ops = {
   1.631 -	.show   = show,
   1.632 -	.store  = store,
   1.633 -};
   1.634 -
   1.635 -static struct kobj_type ktype_cache = {
   1.636 -	.sysfs_ops	= &sysfs_ops,
   1.637 -	.default_attrs	= default_attrs,
   1.638 -};
   1.639 -
   1.640 -static struct kobj_type ktype_percpu_entry = {
   1.641 -	.sysfs_ops	= &sysfs_ops,
   1.642 -};
   1.643 -
   1.644 -static void cpuid4_cache_sysfs_exit(unsigned int cpu)
   1.645 -{
   1.646 -	kfree(cache_kobject[cpu]);
   1.647 -	kfree(index_kobject[cpu]);
   1.648 -	cache_kobject[cpu] = NULL;
   1.649 -	index_kobject[cpu] = NULL;
   1.650 -	free_cache_attributes(cpu);
   1.651 -}
   1.652 -
   1.653 -static int __cpuinit cpuid4_cache_sysfs_init(unsigned int cpu)
   1.654 -{
   1.655 -
   1.656 -	if (num_cache_leaves == 0)
   1.657 -		return -ENOENT;
   1.658 -
   1.659 -	detect_cache_attributes(cpu);
   1.660 -	if (cpuid4_info[cpu] == NULL)
   1.661 -		return -ENOENT;
   1.662 -
   1.663 -	/* Allocate all required memory */
   1.664 -	cache_kobject[cpu] = kmalloc(sizeof(struct kobject), GFP_KERNEL);
   1.665 -	if (unlikely(cache_kobject[cpu] == NULL))
   1.666 -		goto err_out;
   1.667 -	memset(cache_kobject[cpu], 0, sizeof(struct kobject));
   1.668 -
   1.669 -	index_kobject[cpu] = kmalloc(
   1.670 -	    sizeof(struct _index_kobject ) * num_cache_leaves, GFP_KERNEL);
   1.671 -	if (unlikely(index_kobject[cpu] == NULL))
   1.672 -		goto err_out;
   1.673 -	memset(index_kobject[cpu], 0,
   1.674 -	    sizeof(struct _index_kobject) * num_cache_leaves);
   1.675 -
   1.676 -	return 0;
   1.677 -
   1.678 -err_out:
   1.679 -	cpuid4_cache_sysfs_exit(cpu);
   1.680 -	return -ENOMEM;
   1.681 -}
   1.682 -
   1.683 -/* Add/Remove cache interface for CPU device */
   1.684 -static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
   1.685 -{
   1.686 -	unsigned int cpu = sys_dev->id;
   1.687 -	unsigned long i, j;
   1.688 -	struct _index_kobject *this_object;
   1.689 -	int retval = 0;
   1.690 -
   1.691 -	retval = cpuid4_cache_sysfs_init(cpu);
   1.692 -	if (unlikely(retval < 0))
   1.693 -		return retval;
   1.694 -
   1.695 -	cache_kobject[cpu]->parent = &sys_dev->kobj;
   1.696 -	kobject_set_name(cache_kobject[cpu], "%s", "cache");
   1.697 -	cache_kobject[cpu]->ktype = &ktype_percpu_entry;
   1.698 -	retval = kobject_register(cache_kobject[cpu]);
   1.699 -
   1.700 -	for (i = 0; i < num_cache_leaves; i++) {
   1.701 -		this_object = INDEX_KOBJECT_PTR(cpu,i);
   1.702 -		this_object->cpu = cpu;
   1.703 -		this_object->index = i;
   1.704 -		this_object->kobj.parent = cache_kobject[cpu];
   1.705 -		kobject_set_name(&(this_object->kobj), "index%1lu", i);
   1.706 -		this_object->kobj.ktype = &ktype_cache;
   1.707 -		retval = kobject_register(&(this_object->kobj));
   1.708 -		if (unlikely(retval)) {
   1.709 -			for (j = 0; j < i; j++) {
   1.710 -				kobject_unregister(
   1.711 -					&(INDEX_KOBJECT_PTR(cpu,j)->kobj));
   1.712 -			}
   1.713 -			kobject_unregister(cache_kobject[cpu]);
   1.714 -			cpuid4_cache_sysfs_exit(cpu);
   1.715 -			break;
   1.716 -		}
   1.717 -	}
   1.718 -	return retval;
   1.719 -}
   1.720 -
   1.721 -static void __cpuexit cache_remove_dev(struct sys_device * sys_dev)
   1.722 -{
   1.723 -	unsigned int cpu = sys_dev->id;
   1.724 -	unsigned long i;
   1.725 -
   1.726 -	for (i = 0; i < num_cache_leaves; i++) {
   1.727 -		cache_remove_shared_cpu_map(cpu, i);
   1.728 -		kobject_unregister(&(INDEX_KOBJECT_PTR(cpu,i)->kobj));
   1.729 -	}
   1.730 -	kobject_unregister(cache_kobject[cpu]);
   1.731 -	cpuid4_cache_sysfs_exit(cpu);
   1.732 -	return;
   1.733 -}
   1.734 -
   1.735 -static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
   1.736 -					unsigned long action, void *hcpu)
   1.737 -{
   1.738 -	unsigned int cpu = (unsigned long)hcpu;
   1.739 -	struct sys_device *sys_dev;
   1.740 -
   1.741 -	sys_dev = get_cpu_sysdev(cpu);
   1.742 -	switch (action) {
   1.743 -	case CPU_ONLINE:
   1.744 -		cache_add_dev(sys_dev);
   1.745 -		break;
   1.746 -	case CPU_DEAD:
   1.747 -		cache_remove_dev(sys_dev);
   1.748 -		break;
   1.749 -	}
   1.750 -	return NOTIFY_OK;
   1.751 -}
   1.752 -
   1.753 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier =
   1.754 -{
   1.755 -    .notifier_call = cacheinfo_cpu_callback,
   1.756 -};
   1.757 -
   1.758 -static int __cpuinit cache_sysfs_init(void)
   1.759 -{
   1.760 -	int i;
   1.761 -
   1.762 -	if (num_cache_leaves == 0)
   1.763 -		return 0;
   1.764 -
   1.765 -	register_hotcpu_notifier(&cacheinfo_cpu_notifier);
   1.766 -
   1.767 -	for_each_online_cpu(i) {
   1.768 -		cacheinfo_cpu_callback(&cacheinfo_cpu_notifier, CPU_ONLINE,
   1.769 -			(void *)(long)i);
   1.770 -	}
   1.771 -
   1.772 -	return 0;
   1.773 -}
   1.774 -
   1.775 -device_initcall(cache_sysfs_init);
   1.776 -
   1.777 -#endif
     2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Mon Mar 05 13:27:51 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/Makefile	Mon Mar 05 13:30:52 2007 +0000
     2.3 @@ -61,7 +61,6 @@ ifdef CONFIG_XEN
     2.4  time-y				+= ../../i386/kernel/time-xen.o
     2.5  pci-dma-y			+= ../../i386/kernel/pci-dma-xen.o
     2.6  microcode-$(subst m,y,$(CONFIG_MICROCODE))  := ../../i386/kernel/microcode-xen.o
     2.7 -intel_cacheinfo-y		:= ../../i386/kernel/cpu/intel_cacheinfo-xen.o
     2.8  quirks-y			:= ../../i386/kernel/quirks-xen.o
     2.9  alternative-y			:= ../../i386/kernel/alternative-xen.o
    2.10