2008-09-05 10:09:00 +07:00
|
|
|
#include <linux/bootmem.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <linux/linkage.h>
|
2008-09-05 10:09:00 +07:00
|
|
|
#include <linux/bitops.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <linux/kernel.h>
|
2008-09-05 10:09:00 +07:00
|
|
|
#include <linux/module.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/string.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/delay.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/kgdb.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <linux/smp.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <linux/io.h>
|
|
|
|
|
|
|
|
#include <asm/stackprotector.h>
|
perf: Do the big rename: Performance Counters -> Performance Events
Bye-bye Performance Counters, welcome Performance Events!
In the past few months the perfcounters subsystem has grown out its
initial role of counting hardware events, and has become (and is
becoming) a much broader generic event enumeration, reporting, logging,
monitoring, analysis facility.
Naming its core object 'perf_counter' and naming the subsystem
'perfcounters' has become more and more of a misnomer. With pending
code like hw-breakpoints support the 'counter' name is less and
less appropriate.
All in one, we've decided to rename the subsystem to 'performance
events' and to propagate this rename through all fields, variables
and API names. (in an ABI compatible fashion)
The word 'event' is also a bit shorter than 'counter' - which makes
it slightly more convenient to write/handle as well.
Thanks goes to Stephane Eranian who first observed this misnomer and
suggested a rename.
User-space tooling and ABI compatibility is not affected - this patch
should be function-invariant. (Also, defconfigs were not touched to
keep the size down.)
This patch has been generated via the following script:
FILES=$(find * -type f | grep -vE 'oprofile|[^K]config')
sed -i \
-e 's/PERF_EVENT_/PERF_RECORD_/g' \
-e 's/PERF_COUNTER/PERF_EVENT/g' \
-e 's/perf_counter/perf_event/g' \
-e 's/nb_counters/nb_events/g' \
-e 's/swcounter/swevent/g' \
-e 's/tpcounter_event/tp_event/g' \
$FILES
for N in $(find . -name perf_counter.[ch]); do
M=$(echo $N | sed 's/perf_counter/perf_event/g')
mv $N $M
done
FILES=$(find . -name perf_event.*)
sed -i \
-e 's/COUNTER_MASK/REG_MASK/g' \
-e 's/COUNTER/EVENT/g' \
-e 's/\<event\>/event_id/g' \
-e 's/counter/event/g' \
-e 's/Counter/Event/g' \
$FILES
... to keep it as correct as possible. This script can also be
used by anyone who has pending perfcounters patches - it converts
a Linux kernel tree over to the new naming. We tried to time this
change to the point in time where the amount of pending patches
is the smallest: the end of the merge window.
Namespace clashes were fixed up in a preparatory patch - and some
stylistic fallout will be fixed up in a subsequent patch.
( NOTE: 'counters' are still the proper terminology when we deal
with hardware registers - and these sed scripts are a bit
over-eager in renaming them. I've undone some of that, but
in case there's something left where 'counter' would be
better than 'event' we can undo that on an individual basis
instead of touching an otherwise nicely automated patch. )
Suggested-by: Stephane Eranian <eranian@google.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <linux-arch@vger.kernel.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-09-21 17:02:48 +07:00
|
|
|
#include <asm/perf_event.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/mmu_context.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <asm/hypervisor.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/sections.h>
|
2009-07-04 06:35:45 +07:00
|
|
|
#include <linux/topology.h>
|
|
|
|
#include <linux/cpumask.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/atomic.h>
|
|
|
|
#include <asm/proto.h>
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/apic.h>
|
|
|
|
#include <asm/desc.h>
|
|
|
|
#include <asm/i387.h>
|
2006-06-23 16:04:18 +07:00
|
|
|
#include <asm/mtrr.h>
|
2009-07-04 06:35:45 +07:00
|
|
|
#include <linux/numa.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <asm/asm.h>
|
|
|
|
#include <asm/cpu.h>
|
2006-06-23 16:04:20 +07:00
|
|
|
#include <asm/mce.h>
|
2009-03-14 12:49:49 +07:00
|
|
|
#include <asm/msr.h>
|
2008-05-08 14:18:43 +07:00
|
|
|
#include <asm/pat.h>
|
2009-02-17 20:02:01 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_X86_LOCAL_APIC
|
2009-01-21 15:26:06 +07:00
|
|
|
#include <asm/uv/uv.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "cpu.h"
|
|
|
|
|
2009-01-04 20:18:03 +07:00
|
|
|
/* all of these masks are initialized in setup_cpu_local_masks() */
|
|
|
|
cpumask_var_t cpu_initialized_mask;
|
2009-03-14 12:49:49 +07:00
|
|
|
cpumask_var_t cpu_callout_mask;
|
|
|
|
cpumask_var_t cpu_callin_mask;
|
2009-01-04 20:18:03 +07:00
|
|
|
|
|
|
|
/* representing cpus for which sibling maps can be computed */
|
|
|
|
cpumask_var_t cpu_sibling_setup_mask;
|
|
|
|
|
2009-01-27 10:56:47 +07:00
|
|
|
/* correctly size the local cpu masks */
|
2009-01-27 18:03:24 +07:00
|
|
|
void __init setup_cpu_local_masks(void)
|
2009-01-27 10:56:47 +07:00
|
|
|
{
|
|
|
|
alloc_bootmem_cpumask_var(&cpu_initialized_mask);
|
|
|
|
alloc_bootmem_cpumask_var(&cpu_callin_mask);
|
|
|
|
alloc_bootmem_cpumask_var(&cpu_callout_mask);
|
|
|
|
alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask);
|
|
|
|
}
|
|
|
|
|
2009-08-12 01:00:11 +07:00
|
|
|
static void __cpuinit default_init(struct cpuinfo_x86 *c)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_X86_64
|
2009-11-21 20:01:45 +07:00
|
|
|
cpu_detect_cache_sizes(c);
|
2009-08-12 01:00:11 +07:00
|
|
|
#else
|
|
|
|
/* Not much we can do here... */
|
|
|
|
/* Check if at least it has cpuid */
|
|
|
|
if (c->cpuid_level == -1) {
|
|
|
|
/* No cpuid. It must be an ancient CPU */
|
|
|
|
if (c->x86 == 4)
|
|
|
|
strcpy(c->x86_model_id, "486");
|
|
|
|
else if (c->x86 == 3)
|
|
|
|
strcpy(c->x86_model_id, "386");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct cpu_dev __cpuinitconst default_cpu = {
|
|
|
|
.c_init = default_init,
|
|
|
|
.c_vendor = "Unknown",
|
|
|
|
.c_x86_vendor = X86_VENDOR_UNKNOWN,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
|
2008-09-05 02:09:47 +07:00
|
|
|
|
2009-01-21 15:26:05 +07:00
|
|
|
DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
|
2008-09-05 10:09:01 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
2009-01-21 15:26:05 +07:00
|
|
|
/*
|
|
|
|
* We need valid kernel segments for data and code in long mode too
|
|
|
|
* IRET will check the segment types kkeil 2000/10/28
|
|
|
|
* Also sysret mandates a special GDT layout
|
|
|
|
*
|
2009-03-14 12:49:49 +07:00
|
|
|
* TLS descriptors are currently at a different place compared to i386.
|
2009-01-21 15:26:05 +07:00
|
|
|
* Hopefully nobody expects them at a fixed place (Wine?)
|
|
|
|
*/
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
|
2008-09-05 10:09:01 +07:00
|
|
|
#else
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
|
2007-05-03 00:27:10 +07:00
|
|
|
/*
|
|
|
|
* Segments used for calling PnP BIOS have byte granularity.
|
|
|
|
* They code segments and data segments have fixed 64k limits,
|
|
|
|
* the transfer segment sizes are set at run time.
|
|
|
|
*/
|
2008-01-30 19:31:11 +07:00
|
|
|
/* 32-bit code */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
|
2008-01-30 19:31:11 +07:00
|
|
|
/* 16-bit code */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
|
2008-01-30 19:31:11 +07:00
|
|
|
/* 16-bit data */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
|
2008-01-30 19:31:11 +07:00
|
|
|
/* 16-bit data */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
|
2008-01-30 19:31:11 +07:00
|
|
|
/* 16-bit data */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
|
2007-05-03 00:27:10 +07:00
|
|
|
/*
|
|
|
|
* The APM segments have byte granularity and their bases
|
|
|
|
* are set at run time. All have 64k limits.
|
|
|
|
*/
|
2008-01-30 19:31:11 +07:00
|
|
|
/* 32-bit code */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
|
2007-05-03 00:27:10 +07:00
|
|
|
/* 16-bit code */
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
|
2008-01-30 19:31:11 +07:00
|
|
|
/* data */
|
2009-08-03 13:47:07 +07:00
|
|
|
[GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
|
2007-05-03 00:27:10 +07:00
|
|
|
|
2009-07-18 22:12:20 +07:00
|
|
|
[GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
|
|
|
|
[GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
|
2009-02-09 20:17:40 +07:00
|
|
|
GDT_STACK_CANARY_INIT
|
2008-09-05 10:09:01 +07:00
|
|
|
#endif
|
2009-01-21 15:26:05 +07:00
|
|
|
} };
|
2007-05-03 00:27:15 +07:00
|
|
|
EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
|
2007-05-03 00:27:10 +07:00
|
|
|
|
2009-05-23 02:17:45 +07:00
|
|
|
static int __init x86_xsave_setup(char *s)
|
|
|
|
{
|
|
|
|
setup_clear_cpu_cap(X86_FEATURE_XSAVE);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("noxsave", x86_xsave_setup);
|
|
|
|
|
2008-09-05 10:09:02 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2006-03-23 17:59:33 +07:00
|
|
|
static int cachesize_override __cpuinitdata = -1;
|
|
|
|
static int disable_x86_serial_nr __cpuinitdata = 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:47 +07:00
|
|
|
static int __init cachesize_setup(char *str)
|
|
|
|
{
|
|
|
|
get_option(&str, &cachesize_override);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("cachesize=", cachesize_setup);
|
|
|
|
|
|
|
|
static int __init x86_fxsr_setup(char *s)
|
|
|
|
{
|
|
|
|
setup_clear_cpu_cap(X86_FEATURE_FXSR);
|
|
|
|
setup_clear_cpu_cap(X86_FEATURE_XMM);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("nofxsr", x86_fxsr_setup);
|
|
|
|
|
|
|
|
static int __init x86_sep_setup(char *s)
|
|
|
|
{
|
|
|
|
setup_clear_cpu_cap(X86_FEATURE_SEP);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("nosep", x86_sep_setup);
|
|
|
|
|
|
|
|
/* Standard macro to see if a specific flag is changeable */
|
|
|
|
static inline int flag_is_changeable_p(u32 flag)
|
|
|
|
{
|
|
|
|
u32 f1, f2;
|
|
|
|
|
2008-10-01 04:17:51 +07:00
|
|
|
/*
|
|
|
|
* Cyrix and IDT cpus allow disabling of CPUID
|
|
|
|
* so the code below may return different results
|
|
|
|
* when it is executed before and after enabling
|
|
|
|
* the CPUID. Add "volatile" to not allow gcc to
|
|
|
|
* optimize the subsequent calls to this function.
|
|
|
|
*/
|
2009-03-14 14:46:17 +07:00
|
|
|
asm volatile ("pushfl \n\t"
|
|
|
|
"pushfl \n\t"
|
|
|
|
"popl %0 \n\t"
|
|
|
|
"movl %0, %1 \n\t"
|
|
|
|
"xorl %2, %0 \n\t"
|
|
|
|
"pushl %0 \n\t"
|
|
|
|
"popfl \n\t"
|
|
|
|
"pushfl \n\t"
|
|
|
|
"popl %0 \n\t"
|
|
|
|
"popfl \n\t"
|
|
|
|
|
2008-10-01 04:17:51 +07:00
|
|
|
: "=&r" (f1), "=&r" (f2)
|
|
|
|
: "ir" (flag));
|
2008-09-05 02:09:47 +07:00
|
|
|
|
|
|
|
return ((f1^f2) & flag) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Probe for the CPUID instruction */
|
|
|
|
static int __cpuinit have_cpuid_p(void)
|
|
|
|
{
|
|
|
|
return flag_is_changeable_p(X86_EFLAGS_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __cpuinit squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
|
|
|
|
{
|
2009-03-14 14:46:17 +07:00
|
|
|
unsigned long lo, hi;
|
|
|
|
|
|
|
|
if (!cpu_has(c, X86_FEATURE_PN) || !disable_x86_serial_nr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Disable processor serial number: */
|
|
|
|
|
|
|
|
rdmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
|
|
|
|
lo |= 0x200000;
|
|
|
|
wrmsr(MSR_IA32_BBL_CR_CTL, lo, hi);
|
|
|
|
|
|
|
|
printk(KERN_NOTICE "CPU serial number disabled.\n");
|
|
|
|
clear_cpu_cap(c, X86_FEATURE_PN);
|
|
|
|
|
|
|
|
/* Disabling the serial number may affect the cpuid level */
|
|
|
|
c->cpuid_level = cpuid_eax(0);
|
2008-09-05 02:09:47 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init x86_serial_nr_setup(char *s)
|
|
|
|
{
|
|
|
|
disable_x86_serial_nr = 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("serialnumber", x86_serial_nr_setup);
|
2008-09-05 10:09:02 +07:00
|
|
|
#else
|
2008-09-05 10:09:13 +07:00
|
|
|
static inline int flag_is_changeable_p(u32 flag)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2008-09-05 10:09:02 +07:00
|
|
|
/* Probe for the CPUID instruction */
|
|
|
|
static inline int have_cpuid_p(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2008-09-05 10:09:13 +07:00
|
|
|
static inline void squash_the_stupid_serial_number(struct cpuinfo_x86 *c)
|
|
|
|
{
|
|
|
|
}
|
2008-09-05 10:09:02 +07:00
|
|
|
#endif
|
2008-09-05 02:09:47 +07:00
|
|
|
|
2009-01-24 08:20:50 +07:00
|
|
|
/*
|
|
|
|
* Some CPU features depend on higher CPUID levels, which may not always
|
|
|
|
* be available due to CPUID level capping or broken virtualization
|
|
|
|
* software. Add those features to this table to auto-disable them.
|
|
|
|
*/
|
|
|
|
struct cpuid_dependent_feature {
|
|
|
|
u32 feature;
|
|
|
|
u32 level;
|
|
|
|
};
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2009-01-24 08:20:50 +07:00
|
|
|
static const struct cpuid_dependent_feature __cpuinitconst
|
|
|
|
cpuid_dependent_features[] = {
|
|
|
|
{ X86_FEATURE_MWAIT, 0x00000005 },
|
|
|
|
{ X86_FEATURE_DCA, 0x00000009 },
|
|
|
|
{ X86_FEATURE_XSAVE, 0x0000000d },
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void __cpuinit filter_cpuid_features(struct cpuinfo_x86 *c, bool warn)
|
|
|
|
{
|
|
|
|
const struct cpuid_dependent_feature *df;
|
2009-03-14 12:49:49 +07:00
|
|
|
|
2009-01-24 08:20:50 +07:00
|
|
|
for (df = cpuid_dependent_features; df->feature; df++) {
|
2009-03-14 14:46:17 +07:00
|
|
|
|
|
|
|
if (!cpu_has(c, df->feature))
|
|
|
|
continue;
|
2009-01-24 08:20:50 +07:00
|
|
|
/*
|
|
|
|
* Note: cpuid_level is set to -1 if unavailable, but
|
|
|
|
* extended_extended_level is set to 0 if unavailable
|
|
|
|
* and the legitimate extended levels are all negative
|
|
|
|
* when signed; hence the weird messing around with
|
|
|
|
* signs here...
|
|
|
|
*/
|
2009-03-14 14:46:17 +07:00
|
|
|
if (!((s32)df->level < 0 ?
|
2009-02-15 14:59:18 +07:00
|
|
|
(u32)df->level > (u32)c->extended_cpuid_level :
|
2009-03-14 14:46:17 +07:00
|
|
|
(s32)df->level > (s32)c->cpuid_level))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
clear_cpu_cap(c, df->feature);
|
|
|
|
if (!warn)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"CPU: CPU feature %s disabled, no CPUID level 0x%x\n",
|
|
|
|
x86_cap_flags[df->feature], df->level);
|
2009-01-24 08:20:50 +07:00
|
|
|
}
|
2009-02-15 14:59:18 +07:00
|
|
|
}
|
2009-01-24 08:20:50 +07:00
|
|
|
|
2008-09-05 10:09:13 +07:00
|
|
|
/*
|
|
|
|
* Naming convention should be: <Name> [(<Codename>)]
|
|
|
|
* This table only is used unless init_<vendor>() below doesn't set it;
|
2009-03-14 14:46:17 +07:00
|
|
|
* in particular, if CPUID levels 0x80000002..4 are supported, this
|
|
|
|
* isn't used
|
2008-09-05 10:09:13 +07:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Look up CPU names by table lookup. */
|
2009-03-12 19:08:49 +07:00
|
|
|
static const char *__cpuinit table_lookup_model(struct cpuinfo_x86 *c)
|
2008-09-05 10:09:13 +07:00
|
|
|
{
|
2009-03-12 19:08:49 +07:00
|
|
|
const struct cpu_model_info *info;
|
2008-09-05 10:09:13 +07:00
|
|
|
|
|
|
|
if (c->x86_model >= 16)
|
|
|
|
return NULL; /* Range check */
|
|
|
|
|
|
|
|
if (!this_cpu)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
info = this_cpu->c_models;
|
|
|
|
|
|
|
|
while (info && info->family) {
|
|
|
|
if (info->family == c->x86)
|
|
|
|
return info->model_names[c->x86_model];
|
|
|
|
info++;
|
|
|
|
}
|
|
|
|
return NULL; /* Not found */
|
|
|
|
}
|
|
|
|
|
2009-05-10 13:47:42 +07:00
|
|
|
__u32 cpu_caps_cleared[NCAPINTS] __cpuinitdata;
|
|
|
|
__u32 cpu_caps_set[NCAPINTS] __cpuinitdata;
|
2008-01-30 19:33:20 +07:00
|
|
|
|
2009-01-30 15:47:54 +07:00
|
|
|
void load_percpu_segment(int cpu)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
loadsegment(fs, __KERNEL_PERCPU);
|
|
|
|
#else
|
|
|
|
loadsegment(gs, 0);
|
|
|
|
wrmsrl(MSR_GS_BASE, (unsigned long)per_cpu(irq_stack_union.gs_base, cpu));
|
|
|
|
#endif
|
2009-02-09 20:17:40 +07:00
|
|
|
load_stack_canary_segment();
|
2009-01-30 15:47:54 +07:00
|
|
|
}
|
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
/*
|
|
|
|
* Current gdt points %fs at the "master" per-cpu area: after this,
|
|
|
|
* it's on the real one.
|
|
|
|
*/
|
2009-01-30 15:47:53 +07:00
|
|
|
void switch_to_new_gdt(int cpu)
|
2008-09-05 02:09:44 +07:00
|
|
|
{
|
|
|
|
struct desc_ptr gdt_descr;
|
|
|
|
|
2009-01-27 10:56:48 +07:00
|
|
|
gdt_descr.address = (long)get_cpu_gdt_table(cpu);
|
2008-09-05 02:09:44 +07:00
|
|
|
gdt_descr.size = GDT_SIZE - 1;
|
|
|
|
load_gdt(&gdt_descr);
|
2009-01-27 10:56:48 +07:00
|
|
|
/* Reload the per-cpu base */
|
2009-01-30 15:47:54 +07:00
|
|
|
|
|
|
|
load_percpu_segment(cpu);
|
2008-09-05 02:09:44 +07:00
|
|
|
}
|
|
|
|
|
2009-03-12 19:08:49 +07:00
|
|
|
static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {};
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-06 15:52:27 +07:00
|
|
|
static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
unsigned int *v;
|
|
|
|
char *p, *q;
|
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
if (c->extended_cpuid_level < 0x80000004)
|
2008-09-06 15:52:27 +07:00
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
v = (unsigned int *)c->x86_model_id;
|
2005-04-17 05:20:36 +07:00
|
|
|
cpuid(0x80000002, &v[0], &v[1], &v[2], &v[3]);
|
|
|
|
cpuid(0x80000003, &v[4], &v[5], &v[6], &v[7]);
|
|
|
|
cpuid(0x80000004, &v[8], &v[9], &v[10], &v[11]);
|
|
|
|
c->x86_model_id[48] = 0;
|
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
/*
|
|
|
|
* Intel chips right-justify this string for some dumb reason;
|
|
|
|
* undo that brain damage:
|
|
|
|
*/
|
2005-04-17 05:20:36 +07:00
|
|
|
p = q = &c->x86_model_id[0];
|
2008-02-24 17:58:13 +07:00
|
|
|
while (*p == ' ')
|
2009-03-14 12:49:49 +07:00
|
|
|
p++;
|
2008-02-24 17:58:13 +07:00
|
|
|
if (p != q) {
|
2009-03-14 12:49:49 +07:00
|
|
|
while (*p)
|
|
|
|
*q++ = *p++;
|
|
|
|
while (q <= &c->x86_model_id[48])
|
|
|
|
*q++ = '\0'; /* Zero-pad the rest */
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-21 20:01:45 +07:00
|
|
|
void __cpuinit cpu_detect_cache_sizes(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-09-05 02:09:44 +07:00
|
|
|
unsigned int n, dummy, ebx, ecx, edx, l2size;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
n = c->extended_cpuid_level;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (n >= 0x80000005) {
|
2008-09-05 02:09:44 +07:00
|
|
|
cpuid(0x80000005, &dummy, &ebx, &ecx, &edx);
|
|
|
|
c->x86_cache_size = (ecx>>24) + (edx>>24);
|
2008-09-05 10:09:07 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
/* On K8 L1 TLB is inclusive, so don't count it */
|
|
|
|
c->x86_tlbsize = 0;
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (n < 0x80000006) /* Some chips just has a large L1. */
|
|
|
|
return;
|
|
|
|
|
2008-09-05 02:09:47 +07:00
|
|
|
cpuid(0x80000006, &dummy, &ebx, &ecx, &edx);
|
2005-04-17 05:20:36 +07:00
|
|
|
l2size = ecx >> 16;
|
2008-02-24 17:58:13 +07:00
|
|
|
|
2008-09-05 10:09:07 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
c->x86_tlbsize += ((ebx >> 16) & 0xfff) + (ebx & 0xfff);
|
|
|
|
#else
|
2005-04-17 05:20:36 +07:00
|
|
|
/* do processor-specific cache resizing */
|
|
|
|
if (this_cpu->c_size_cache)
|
2008-02-24 17:58:13 +07:00
|
|
|
l2size = this_cpu->c_size_cache(c, l2size);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* Allow user to override all this if necessary. */
|
|
|
|
if (cachesize_override != -1)
|
|
|
|
l2size = cachesize_override;
|
|
|
|
|
2008-02-24 17:58:13 +07:00
|
|
|
if (l2size == 0)
|
2005-04-17 05:20:36 +07:00
|
|
|
return; /* Again, no L2 cache is possible */
|
2008-09-05 10:09:07 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
c->x86_cache_size = l2size;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
void __cpuinit detect_ht(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-09-05 10:08:59 +07:00
|
|
|
#ifdef CONFIG_X86_HT
|
2008-09-05 02:09:47 +07:00
|
|
|
u32 eax, ebx, ecx, edx;
|
|
|
|
int index_msb, core_bits;
|
2009-12-11 08:19:36 +07:00
|
|
|
static bool printed;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:47 +07:00
|
|
|
if (!cpu_has(c, X86_FEATURE_HT))
|
2008-09-05 02:09:44 +07:00
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:47 +07:00
|
|
|
if (cpu_has(c, X86_FEATURE_CMP_LEGACY))
|
|
|
|
goto out;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 10:09:08 +07:00
|
|
|
if (cpu_has(c, X86_FEATURE_XTOPOLOGY))
|
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:47 +07:00
|
|
|
cpuid(1, &eax, &ebx, &ecx, &edx);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
smp_num_siblings = (ebx & 0xff0000) >> 16;
|
|
|
|
|
|
|
|
if (smp_num_siblings == 1) {
|
2009-12-11 08:19:36 +07:00
|
|
|
printk_once(KERN_INFO "CPU0: Hyper-Threading is disabled\n");
|
2009-03-14 14:46:17 +07:00
|
|
|
goto out;
|
|
|
|
}
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
if (smp_num_siblings <= 1)
|
|
|
|
goto out;
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
if (smp_num_siblings > nr_cpu_ids) {
|
|
|
|
pr_warning("CPU: Unsupported number of siblings %d",
|
|
|
|
smp_num_siblings);
|
|
|
|
smp_num_siblings = 1;
|
|
|
|
return;
|
|
|
|
}
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
index_msb = get_count_order(smp_num_siblings);
|
|
|
|
c->phys_proc_id = apic->phys_pkg_id(c->initial_apicid, index_msb);
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
smp_num_siblings = smp_num_siblings / c->x86_max_cores;
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
index_msb = get_count_order(smp_num_siblings);
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
core_bits = get_count_order(c->x86_max_cores);
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
c->cpu_core_id = apic->phys_pkg_id(c->initial_apicid, index_msb) &
|
|
|
|
((1 << core_bits) - 1);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:47 +07:00
|
|
|
out:
|
2009-12-11 08:19:36 +07:00
|
|
|
if (!printed && (c->x86_max_cores * smp_num_siblings) > 1) {
|
2008-09-05 02:09:47 +07:00
|
|
|
printk(KERN_INFO "CPU: Physical Processor ID: %d\n",
|
|
|
|
c->phys_proc_id);
|
|
|
|
printk(KERN_INFO "CPU: Processor Core ID: %d\n",
|
|
|
|
c->cpu_core_id);
|
2009-12-11 08:19:36 +07:00
|
|
|
printed = 1;
|
2008-09-05 02:09:44 +07:00
|
|
|
}
|
|
|
|
#endif
|
2008-09-05 10:08:59 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
static void __cpuinit get_cpu_vendor(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
char *v = c->x86_vendor_id;
|
2009-03-14 14:46:17 +07:00
|
|
|
int i;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
for (i = 0; i < X86_VENDOR_NUM; i++) {
|
2008-09-05 02:09:45 +07:00
|
|
|
if (!cpu_devs[i])
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!strcmp(v, cpu_devs[i]->c_ident[0]) ||
|
|
|
|
(cpu_devs[i]->c_ident[1] &&
|
|
|
|
!strcmp(v, cpu_devs[i]->c_ident[1]))) {
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 02:09:45 +07:00
|
|
|
this_cpu = cpu_devs[i];
|
|
|
|
c->x86_vendor = this_cpu->c_x86_vendor;
|
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
2008-09-05 02:09:45 +07:00
|
|
|
|
2009-06-17 05:33:44 +07:00
|
|
|
printk_once(KERN_ERR
|
|
|
|
"CPU: vendor_id '%s' unknown, using generic init.\n" \
|
|
|
|
"CPU: Your system may be unstable.\n", v);
|
2008-09-05 02:09:45 +07:00
|
|
|
|
2006-02-05 14:28:03 +07:00
|
|
|
c->x86_vendor = X86_VENDOR_UNKNOWN;
|
|
|
|
this_cpu = &default_cpu;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
void __cpuinit cpu_detect(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
/* Get vendor name */
|
2008-02-01 23:49:43 +07:00
|
|
|
cpuid(0x00000000, (unsigned int *)&c->cpuid_level,
|
|
|
|
(unsigned int *)&c->x86_vendor_id[0],
|
|
|
|
(unsigned int *)&c->x86_vendor_id[8],
|
|
|
|
(unsigned int *)&c->x86_vendor_id[4]);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
c->x86 = 4;
|
2008-09-05 02:09:44 +07:00
|
|
|
/* Intel-defined flags: level 0x00000001 */
|
2005-04-17 05:20:36 +07:00
|
|
|
if (c->cpuid_level >= 0x00000001) {
|
|
|
|
u32 junk, tfms, cap0, misc;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
cpuid(0x00000001, &tfms, &misc, &junk, &cap0);
|
2008-09-05 02:09:44 +07:00
|
|
|
c->x86 = (tfms >> 8) & 0xf;
|
|
|
|
c->x86_model = (tfms >> 4) & 0xf;
|
|
|
|
c->x86_mask = tfms & 0xf;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2005-11-05 23:25:53 +07:00
|
|
|
if (c->x86 == 0xf)
|
2005-04-17 05:20:36 +07:00
|
|
|
c->x86 += (tfms >> 20) & 0xff;
|
2005-11-05 23:25:53 +07:00
|
|
|
if (c->x86 >= 0x6)
|
2008-09-05 02:09:44 +07:00
|
|
|
c->x86_model += ((tfms >> 16) & 0xf) << 4;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-02-01 04:05:45 +07:00
|
|
|
if (cap0 & (1<<19)) {
|
|
|
|
c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
|
2008-09-05 02:09:44 +07:00
|
|
|
c->x86_cache_alignment = c->x86_clflush_size;
|
2008-02-01 04:05:45 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
}
|
2008-09-05 02:09:44 +07:00
|
|
|
|
|
|
|
static void __cpuinit get_cpu_cap(struct cpuinfo_x86 *c)
|
2008-01-30 19:33:32 +07:00
|
|
|
{
|
|
|
|
u32 tfms, xlvl;
|
2008-09-05 02:09:44 +07:00
|
|
|
u32 ebx;
|
2008-01-30 19:33:32 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
/* Intel-defined flags: level 0x00000001 */
|
|
|
|
if (c->cpuid_level >= 0x00000001) {
|
|
|
|
u32 capability, excap;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
cpuid(0x00000001, &tfms, &ebx, &excap, &capability);
|
|
|
|
c->x86_capability[0] = capability;
|
|
|
|
c->x86_capability[4] = excap;
|
|
|
|
}
|
2008-01-30 19:33:32 +07:00
|
|
|
|
2010-07-08 07:29:18 +07:00
|
|
|
/* Additional Intel-defined flags: level 0x00000007 */
|
|
|
|
if (c->cpuid_level >= 0x00000007) {
|
|
|
|
u32 eax, ebx, ecx, edx;
|
|
|
|
|
|
|
|
cpuid_count(0x00000007, 0, &eax, &ebx, &ecx, &edx);
|
|
|
|
|
|
|
|
if (eax > 0)
|
|
|
|
c->x86_capability[9] = ebx;
|
|
|
|
}
|
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
/* AMD-defined flags: level 0x80000001 */
|
|
|
|
xlvl = cpuid_eax(0x80000000);
|
|
|
|
c->extended_cpuid_level = xlvl;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
if ((xlvl & 0xffff0000) == 0x80000000) {
|
|
|
|
if (xlvl >= 0x80000001) {
|
|
|
|
c->x86_capability[1] = cpuid_edx(0x80000001);
|
|
|
|
c->x86_capability[6] = cpuid_ecx(0x80000001);
|
2008-01-30 19:33:32 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-05 10:09:09 +07:00
|
|
|
if (c->extended_cpuid_level >= 0x80000008) {
|
|
|
|
u32 eax = cpuid_eax(0x80000008);
|
|
|
|
|
|
|
|
c->x86_virt_bits = (eax >> 8) & 0xff;
|
|
|
|
c->x86_phys_bits = eax & 0xff;
|
2008-01-30 19:33:32 +07:00
|
|
|
}
|
2009-03-12 19:37:34 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
else if (cpu_has(c, X86_FEATURE_PAE) || cpu_has(c, X86_FEATURE_PSE36))
|
|
|
|
c->x86_phys_bits = 36;
|
2008-09-05 10:09:09 +07:00
|
|
|
#endif
|
2008-09-06 15:52:28 +07:00
|
|
|
|
|
|
|
if (c->extended_cpuid_level >= 0x80000007)
|
|
|
|
c->x86_power = cpuid_edx(0x80000007);
|
2008-01-30 19:33:32 +07:00
|
|
|
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-14 16:33:15 +07:00
|
|
|
static void __cpuinit identify_cpu_without_cpuid(struct cpuinfo_x86 *c)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First of all, decide if this is a 486 or higher
|
|
|
|
* It's a 486 if we can modify the AC flag
|
|
|
|
*/
|
|
|
|
if (flag_is_changeable_p(X86_EFLAGS_AC))
|
|
|
|
c->x86 = 4;
|
|
|
|
else
|
|
|
|
c->x86 = 3;
|
|
|
|
|
|
|
|
for (i = 0; i < X86_VENDOR_NUM; i++)
|
|
|
|
if (cpu_devs[i] && cpu_devs[i]->c_identify) {
|
|
|
|
c->x86_vendor_id[0] = 0;
|
|
|
|
cpu_devs[i]->c_identify(c);
|
|
|
|
if (c->x86_vendor_id[0]) {
|
|
|
|
get_cpu_vendor(c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-02-24 17:58:13 +07:00
|
|
|
/*
|
|
|
|
* Do minimum CPU detection early.
|
|
|
|
* Fields really needed: vendor, cpuid_level, family, model, mask,
|
|
|
|
* cache alignment.
|
|
|
|
* The others are not touched to avoid unwanted side effects.
|
|
|
|
*
|
|
|
|
* WARNING: this function is only called on the BP. Don't add code here
|
|
|
|
* that is supposed to run on all CPUs.
|
|
|
|
*/
|
2008-09-05 02:09:44 +07:00
|
|
|
static void __init early_identify_cpu(struct cpuinfo_x86 *c)
|
2006-12-07 08:14:08 +07:00
|
|
|
{
|
2008-09-05 10:09:10 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
c->x86_clflush_size = 64;
|
2009-03-12 19:37:34 +07:00
|
|
|
c->x86_phys_bits = 36;
|
|
|
|
c->x86_virt_bits = 48;
|
2008-09-05 10:09:10 +07:00
|
|
|
#else
|
2008-02-01 04:05:45 +07:00
|
|
|
c->x86_clflush_size = 32;
|
2009-03-12 19:37:34 +07:00
|
|
|
c->x86_phys_bits = 32;
|
|
|
|
c->x86_virt_bits = 32;
|
2008-09-05 10:09:10 +07:00
|
|
|
#endif
|
2008-09-05 02:09:47 +07:00
|
|
|
c->x86_cache_alignment = c->x86_clflush_size;
|
2006-12-07 08:14:08 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
memset(&c->x86_capability, 0, sizeof c->x86_capability);
|
2008-09-05 02:09:47 +07:00
|
|
|
c->extended_cpuid_level = 0;
|
2006-12-07 08:14:08 +07:00
|
|
|
|
2008-09-14 16:33:15 +07:00
|
|
|
if (!have_cpuid_p())
|
|
|
|
identify_cpu_without_cpuid(c);
|
|
|
|
|
|
|
|
/* cyrix could have cpuid enabled via c_identify()*/
|
2006-12-07 08:14:08 +07:00
|
|
|
if (!have_cpuid_p())
|
|
|
|
return;
|
|
|
|
|
|
|
|
cpu_detect(c);
|
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
get_cpu_vendor(c);
|
2008-01-30 19:32:40 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
get_cpu_cap(c);
|
2008-09-05 02:09:43 +07:00
|
|
|
|
2008-09-05 02:09:45 +07:00
|
|
|
if (this_cpu->c_early_init)
|
|
|
|
this_cpu->c_early_init(c);
|
2008-01-30 19:33:32 +07:00
|
|
|
|
2008-10-31 06:43:03 +07:00
|
|
|
#ifdef CONFIG_SMP
|
2008-10-31 04:13:37 +07:00
|
|
|
c->cpu_index = boot_cpu_id;
|
2008-10-31 06:43:03 +07:00
|
|
|
#endif
|
2009-01-24 08:20:50 +07:00
|
|
|
filter_cpuid_features(c, false);
|
2006-12-07 08:14:08 +07:00
|
|
|
}
|
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
void __init early_cpu_init(void)
|
|
|
|
{
|
2009-03-12 19:08:49 +07:00
|
|
|
const struct cpu_dev *const *cdev;
|
2008-09-05 02:09:45 +07:00
|
|
|
int count = 0;
|
|
|
|
|
2009-11-14 16:34:41 +07:00
|
|
|
#ifdef PROCESSOR_SELECT
|
2009-03-14 12:49:49 +07:00
|
|
|
printk(KERN_INFO "KERNEL supported cpus:\n");
|
2009-11-14 16:34:41 +07:00
|
|
|
#endif
|
|
|
|
|
2008-09-05 02:09:45 +07:00
|
|
|
for (cdev = __x86_cpu_dev_start; cdev < __x86_cpu_dev_end; cdev++) {
|
2009-03-12 19:08:49 +07:00
|
|
|
const struct cpu_dev *cpudev = *cdev;
|
2008-09-05 02:09:44 +07:00
|
|
|
|
2008-09-05 02:09:45 +07:00
|
|
|
if (count >= X86_VENDOR_NUM)
|
|
|
|
break;
|
|
|
|
cpu_devs[count] = cpudev;
|
|
|
|
count++;
|
|
|
|
|
2009-11-14 16:34:41 +07:00
|
|
|
#ifdef PROCESSOR_SELECT
|
|
|
|
{
|
|
|
|
unsigned int j;
|
|
|
|
|
|
|
|
for (j = 0; j < 2; j++) {
|
|
|
|
if (!cpudev->c_ident[j])
|
|
|
|
continue;
|
|
|
|
printk(KERN_INFO " %s %s\n", cpudev->c_vendor,
|
|
|
|
cpudev->c_ident[j]);
|
|
|
|
}
|
2008-09-05 02:09:45 +07:00
|
|
|
}
|
2009-11-14 03:30:00 +07:00
|
|
|
#endif
|
2008-09-05 02:09:45 +07:00
|
|
|
}
|
2008-09-05 02:09:44 +07:00
|
|
|
early_identify_cpu(&boot_cpu_data);
|
2006-12-07 08:14:08 +07:00
|
|
|
}
|
2008-01-30 19:33:32 +07:00
|
|
|
|
2008-08-19 07:39:32 +07:00
|
|
|
/*
|
|
|
|
* The NOPL instruction is supposed to exist on all CPUs with
|
2008-09-16 23:29:40 +07:00
|
|
|
* family >= 6; unfortunately, that's not true in practice because
|
2008-08-19 07:39:32 +07:00
|
|
|
* of early VIA chips and (more importantly) broken virtualizers that
|
2008-09-16 23:29:40 +07:00
|
|
|
* are not easy to detect. In the latter case it doesn't even *fail*
|
|
|
|
* reliably, so probing for it doesn't even work. Disable it completely
|
|
|
|
* unless we can find a reliable way to detect all the broken cases.
|
2008-08-19 07:39:32 +07:00
|
|
|
*/
|
|
|
|
static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
|
|
|
|
{
|
|
|
|
clear_cpu_cap(c, X86_FEATURE_NOPL);
|
2006-12-07 08:14:08 +07:00
|
|
|
}
|
|
|
|
|
2008-02-24 17:58:13 +07:00
|
|
|
static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-09-14 16:33:15 +07:00
|
|
|
c->extended_cpuid_level = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
if (!have_cpuid_p())
|
2008-09-14 16:33:15 +07:00
|
|
|
identify_cpu_without_cpuid(c);
|
2007-07-12 02:18:32 +07:00
|
|
|
|
2008-09-14 16:33:15 +07:00
|
|
|
/* cyrix could have cpuid enabled via c_identify()*/
|
2008-09-14 19:46:58 +07:00
|
|
|
if (!have_cpuid_p())
|
2008-09-14 16:33:15 +07:00
|
|
|
return;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
cpu_detect(c);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
get_cpu_vendor(c);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
get_cpu_cap(c);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
if (c->cpuid_level >= 0x00000001) {
|
|
|
|
c->initial_apicid = (cpuid_ebx(1) >> 24) & 0xFF;
|
2008-09-05 10:09:12 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
|
|
|
# ifdef CONFIG_X86_HT
|
2009-01-28 19:24:54 +07:00
|
|
|
c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
|
2008-09-05 10:09:12 +07:00
|
|
|
# else
|
2008-09-05 02:09:44 +07:00
|
|
|
c->apicid = c->initial_apicid;
|
2008-09-05 10:09:12 +07:00
|
|
|
# endif
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 10:09:12 +07:00
|
|
|
#ifdef CONFIG_X86_HT
|
|
|
|
c->phys_proc_id = c->initial_apicid;
|
2006-03-27 16:15:22 +07:00
|
|
|
#endif
|
2008-09-05 02:09:44 +07:00
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-06 15:52:27 +07:00
|
|
|
get_model_name(c); /* Default name */
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
init_scattered_cpuid_features(c);
|
|
|
|
detect_nopl(c);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This does the hard work of actually picking apart the CPU stuff...
|
|
|
|
*/
|
2008-06-21 17:24:00 +07:00
|
|
|
static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
c->loops_per_jiffy = loops_per_jiffy;
|
|
|
|
c->x86_cache_size = -1;
|
|
|
|
c->x86_vendor = X86_VENDOR_UNKNOWN;
|
|
|
|
c->x86_model = c->x86_mask = 0; /* So far unknown... */
|
|
|
|
c->x86_vendor_id[0] = '\0'; /* Unset */
|
|
|
|
c->x86_model_id[0] = '\0'; /* Unset */
|
2005-11-05 23:25:54 +07:00
|
|
|
c->x86_max_cores = 1;
|
2008-09-05 10:09:13 +07:00
|
|
|
c->x86_coreid_bits = 0;
|
2008-09-08 07:58:50 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
2008-09-05 10:09:13 +07:00
|
|
|
c->x86_clflush_size = 64;
|
2009-03-12 19:37:34 +07:00
|
|
|
c->x86_phys_bits = 36;
|
|
|
|
c->x86_virt_bits = 48;
|
2008-09-05 10:09:13 +07:00
|
|
|
#else
|
|
|
|
c->cpuid_level = -1; /* CPUID not detected */
|
2006-12-07 08:14:05 +07:00
|
|
|
c->x86_clflush_size = 32;
|
2009-03-12 19:37:34 +07:00
|
|
|
c->x86_phys_bits = 32;
|
|
|
|
c->x86_virt_bits = 32;
|
2008-09-05 10:09:13 +07:00
|
|
|
#endif
|
|
|
|
c->x86_cache_alignment = c->x86_clflush_size;
|
2005-04-17 05:20:36 +07:00
|
|
|
memset(&c->x86_capability, 0, sizeof c->x86_capability);
|
|
|
|
|
|
|
|
generic_identify(c);
|
|
|
|
|
2008-01-30 19:32:49 +07:00
|
|
|
if (this_cpu->c_identify)
|
2005-04-17 05:20:36 +07:00
|
|
|
this_cpu->c_identify(c);
|
|
|
|
|
2009-05-16 03:05:16 +07:00
|
|
|
/* Clear/Set all flags overriden by options, after probe */
|
|
|
|
for (i = 0; i < NCAPINTS; i++) {
|
|
|
|
c->x86_capability[i] &= ~cpu_caps_cleared[i];
|
|
|
|
c->x86_capability[i] |= cpu_caps_set[i];
|
|
|
|
}
|
|
|
|
|
2008-09-05 10:09:13 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
2009-01-28 19:24:54 +07:00
|
|
|
c->apicid = apic->phys_pkg_id(c->initial_apicid, 0);
|
2008-09-05 10:09:13 +07:00
|
|
|
#endif
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Vendor-specific initialization. In this section we
|
|
|
|
* canonicalize the feature flags, meaning if there are
|
|
|
|
* features a certain CPU supports which CPUID doesn't
|
|
|
|
* tell us, CPUID claiming incorrect flags, or other bugs,
|
|
|
|
* we handle them here.
|
|
|
|
*
|
|
|
|
* At the end of this section, c->x86_capability better
|
|
|
|
* indicate the features this CPU genuinely supports!
|
|
|
|
*/
|
|
|
|
if (this_cpu->c_init)
|
|
|
|
this_cpu->c_init(c);
|
|
|
|
|
|
|
|
/* Disable the PN if appropriate */
|
|
|
|
squash_the_stupid_serial_number(c);
|
|
|
|
|
|
|
|
/*
|
2009-03-14 14:46:17 +07:00
|
|
|
* The vendor-specific functions might have changed features.
|
|
|
|
* Now we do "generic changes."
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2009-01-24 08:20:50 +07:00
|
|
|
/* Filter out anything that depends on CPUID levels we don't have */
|
|
|
|
filter_cpuid_features(c, true);
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* If the model name is still unset, do table lookup. */
|
2008-02-24 17:58:13 +07:00
|
|
|
if (!c->x86_model_id[0]) {
|
2009-03-12 19:08:49 +07:00
|
|
|
const char *p;
|
2005-04-17 05:20:36 +07:00
|
|
|
p = table_lookup_model(c);
|
2008-02-24 17:58:13 +07:00
|
|
|
if (p)
|
2005-04-17 05:20:36 +07:00
|
|
|
strcpy(c->x86_model_id, p);
|
|
|
|
else
|
|
|
|
/* Last resort... */
|
|
|
|
sprintf(c->x86_model_id, "%02x/%02x",
|
2006-03-23 17:59:36 +07:00
|
|
|
c->x86, c->x86_model);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-09-05 10:09:13 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
detect_ht(c);
|
|
|
|
#endif
|
|
|
|
|
2008-10-28 00:41:46 +07:00
|
|
|
init_hypervisor(c);
|
2009-05-10 13:47:42 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear/Set all flags overriden by options, need do it
|
|
|
|
* before following smp all cpus cap AND.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < NCAPINTS; i++) {
|
|
|
|
c->x86_capability[i] &= ~cpu_caps_cleared[i];
|
|
|
|
c->x86_capability[i] |= cpu_caps_set[i];
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* On SMP, boot_cpu_data holds the common feature set between
|
|
|
|
* all CPUs; so make sure that we indicate which features are
|
|
|
|
* common between the CPUs. The first time this routine gets
|
|
|
|
* executed, c == &boot_cpu_data.
|
|
|
|
*/
|
2008-02-24 17:58:13 +07:00
|
|
|
if (c != &boot_cpu_data) {
|
2005-04-17 05:20:36 +07:00
|
|
|
/* AND the already accumulated flags with these */
|
2008-09-05 02:09:44 +07:00
|
|
|
for (i = 0; i < NCAPINTS; i++)
|
2005-04-17 05:20:36 +07:00
|
|
|
boot_cpu_data.x86_capability[i] &= c->x86_capability[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init Machine Check Exception if available. */
|
2009-10-16 17:31:32 +07:00
|
|
|
mcheck_cpu_init(c);
|
2008-01-30 19:33:16 +07:00
|
|
|
|
|
|
|
select_idle_routine(c);
|
2008-09-05 10:09:13 +07:00
|
|
|
|
|
|
|
#if defined(CONFIG_NUMA) && defined(CONFIG_X86_64)
|
|
|
|
numa_add_cpu(smp_processor_id());
|
|
|
|
#endif
|
2007-05-03 00:27:12 +07:00
|
|
|
}
|
2005-11-07 15:58:42 +07:00
|
|
|
|
2008-09-23 00:35:08 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
static void vgetcpu_set_mode(void)
|
|
|
|
{
|
|
|
|
if (cpu_has(&boot_cpu_data, X86_FEATURE_RDTSCP))
|
|
|
|
vgetcpu_mode = VGETCPU_RDTSCP;
|
|
|
|
else
|
|
|
|
vgetcpu_mode = VGETCPU_LSL;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-05-03 00:27:12 +07:00
|
|
|
void __init identify_boot_cpu(void)
|
|
|
|
{
|
|
|
|
identify_cpu(&boot_cpu_data);
|
2009-03-17 11:20:34 +07:00
|
|
|
init_c1e_mask();
|
2008-09-05 10:09:13 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2007-05-03 00:27:12 +07:00
|
|
|
sysenter_setup();
|
2005-06-26 04:54:53 +07:00
|
|
|
enable_sep_cpu();
|
2008-09-23 00:35:08 +07:00
|
|
|
#else
|
|
|
|
vgetcpu_set_mode();
|
2008-09-05 10:09:13 +07:00
|
|
|
#endif
|
perf: Do the big rename: Performance Counters -> Performance Events
Bye-bye Performance Counters, welcome Performance Events!
In the past few months the perfcounters subsystem has grown out its
initial role of counting hardware events, and has become (and is
becoming) a much broader generic event enumeration, reporting, logging,
monitoring, analysis facility.
Naming its core object 'perf_counter' and naming the subsystem
'perfcounters' has become more and more of a misnomer. With pending
code like hw-breakpoints support the 'counter' name is less and
less appropriate.
All in one, we've decided to rename the subsystem to 'performance
events' and to propagate this rename through all fields, variables
and API names. (in an ABI compatible fashion)
The word 'event' is also a bit shorter than 'counter' - which makes
it slightly more convenient to write/handle as well.
Thanks goes to Stephane Eranian who first observed this misnomer and
suggested a rename.
User-space tooling and ABI compatibility is not affected - this patch
should be function-invariant. (Also, defconfigs were not touched to
keep the size down.)
This patch has been generated via the following script:
FILES=$(find * -type f | grep -vE 'oprofile|[^K]config')
sed -i \
-e 's/PERF_EVENT_/PERF_RECORD_/g' \
-e 's/PERF_COUNTER/PERF_EVENT/g' \
-e 's/perf_counter/perf_event/g' \
-e 's/nb_counters/nb_events/g' \
-e 's/swcounter/swevent/g' \
-e 's/tpcounter_event/tp_event/g' \
$FILES
for N in $(find . -name perf_counter.[ch]); do
M=$(echo $N | sed 's/perf_counter/perf_event/g')
mv $N $M
done
FILES=$(find . -name perf_event.*)
sed -i \
-e 's/COUNTER_MASK/REG_MASK/g' \
-e 's/COUNTER/EVENT/g' \
-e 's/\<event\>/event_id/g' \
-e 's/counter/event/g' \
-e 's/Counter/Event/g' \
$FILES
... to keep it as correct as possible. This script can also be
used by anyone who has pending perfcounters patches - it converts
a Linux kernel tree over to the new naming. We tried to time this
change to the point in time where the amount of pending patches
is the smallest: the end of the merge window.
Namespace clashes were fixed up in a preparatory patch - and some
stylistic fallout will be fixed up in a subsequent patch.
( NOTE: 'counters' are still the proper terminology when we deal
with hardware registers - and these sed scripts are a bit
over-eager in renaming them. I've undone some of that, but
in case there's something left where 'counter' would be
better than 'event' we can undo that on an individual basis
instead of touching an otherwise nicely automated patch. )
Suggested-by: Stephane Eranian <eranian@google.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <linux-arch@vger.kernel.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-09-21 17:02:48 +07:00
|
|
|
init_hw_perf_events();
|
2007-05-03 00:27:12 +07:00
|
|
|
}
|
2005-07-08 07:56:38 +07:00
|
|
|
|
2007-05-03 00:27:12 +07:00
|
|
|
void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c)
|
|
|
|
{
|
|
|
|
BUG_ON(c == &boot_cpu_data);
|
|
|
|
identify_cpu(c);
|
2008-09-05 10:09:13 +07:00
|
|
|
#ifdef CONFIG_X86_32
|
2007-05-03 00:27:12 +07:00
|
|
|
enable_sep_cpu();
|
2008-09-05 10:09:13 +07:00
|
|
|
#endif
|
2007-05-03 00:27:12 +07:00
|
|
|
mtrr_ap_init();
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
struct msr_range {
|
2009-03-14 14:46:17 +07:00
|
|
|
unsigned min;
|
|
|
|
unsigned max;
|
2008-09-05 02:09:46 +07:00
|
|
|
};
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-12 19:08:49 +07:00
|
|
|
static const struct msr_range msr_range_array[] __cpuinitconst = {
|
2008-09-05 02:09:46 +07:00
|
|
|
{ 0x00000000, 0x00000418},
|
|
|
|
{ 0xc0000000, 0xc000040b},
|
|
|
|
{ 0xc0010000, 0xc0010142},
|
|
|
|
{ 0xc0011000, 0xc001103b},
|
|
|
|
};
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
static void __cpuinit print_cpu_msr(void)
|
|
|
|
{
|
2009-03-14 14:46:17 +07:00
|
|
|
unsigned index_min, index_max;
|
2008-09-05 02:09:46 +07:00
|
|
|
unsigned index;
|
|
|
|
u64 val;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(msr_range_array); i++) {
|
|
|
|
index_min = msr_range_array[i].min;
|
|
|
|
index_max = msr_range_array[i].max;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
for (index = index_min; index < index_max; index++) {
|
|
|
|
if (rdmsrl_amd_safe(index, &val))
|
|
|
|
continue;
|
|
|
|
printk(KERN_INFO " MSR%08x: %016llx\n", index, val);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-09-05 02:09:46 +07:00
|
|
|
}
|
|
|
|
}
|
2005-11-05 23:25:54 +07:00
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
static int show_msr __cpuinitdata;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
static __init int setup_show_msr(char *arg)
|
|
|
|
{
|
|
|
|
int num;
|
2005-04-17 05:25:15 +07:00
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
get_option(&arg, &num);
|
2005-04-17 05:25:15 +07:00
|
|
|
|
2008-09-05 02:09:46 +07:00
|
|
|
if (num > 0)
|
|
|
|
show_msr = num;
|
|
|
|
return 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-09-05 02:09:46 +07:00
|
|
|
__setup("show_msr=", setup_show_msr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-01-30 19:33:21 +07:00
|
|
|
static __init int setup_noclflush(char *arg)
|
|
|
|
{
|
|
|
|
setup_clear_cpu_cap(X86_FEATURE_CLFLSH);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("noclflush", setup_noclflush);
|
|
|
|
|
2006-03-23 17:59:33 +07:00
|
|
|
void __cpuinit print_cpu_info(struct cpuinfo_x86 *c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-03-12 19:08:49 +07:00
|
|
|
const char *vendor = NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
if (c->x86_vendor < X86_VENDOR_NUM) {
|
2005-04-17 05:20:36 +07:00
|
|
|
vendor = this_cpu->c_vendor;
|
2009-03-14 14:46:17 +07:00
|
|
|
} else {
|
|
|
|
if (c->cpuid_level >= 0)
|
|
|
|
vendor = c->x86_vendor_id;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-20 08:41:16 +07:00
|
|
|
if (vendor && !strstr(c->x86_model_id, vendor))
|
2008-09-05 02:09:44 +07:00
|
|
|
printk(KERN_CONT "%s ", vendor);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-09-05 02:09:44 +07:00
|
|
|
if (c->x86_model_id[0])
|
|
|
|
printk(KERN_CONT "%s", c->x86_model_id);
|
2005-04-17 05:20:36 +07:00
|
|
|
else
|
2008-09-05 02:09:44 +07:00
|
|
|
printk(KERN_CONT "%d86", c->x86);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-02-24 17:58:13 +07:00
|
|
|
if (c->x86_mask || c->cpuid_level >= 0)
|
2008-09-05 02:09:44 +07:00
|
|
|
printk(KERN_CONT " stepping %02x\n", c->x86_mask);
|
2005-04-17 05:20:36 +07:00
|
|
|
else
|
2008-09-05 02:09:44 +07:00
|
|
|
printk(KERN_CONT "\n");
|
2008-09-05 02:09:46 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
if (c->cpu_index < show_msr)
|
|
|
|
print_cpu_msr();
|
|
|
|
#else
|
|
|
|
if (show_msr)
|
|
|
|
print_cpu_msr();
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
2008-01-30 19:33:21 +07:00
|
|
|
static __init int setup_disablecpuid(char *arg)
|
|
|
|
{
|
|
|
|
int bit;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-01-30 19:33:21 +07:00
|
|
|
if (get_option(&arg, &bit) && bit < NCAPINTS*32)
|
|
|
|
setup_clear_cpu_cap(bit);
|
|
|
|
else
|
|
|
|
return 0;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-01-30 19:33:21 +07:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
__setup("clearcpuid=", setup_disablecpuid);
|
|
|
|
|
2008-09-05 10:09:03 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
2009-07-09 01:03:53 +07:00
|
|
|
struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
|
2008-09-05 10:09:03 +07:00
|
|
|
|
2009-01-19 10:21:28 +07:00
|
|
|
DEFINE_PER_CPU_FIRST(union irq_stack_union,
|
|
|
|
irq_stack_union) __aligned(PAGE_SIZE);
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2009-08-03 12:12:19 +07:00
|
|
|
/*
|
|
|
|
* The following four percpu variables are hot. Align current_task to
|
|
|
|
* cacheline size such that all four fall in the same cacheline.
|
|
|
|
*/
|
|
|
|
DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
|
|
|
|
&init_task;
|
|
|
|
EXPORT_PER_CPU_SYMBOL(current_task);
|
2008-09-05 10:09:03 +07:00
|
|
|
|
2009-01-18 22:38:58 +07:00
|
|
|
DEFINE_PER_CPU(unsigned long, kernel_stack) =
|
|
|
|
(unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
|
|
|
|
EXPORT_PER_CPU_SYMBOL(kernel_stack);
|
|
|
|
|
2009-08-03 12:12:19 +07:00
|
|
|
DEFINE_PER_CPU(char *, irq_stack_ptr) =
|
|
|
|
init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64;
|
|
|
|
|
2009-01-18 22:38:58 +07:00
|
|
|
DEFINE_PER_CPU(unsigned int, irq_count) = -1;
|
2008-09-05 10:09:03 +07:00
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
/*
|
|
|
|
* Special IST stacks which the CPU switches to when it calls
|
|
|
|
* an IST-marked descriptor entry. Up to 7 stacks (hardware
|
|
|
|
* limit), all of them are 4K, except the debug stack which
|
|
|
|
* is 8K.
|
|
|
|
*/
|
|
|
|
static const unsigned int exception_stack_sizes[N_EXCEPTION_STACKS] = {
|
|
|
|
[0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ,
|
|
|
|
[DEBUG_STACK - 1] = DEBUG_STKSZ
|
|
|
|
};
|
|
|
|
|
2009-01-18 22:38:58 +07:00
|
|
|
static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
|
2009-08-03 12:10:11 +07:00
|
|
|
[(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
|
2008-09-05 10:09:03 +07:00
|
|
|
|
|
|
|
/* May not be marked __init: used by software suspend */
|
|
|
|
void syscall_init(void)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2008-09-05 10:09:03 +07:00
|
|
|
/*
|
|
|
|
* LSTAR and STAR live in a bit strange symbiosis.
|
|
|
|
* They both write to the same internal register. STAR allows to
|
|
|
|
* set CS/DS but only a 32bit target. LSTAR sets the 64bit rip.
|
|
|
|
*/
|
|
|
|
wrmsrl(MSR_STAR, ((u64)__USER32_CS)<<48 | ((u64)__KERNEL_CS)<<32);
|
|
|
|
wrmsrl(MSR_LSTAR, system_call);
|
|
|
|
wrmsrl(MSR_CSTAR, ignore_sysret);
|
x86: use ELF section to list CPU vendor specific code
Replace the hardcoded list of initialization functions for each CPU
vendor by a list in an ELF section, which is read at initialization in
arch/x86/kernel/cpu/cpu.c to fill the cpu_devs[] array. The ELF
section, named .x86cpuvendor.init, is reclaimed after boot, and
contains entries of type "struct cpu_vendor_dev" which associates a
vendor number with a pointer to a "struct cpu_dev" structure.
This first modification allows to remove all the VENDOR_init_cpu()
functions.
This patch also removes the hardcoded calls to early_init_amd() and
early_init_intel(). Instead, we add a "c_early_init" member to the
cpu_dev structure, which is then called if not NULL by the generic CPU
initialization code. Unfortunately, in early_cpu_detect(), this_cpu is
not yet set, so we have to use the cpu_devs[] array directly.
This patch is part of the Linux Tiny project, and is needed for
further patch that will allow to disable compilation of unused CPU
support code.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-02-15 18:00:23 +07:00
|
|
|
|
2008-09-05 10:09:03 +07:00
|
|
|
#ifdef CONFIG_IA32_EMULATION
|
|
|
|
syscall32_cpu_init();
|
|
|
|
#endif
|
x86: use ELF section to list CPU vendor specific code
Replace the hardcoded list of initialization functions for each CPU
vendor by a list in an ELF section, which is read at initialization in
arch/x86/kernel/cpu/cpu.c to fill the cpu_devs[] array. The ELF
section, named .x86cpuvendor.init, is reclaimed after boot, and
contains entries of type "struct cpu_vendor_dev" which associates a
vendor number with a pointer to a "struct cpu_dev" structure.
This first modification allows to remove all the VENDOR_init_cpu()
functions.
This patch also removes the hardcoded calls to early_init_amd() and
early_init_intel(). Instead, we add a "c_early_init" member to the
cpu_dev structure, which is then called if not NULL by the generic CPU
initialization code. Unfortunately, in early_cpu_detect(), this_cpu is
not yet set, so we have to use the cpu_devs[] array directly.
This patch is part of the Linux Tiny project, and is needed for
further patch that will allow to disable compilation of unused CPU
support code.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-02-15 18:00:23 +07:00
|
|
|
|
2008-09-05 10:09:03 +07:00
|
|
|
/* Flags to clear on syscall */
|
|
|
|
wrmsrl(MSR_SYSCALL_MASK,
|
|
|
|
X86_EFLAGS_TF|X86_EFLAGS_DF|X86_EFLAGS_IF|X86_EFLAGS_IOPL);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2006-12-07 08:14:02 +07:00
|
|
|
|
2008-09-05 10:09:03 +07:00
|
|
|
unsigned long kernel_eflags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copies of the original ist values from the tss are only accessed during
|
|
|
|
* debugging, no special alignment required.
|
|
|
|
*/
|
|
|
|
DEFINE_PER_CPU(struct orig_ist, orig_ist);
|
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
#else /* CONFIG_X86_64 */
|
2008-09-05 10:09:03 +07:00
|
|
|
|
2009-08-03 12:12:19 +07:00
|
|
|
DEFINE_PER_CPU(struct task_struct *, current_task) = &init_task;
|
|
|
|
EXPORT_PER_CPU_SYMBOL(current_task);
|
|
|
|
|
2009-02-09 20:17:40 +07:00
|
|
|
#ifdef CONFIG_CC_STACKPROTECTOR
|
2009-09-04 04:31:44 +07:00
|
|
|
DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
|
2009-02-09 20:17:40 +07:00
|
|
|
#endif
|
2008-09-05 10:09:03 +07:00
|
|
|
|
2009-02-09 20:17:40 +07:00
|
|
|
/* Make sure %fs and %gs are initialized properly in idle threads */
|
2008-02-06 16:37:55 +07:00
|
|
|
struct pt_regs * __cpuinit idle_regs(struct pt_regs *regs)
|
[PATCH] i386: Use %gs as the PDA base-segment in the kernel
This patch is the meat of the PDA change. This patch makes several related
changes:
1: Most significantly, %gs is now used in the kernel. This means that on
entry, the old value of %gs is saved away, and it is reloaded with
__KERNEL_PDA.
2: entry.S constructs the stack in the shape of struct pt_regs, and this
is passed around the kernel so that the process's saved register
state can be accessed.
Unfortunately struct pt_regs doesn't currently have space for %gs
(or %fs). This patch extends pt_regs to add space for gs (no space
is allocated for %fs, since it won't be used, and it would just
complicate the code in entry.S to work around the space).
3: Because %gs is now saved on the stack like %ds, %es and the integer
registers, there are a number of places where it no longer needs to
be handled specially; namely context switch, and saving/restoring the
register state in a signal context.
4: And since kernel threads run in kernel space and call normal kernel
code, they need to be created with their %gs == __KERNEL_PDA.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
2006-12-07 08:14:02 +07:00
|
|
|
{
|
|
|
|
memset(regs, 0, sizeof(struct pt_regs));
|
2008-01-30 19:30:56 +07:00
|
|
|
regs->fs = __KERNEL_PERCPU;
|
2009-02-09 20:17:40 +07:00
|
|
|
regs->gs = __KERNEL_STACK_CANARY;
|
2009-03-14 14:46:17 +07:00
|
|
|
|
[PATCH] i386: Use %gs as the PDA base-segment in the kernel
This patch is the meat of the PDA change. This patch makes several related
changes:
1: Most significantly, %gs is now used in the kernel. This means that on
entry, the old value of %gs is saved away, and it is reloaded with
__KERNEL_PDA.
2: entry.S constructs the stack in the shape of struct pt_regs, and this
is passed around the kernel so that the process's saved register
state can be accessed.
Unfortunately struct pt_regs doesn't currently have space for %gs
(or %fs). This patch extends pt_regs to add space for gs (no space
is allocated for %fs, since it won't be used, and it would just
complicate the code in entry.S to work around the space).
3: Because %gs is now saved on the stack like %ds, %es and the integer
registers, there are a number of places where it no longer needs to
be handled specially; namely context switch, and saving/restoring the
register state in a signal context.
4: And since kernel threads run in kernel space and call normal kernel
code, they need to be created with their %gs == __KERNEL_PDA.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Zachary Amsden <zach@vmware.com>
Cc: Jan Beulich <jbeulich@novell.com>
Cc: Andi Kleen <ak@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
2006-12-07 08:14:02 +07:00
|
|
|
return regs;
|
|
|
|
}
|
2009-03-14 14:46:17 +07:00
|
|
|
#endif /* CONFIG_X86_64 */
|
2007-05-03 00:27:16 +07:00
|
|
|
|
2009-03-14 12:49:49 +07:00
|
|
|
/*
|
|
|
|
* Clear all 6 debug registers:
|
|
|
|
*/
|
|
|
|
static void clear_all_debug_regs(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
/* Ignore db4, db5 */
|
|
|
|
if ((i == 4) || (i == 5))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
set_debugreg(0, i);
|
|
|
|
}
|
|
|
|
}
|
2007-05-03 00:27:16 +07:00
|
|
|
|
2010-05-21 09:04:30 +07:00
|
|
|
#ifdef CONFIG_KGDB
|
|
|
|
/*
|
|
|
|
* Restore debug regs if using kgdbwait and you have a kernel debugger
|
|
|
|
* connection established.
|
|
|
|
*/
|
|
|
|
static void dbg_restore_debug_regs(void)
|
|
|
|
{
|
|
|
|
if (unlikely(kgdb_connected && arch_kgdb_ops.correct_hw_break))
|
|
|
|
arch_kgdb_ops.correct_hw_break();
|
|
|
|
}
|
|
|
|
#else /* ! CONFIG_KGDB */
|
|
|
|
#define dbg_restore_debug_regs()
|
|
|
|
#endif /* ! CONFIG_KGDB */
|
|
|
|
|
2007-05-03 00:27:10 +07:00
|
|
|
/*
|
|
|
|
* cpu_init() initializes state that is per-CPU. Some data is already
|
|
|
|
* initialized (naturally) in the bootstrap process, such as the GDT
|
|
|
|
* and IDT. We reload them nevertheless, this function acts as a
|
|
|
|
* 'CPU state barrier', nothing should get across.
|
2008-09-05 10:09:04 +07:00
|
|
|
* A lot of state is already set up in PDA init for 64 bit
|
2007-05-03 00:27:10 +07:00
|
|
|
*/
|
2008-09-05 10:09:04 +07:00
|
|
|
#ifdef CONFIG_X86_64
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 10:09:04 +07:00
|
|
|
void __cpuinit cpu_init(void)
|
|
|
|
{
|
2009-10-29 20:34:14 +07:00
|
|
|
struct orig_ist *oist;
|
2008-09-05 10:09:04 +07:00
|
|
|
struct task_struct *me;
|
2009-03-14 14:46:17 +07:00
|
|
|
struct tss_struct *t;
|
|
|
|
unsigned long v;
|
|
|
|
int cpu;
|
2008-09-05 10:09:04 +07:00
|
|
|
int i;
|
|
|
|
|
2009-03-14 14:46:17 +07:00
|
|
|
cpu = stack_smp_processor_id();
|
|
|
|
t = &per_cpu(init_tss, cpu);
|
2009-10-29 20:34:14 +07:00
|
|
|
oist = &per_cpu(orig_ist, cpu);
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2009-01-18 22:38:59 +07:00
|
|
|
#ifdef CONFIG_NUMA
|
2010-05-27 04:44:58 +07:00
|
|
|
if (cpu != 0 && percpu_read(numa_node) == 0 &&
|
|
|
|
early_cpu_to_node(cpu) != NUMA_NO_NODE)
|
|
|
|
set_numa_node(early_cpu_to_node(cpu));
|
2009-01-18 22:38:59 +07:00
|
|
|
#endif
|
2008-09-05 10:09:04 +07:00
|
|
|
|
|
|
|
me = current;
|
|
|
|
|
2009-01-04 20:18:03 +07:00
|
|
|
if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask))
|
2008-09-05 10:09:04 +07:00
|
|
|
panic("CPU#%d already initialized!\n", cpu);
|
|
|
|
|
2009-12-11 08:19:36 +07:00
|
|
|
pr_debug("Initializing CPU#%d\n", cpu);
|
2008-09-05 10:09:04 +07:00
|
|
|
|
|
|
|
clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the per-CPU GDT with the boot GDT,
|
|
|
|
* and set up the GDT descriptor:
|
|
|
|
*/
|
|
|
|
|
2009-01-30 15:47:53 +07:00
|
|
|
switch_to_new_gdt(cpu);
|
2009-01-27 10:56:48 +07:00
|
|
|
loadsegment(fs, 0);
|
|
|
|
|
2008-09-05 10:09:04 +07:00
|
|
|
load_idt((const struct desc_ptr *)&idt_descr);
|
|
|
|
|
|
|
|
memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
|
|
|
|
syscall_init();
|
|
|
|
|
|
|
|
wrmsrl(MSR_FS_BASE, 0);
|
|
|
|
wrmsrl(MSR_KERNEL_GS_BASE, 0);
|
|
|
|
barrier();
|
|
|
|
|
2009-11-14 06:28:16 +07:00
|
|
|
x86_configure_nx();
|
2009-02-17 08:29:58 +07:00
|
|
|
if (cpu != 0)
|
2008-09-05 10:09:04 +07:00
|
|
|
enable_x2apic();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* set up and load the per-CPU TSS
|
|
|
|
*/
|
2009-10-29 20:34:14 +07:00
|
|
|
if (!oist->ist[0]) {
|
2009-01-18 22:38:58 +07:00
|
|
|
char *estacks = per_cpu(exception_stacks, cpu);
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 10:09:04 +07:00
|
|
|
for (v = 0; v < N_EXCEPTION_STACKS; v++) {
|
2009-03-14 14:46:17 +07:00
|
|
|
estacks += exception_stack_sizes[v];
|
2009-10-29 20:34:14 +07:00
|
|
|
oist->ist[v] = t->x86_tss.ist[v] =
|
2008-09-05 10:09:04 +07:00
|
|
|
(unsigned long)estacks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
|
2009-03-14 14:46:17 +07:00
|
|
|
|
2008-09-05 10:09:04 +07:00
|
|
|
/*
|
|
|
|
* <= is required because the CPU will access up to
|
|
|
|
* 8 bits beyond the end of the IO permission bitmap.
|
|
|
|
*/
|
|
|
|
for (i = 0; i <= IO_BITMAP_LONGS; i++)
|
|
|
|
t->io_bitmap[i] = ~0UL;
|
|
|
|
|
|
|
|
atomic_inc(&init_mm.mm_count);
|
|
|
|
me->active_mm = &init_mm;
|
2009-03-10 12:10:32 +07:00
|
|
|
BUG_ON(me->mm);
|
2008-09-05 10:09:04 +07:00
|
|
|
enter_lazy_tlb(&init_mm, me);
|
|
|
|
|
|
|
|
load_sp0(t, ¤t->thread);
|
|
|
|
set_tss_desc(cpu, t);
|
|
|
|
load_TR_desc();
|
|
|
|
load_LDT(&init_mm.context);
|
|
|
|
|
2010-05-21 09:04:30 +07:00
|
|
|
clear_all_debug_regs();
|
|
|
|
dbg_restore_debug_regs();
|
2008-09-05 10:09:04 +07:00
|
|
|
|
|
|
|
fpu_init();
|
|
|
|
|
|
|
|
raw_local_save_flags(kernel_eflags);
|
|
|
|
|
|
|
|
if (is_uv_system())
|
|
|
|
uv_cpu_init();
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2007-05-03 00:27:10 +07:00
|
|
|
void __cpuinit cpu_init(void)
|
2007-01-22 22:18:31 +07:00
|
|
|
{
|
2007-05-03 00:27:10 +07:00
|
|
|
int cpu = smp_processor_id();
|
|
|
|
struct task_struct *curr = current;
|
2008-02-24 17:58:13 +07:00
|
|
|
struct tss_struct *t = &per_cpu(init_tss, cpu);
|
2007-01-22 22:18:31 +07:00
|
|
|
struct thread_struct *thread = &curr->thread;
|
2006-12-07 08:14:02 +07:00
|
|
|
|
2009-01-04 20:18:03 +07:00
|
|
|
if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
|
2006-12-07 08:14:02 +07:00
|
|
|
printk(KERN_WARNING "CPU#%d already initialized!\n", cpu);
|
2009-03-14 12:49:49 +07:00
|
|
|
for (;;)
|
|
|
|
local_irq_enable();
|
2006-12-07 08:14:02 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO "Initializing CPU#%d\n", cpu);
|
|
|
|
|
|
|
|
if (cpu_has_vme || cpu_has_tsc || cpu_has_de)
|
|
|
|
clear_in_cr4(X86_CR4_VME|X86_CR4_PVI|X86_CR4_TSD|X86_CR4_DE);
|
|
|
|
|
2005-09-04 05:56:38 +07:00
|
|
|
load_idt(&idt_descr);
|
2009-01-30 15:47:53 +07:00
|
|
|
switch_to_new_gdt(cpu);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up and load the per-CPU TSS and LDT
|
|
|
|
*/
|
|
|
|
atomic_inc(&init_mm.mm_count);
|
2006-12-07 08:14:02 +07:00
|
|
|
curr->active_mm = &init_mm;
|
2009-03-10 12:10:32 +07:00
|
|
|
BUG_ON(curr->mm);
|
2006-12-07 08:14:02 +07:00
|
|
|
enter_lazy_tlb(&init_mm, curr);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-01-30 19:31:02 +07:00
|
|
|
load_sp0(t, thread);
|
2008-02-24 17:58:13 +07:00
|
|
|
set_tss_desc(cpu, t);
|
2005-04-17 05:20:36 +07:00
|
|
|
load_TR_desc();
|
|
|
|
load_LDT(&init_mm.context);
|
|
|
|
|
2009-05-02 01:59:25 +07:00
|
|
|
t->x86_tss.io_bitmap_base = offsetof(struct tss_struct, io_bitmap);
|
|
|
|
|
2006-01-08 16:05:24 +07:00
|
|
|
#ifdef CONFIG_DOUBLEFAULT
|
2005-04-17 05:20:36 +07:00
|
|
|
/* Set up doublefault TSS pointer in the GDT */
|
|
|
|
__set_tss_desc(cpu, GDT_ENTRY_DOUBLEFAULT_TSS, &doublefault_tss);
|
2006-01-08 16:05:24 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-03-14 12:49:49 +07:00
|
|
|
clear_all_debug_regs();
|
2010-05-21 09:04:30 +07:00
|
|
|
dbg_restore_debug_regs();
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Force FPU initialization:
|
|
|
|
*/
|
2010-05-06 15:45:45 +07:00
|
|
|
current_thread_info()->status = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
clear_used_math();
|
|
|
|
mxcsr_feature_mask_init();
|
2008-07-30 00:29:19 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Boot processor to setup the FP and extended state context info.
|
|
|
|
*/
|
2008-10-31 04:00:59 +07:00
|
|
|
if (smp_processor_id() == boot_cpu_id)
|
2008-07-30 00:29:19 +07:00
|
|
|
init_thread_xstate();
|
|
|
|
|
|
|
|
xsave_init();
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
2008-09-05 10:09:04 +07:00
|
|
|
#endif
|