diff options
author | Borislav Petkov <bp@suse.de> | 2015-11-23 05:12:21 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-11-24 03:15:54 -0500 |
commit | 99f925ce927e4ac313d9af8bd1bf55796e2cdcb1 (patch) | |
tree | 51a3708791496f4d60f895e6f07a628a8f7a68e3 /arch/x86/lib | |
parent | 1ec218373b8ebda821aec00bb156a9c94fad9cd4 (diff) |
x86/cpu: Unify CPU family, model, stepping calculation
Add generic functions which calc family, model and stepping from
the CPUID_1.EAX leaf and stick them into the library we have.
Rename those which do call CPUID with the prefix "x86_cpuid" as
suggested by Paolo Bonzini.
No functionality change.
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1448273546-2567-2-git-send-email-bp@alien8.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/lib')
-rw-r--r-- | arch/x86/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/lib/cpu.c | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index f2587888d987..a501fa25da41 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile | |||
@@ -16,7 +16,7 @@ clean-files := inat-tables.c | |||
16 | 16 | ||
17 | obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o | 17 | obj-$(CONFIG_SMP) += msr-smp.o cache-smp.o |
18 | 18 | ||
19 | lib-y := delay.o misc.o cmdline.o | 19 | lib-y := delay.o misc.o cmdline.o cpu.o |
20 | lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o | 20 | lib-y += usercopy_$(BITS).o usercopy.o getuser.o putuser.o |
21 | lib-y += memcpy_$(BITS).o | 21 | lib-y += memcpy_$(BITS).o |
22 | lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o | 22 | lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o |
diff --git a/arch/x86/lib/cpu.c b/arch/x86/lib/cpu.c new file mode 100644 index 000000000000..aa417a97511c --- /dev/null +++ b/arch/x86/lib/cpu.c | |||
@@ -0,0 +1,35 @@ | |||
1 | #include <linux/module.h> | ||
2 | |||
3 | unsigned int x86_family(unsigned int sig) | ||
4 | { | ||
5 | unsigned int x86; | ||
6 | |||
7 | x86 = (sig >> 8) & 0xf; | ||
8 | |||
9 | if (x86 == 0xf) | ||
10 | x86 += (sig >> 20) & 0xff; | ||
11 | |||
12 | return x86; | ||
13 | } | ||
14 | EXPORT_SYMBOL_GPL(x86_family); | ||
15 | |||
16 | unsigned int x86_model(unsigned int sig) | ||
17 | { | ||
18 | unsigned int fam, model; | ||
19 | |||
20 | fam = x86_family(sig); | ||
21 | |||
22 | model = (sig >> 4) & 0xf; | ||
23 | |||
24 | if (fam >= 0x6) | ||
25 | model += ((sig >> 16) & 0xf) << 4; | ||
26 | |||
27 | return model; | ||
28 | } | ||
29 | EXPORT_SYMBOL_GPL(x86_model); | ||
30 | |||
31 | unsigned int x86_stepping(unsigned int sig) | ||
32 | { | ||
33 | return sig & 0xf; | ||
34 | } | ||
35 | EXPORT_SYMBOL_GPL(x86_stepping); | ||