diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-01-15 15:03:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-01-15 15:03:11 -0500 |
commit | 83346fbc07d267de777e2597552f785174ad0373 (patch) | |
tree | b321fa8a652b04bc3745be183252ef024a3ba4be | |
parent | a11ce3a4ac0ad78618cddb9ce16def7486f2707d (diff) | |
parent | 453828625731d0ba7218242ef6ec88f59408f368 (diff) |
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar:
"Misc fixes:
- unwinder fixes
- AMD CPU topology enumeration fixes
- microcode loader fixes
- x86 embedded platform fixes
- fix for a bootup crash that may trigger when clearcpuid= is used
with invalid values"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/mpx: Use compatible types in comparison to fix sparse error
x86/tsc: Add the Intel Denverton Processor to native_calibrate_tsc()
x86/entry: Fix the end of the stack for newly forked tasks
x86/unwind: Include __schedule() in stack traces
x86/unwind: Disable KASAN checks for non-current tasks
x86/unwind: Silence warnings for non-current tasks
x86/microcode/intel: Use correct buffer size for saving microcode data
x86/microcode/intel: Fix allocation size of struct ucode_patch
x86/microcode/intel: Add a helper which gives the microcode revision
x86/microcode: Use native CPUID to tickle out microcode revision
x86/CPU: Add native CPUID variants returning a single datum
x86/boot: Add missing declaration of string functions
x86/CPU/AMD: Fix Bulldozer topology
x86/platform/intel-mid: Rename 'spidev' to 'mrfld_spidev'
x86/cpu: Fix typo in the comment for Anniedale
x86/cpu: Fix bootup crashes by sanitizing the argument of the 'clearcpuid=' command-line option
-rw-r--r-- | arch/x86/boot/string.c | 1 | ||||
-rw-r--r-- | arch/x86/boot/string.h | 9 | ||||
-rw-r--r-- | arch/x86/entry/entry_32.S | 30 | ||||
-rw-r--r-- | arch/x86/entry/entry_64.S | 11 | ||||
-rw-r--r-- | arch/x86/include/asm/intel-family.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/microcode_intel.h | 15 | ||||
-rw-r--r-- | arch/x86/include/asm/processor.h | 18 | ||||
-rw-r--r-- | arch/x86/include/asm/stacktrace.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/switch_to.h | 10 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/amd.c | 9 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/intel.c | 11 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/microcode/intel.c | 70 | ||||
-rw-r--r-- | arch/x86/kernel/tsc.c | 1 | ||||
-rw-r--r-- | arch/x86/kernel/unwind_frame.c | 30 | ||||
-rw-r--r-- | arch/x86/mm/mpx.c | 2 | ||||
-rw-r--r-- | arch/x86/platform/intel-mid/device_libs/Makefile | 2 | ||||
-rw-r--r-- | arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c (renamed from arch/x86/platform/intel-mid/device_libs/platform_spidev.c) | 4 |
18 files changed, 129 insertions, 100 deletions
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index cc3bd583dce1..9e240fcba784 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c | |||
@@ -14,6 +14,7 @@ | |||
14 | 14 | ||
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include "ctype.h" | 16 | #include "ctype.h" |
17 | #include "string.h" | ||
17 | 18 | ||
18 | int memcmp(const void *s1, const void *s2, size_t len) | 19 | int memcmp(const void *s1, const void *s2, size_t len) |
19 | { | 20 | { |
diff --git a/arch/x86/boot/string.h b/arch/x86/boot/string.h index 725e820602b1..113588ddb43f 100644 --- a/arch/x86/boot/string.h +++ b/arch/x86/boot/string.h | |||
@@ -18,4 +18,13 @@ int memcmp(const void *s1, const void *s2, size_t len); | |||
18 | #define memset(d,c,l) __builtin_memset(d,c,l) | 18 | #define memset(d,c,l) __builtin_memset(d,c,l) |
19 | #define memcmp __builtin_memcmp | 19 | #define memcmp __builtin_memcmp |
20 | 20 | ||
21 | extern int strcmp(const char *str1, const char *str2); | ||
22 | extern int strncmp(const char *cs, const char *ct, size_t count); | ||
23 | extern size_t strlen(const char *s); | ||
24 | extern char *strstr(const char *s1, const char *s2); | ||
25 | extern size_t strnlen(const char *s, size_t maxlen); | ||
26 | extern unsigned int atou(const char *s); | ||
27 | extern unsigned long long simple_strtoull(const char *cp, char **endp, | ||
28 | unsigned int base); | ||
29 | |||
21 | #endif /* BOOT_STRING_H */ | 30 | #endif /* BOOT_STRING_H */ |
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S index 701d29f8e4d3..57f7ec35216e 100644 --- a/arch/x86/entry/entry_32.S +++ b/arch/x86/entry/entry_32.S | |||
@@ -255,23 +255,6 @@ ENTRY(__switch_to_asm) | |||
255 | END(__switch_to_asm) | 255 | END(__switch_to_asm) |
256 | 256 | ||
257 | /* | 257 | /* |
258 | * The unwinder expects the last frame on the stack to always be at the same | ||
259 | * offset from the end of the page, which allows it to validate the stack. | ||
260 | * Calling schedule_tail() directly would break that convention because its an | ||
261 | * asmlinkage function so its argument has to be pushed on the stack. This | ||
262 | * wrapper creates a proper "end of stack" frame header before the call. | ||
263 | */ | ||
264 | ENTRY(schedule_tail_wrapper) | ||
265 | FRAME_BEGIN | ||
266 | |||
267 | pushl %eax | ||
268 | call schedule_tail | ||
269 | popl %eax | ||
270 | |||
271 | FRAME_END | ||
272 | ret | ||
273 | ENDPROC(schedule_tail_wrapper) | ||
274 | /* | ||
275 | * A newly forked process directly context switches into this address. | 258 | * A newly forked process directly context switches into this address. |
276 | * | 259 | * |
277 | * eax: prev task we switched from | 260 | * eax: prev task we switched from |
@@ -279,15 +262,24 @@ ENDPROC(schedule_tail_wrapper) | |||
279 | * edi: kernel thread arg | 262 | * edi: kernel thread arg |
280 | */ | 263 | */ |
281 | ENTRY(ret_from_fork) | 264 | ENTRY(ret_from_fork) |
282 | call schedule_tail_wrapper | 265 | FRAME_BEGIN /* help unwinder find end of stack */ |
266 | |||
267 | /* | ||
268 | * schedule_tail() is asmlinkage so we have to put its 'prev' argument | ||
269 | * on the stack. | ||
270 | */ | ||
271 | pushl %eax | ||
272 | call schedule_tail | ||
273 | popl %eax | ||
283 | 274 | ||
284 | testl %ebx, %ebx | 275 | testl %ebx, %ebx |
285 | jnz 1f /* kernel threads are uncommon */ | 276 | jnz 1f /* kernel threads are uncommon */ |
286 | 277 | ||
287 | 2: | 278 | 2: |
288 | /* When we fork, we trace the syscall return in the child, too. */ | 279 | /* When we fork, we trace the syscall return in the child, too. */ |
289 | movl %esp, %eax | 280 | leal FRAME_OFFSET(%esp), %eax |
290 | call syscall_return_slowpath | 281 | call syscall_return_slowpath |
282 | FRAME_END | ||
291 | jmp restore_all | 283 | jmp restore_all |
292 | 284 | ||
293 | /* kernel thread */ | 285 | /* kernel thread */ |
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index 5b219707c2f2..044d18ebc43c 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <asm/smap.h> | 36 | #include <asm/smap.h> |
37 | #include <asm/pgtable_types.h> | 37 | #include <asm/pgtable_types.h> |
38 | #include <asm/export.h> | 38 | #include <asm/export.h> |
39 | #include <asm/frame.h> | ||
39 | #include <linux/err.h> | 40 | #include <linux/err.h> |
40 | 41 | ||
41 | .code64 | 42 | .code64 |
@@ -408,17 +409,19 @@ END(__switch_to_asm) | |||
408 | * r12: kernel thread arg | 409 | * r12: kernel thread arg |
409 | */ | 410 | */ |
410 | ENTRY(ret_from_fork) | 411 | ENTRY(ret_from_fork) |
412 | FRAME_BEGIN /* help unwinder find end of stack */ | ||
411 | movq %rax, %rdi | 413 | movq %rax, %rdi |
412 | call schedule_tail /* rdi: 'prev' task parameter */ | 414 | call schedule_tail /* rdi: 'prev' task parameter */ |
413 | 415 | ||
414 | testq %rbx, %rbx /* from kernel_thread? */ | 416 | testq %rbx, %rbx /* from kernel_thread? */ |
415 | jnz 1f /* kernel threads are uncommon */ | 417 | jnz 1f /* kernel threads are uncommon */ |
416 | 418 | ||
417 | 2: | 419 | 2: |
418 | movq %rsp, %rdi | 420 | leaq FRAME_OFFSET(%rsp),%rdi /* pt_regs pointer */ |
419 | call syscall_return_slowpath /* returns with IRQs disabled */ | 421 | call syscall_return_slowpath /* returns with IRQs disabled */ |
420 | TRACE_IRQS_ON /* user mode is traced as IRQS on */ | 422 | TRACE_IRQS_ON /* user mode is traced as IRQS on */ |
421 | SWAPGS | 423 | SWAPGS |
424 | FRAME_END | ||
422 | jmp restore_regs_and_iret | 425 | jmp restore_regs_and_iret |
423 | 426 | ||
424 | 1: | 427 | 1: |
diff --git a/arch/x86/include/asm/intel-family.h b/arch/x86/include/asm/intel-family.h index 34a46dc076d3..8167fdb67ae8 100644 --- a/arch/x86/include/asm/intel-family.h +++ b/arch/x86/include/asm/intel-family.h | |||
@@ -57,7 +57,7 @@ | |||
57 | #define INTEL_FAM6_ATOM_SILVERMONT2 0x4D /* Avaton/Rangely */ | 57 | #define INTEL_FAM6_ATOM_SILVERMONT2 0x4D /* Avaton/Rangely */ |
58 | #define INTEL_FAM6_ATOM_AIRMONT 0x4C /* CherryTrail / Braswell */ | 58 | #define INTEL_FAM6_ATOM_AIRMONT 0x4C /* CherryTrail / Braswell */ |
59 | #define INTEL_FAM6_ATOM_MERRIFIELD 0x4A /* Tangier */ | 59 | #define INTEL_FAM6_ATOM_MERRIFIELD 0x4A /* Tangier */ |
60 | #define INTEL_FAM6_ATOM_MOOREFIELD 0x5A /* Annidale */ | 60 | #define INTEL_FAM6_ATOM_MOOREFIELD 0x5A /* Anniedale */ |
61 | #define INTEL_FAM6_ATOM_GOLDMONT 0x5C | 61 | #define INTEL_FAM6_ATOM_GOLDMONT 0x5C |
62 | #define INTEL_FAM6_ATOM_DENVERTON 0x5F /* Goldmont Microserver */ | 62 | #define INTEL_FAM6_ATOM_DENVERTON 0x5F /* Goldmont Microserver */ |
63 | 63 | ||
diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h index 195becc6f780..e793fc9a9b20 100644 --- a/arch/x86/include/asm/microcode_intel.h +++ b/arch/x86/include/asm/microcode_intel.h | |||
@@ -52,6 +52,21 @@ struct extended_sigtable { | |||
52 | 52 | ||
53 | #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) | 53 | #define exttable_size(et) ((et)->count * EXT_SIGNATURE_SIZE + EXT_HEADER_SIZE) |
54 | 54 | ||
55 | static inline u32 intel_get_microcode_revision(void) | ||
56 | { | ||
57 | u32 rev, dummy; | ||
58 | |||
59 | native_wrmsrl(MSR_IA32_UCODE_REV, 0); | ||
60 | |||
61 | /* As documented in the SDM: Do a CPUID 1 here */ | ||
62 | native_cpuid_eax(1); | ||
63 | |||
64 | /* get the current revision from MSR 0x8B */ | ||
65 | native_rdmsr(MSR_IA32_UCODE_REV, dummy, rev); | ||
66 | |||
67 | return rev; | ||
68 | } | ||
69 | |||
55 | #ifdef CONFIG_MICROCODE_INTEL | 70 | #ifdef CONFIG_MICROCODE_INTEL |
56 | extern void __init load_ucode_intel_bsp(void); | 71 | extern void __init load_ucode_intel_bsp(void); |
57 | extern void load_ucode_intel_ap(void); | 72 | extern void load_ucode_intel_ap(void); |
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index eaf100508c36..1be64da0384e 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -219,6 +219,24 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx, | |||
219 | : "memory"); | 219 | : "memory"); |
220 | } | 220 | } |
221 | 221 | ||
222 | #define native_cpuid_reg(reg) \ | ||
223 | static inline unsigned int native_cpuid_##reg(unsigned int op) \ | ||
224 | { \ | ||
225 | unsigned int eax = op, ebx, ecx = 0, edx; \ | ||
226 | \ | ||
227 | native_cpuid(&eax, &ebx, &ecx, &edx); \ | ||
228 | \ | ||
229 | return reg; \ | ||
230 | } | ||
231 | |||
232 | /* | ||
233 | * Native CPUID functions returning a single datum. | ||
234 | */ | ||
235 | native_cpuid_reg(eax) | ||
236 | native_cpuid_reg(ebx) | ||
237 | native_cpuid_reg(ecx) | ||
238 | native_cpuid_reg(edx) | ||
239 | |||
222 | static inline void load_cr3(pgd_t *pgdir) | 240 | static inline void load_cr3(pgd_t *pgdir) |
223 | { | 241 | { |
224 | write_cr3(__pa(pgdir)); | 242 | write_cr3(__pa(pgdir)); |
diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h index a3269c897ec5..2e41c50ddf47 100644 --- a/arch/x86/include/asm/stacktrace.h +++ b/arch/x86/include/asm/stacktrace.h | |||
@@ -58,7 +58,7 @@ get_frame_pointer(struct task_struct *task, struct pt_regs *regs) | |||
58 | if (task == current) | 58 | if (task == current) |
59 | return __builtin_frame_address(0); | 59 | return __builtin_frame_address(0); |
60 | 60 | ||
61 | return (unsigned long *)((struct inactive_task_frame *)task->thread.sp)->bp; | 61 | return &((struct inactive_task_frame *)task->thread.sp)->bp; |
62 | } | 62 | } |
63 | #else | 63 | #else |
64 | static inline unsigned long * | 64 | static inline unsigned long * |
diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h index 5cb436acd463..fcc5cd387fd1 100644 --- a/arch/x86/include/asm/switch_to.h +++ b/arch/x86/include/asm/switch_to.h | |||
@@ -36,7 +36,10 @@ static inline void prepare_switch_to(struct task_struct *prev, | |||
36 | 36 | ||
37 | asmlinkage void ret_from_fork(void); | 37 | asmlinkage void ret_from_fork(void); |
38 | 38 | ||
39 | /* data that is pointed to by thread.sp */ | 39 | /* |
40 | * This is the structure pointed to by thread.sp for an inactive task. The | ||
41 | * order of the fields must match the code in __switch_to_asm(). | ||
42 | */ | ||
40 | struct inactive_task_frame { | 43 | struct inactive_task_frame { |
41 | #ifdef CONFIG_X86_64 | 44 | #ifdef CONFIG_X86_64 |
42 | unsigned long r15; | 45 | unsigned long r15; |
@@ -48,6 +51,11 @@ struct inactive_task_frame { | |||
48 | unsigned long di; | 51 | unsigned long di; |
49 | #endif | 52 | #endif |
50 | unsigned long bx; | 53 | unsigned long bx; |
54 | |||
55 | /* | ||
56 | * These two fields must be together. They form a stack frame header, | ||
57 | * needed by get_frame_pointer(). | ||
58 | */ | ||
51 | unsigned long bp; | 59 | unsigned long bp; |
52 | unsigned long ret_addr; | 60 | unsigned long ret_addr; |
53 | }; | 61 | }; |
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 71cae73a5076..1d3167269a67 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c | |||
@@ -309,15 +309,8 @@ static void amd_get_topology(struct cpuinfo_x86 *c) | |||
309 | 309 | ||
310 | /* get information required for multi-node processors */ | 310 | /* get information required for multi-node processors */ |
311 | if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { | 311 | if (boot_cpu_has(X86_FEATURE_TOPOEXT)) { |
312 | u32 eax, ebx, ecx, edx; | ||
313 | 312 | ||
314 | cpuid(0x8000001e, &eax, &ebx, &ecx, &edx); | 313 | node_id = cpuid_ecx(0x8000001e) & 7; |
315 | node_id = ecx & 7; | ||
316 | |||
317 | /* get compute unit information */ | ||
318 | smp_num_siblings = ((ebx >> 8) & 3) + 1; | ||
319 | c->x86_max_cores /= smp_num_siblings; | ||
320 | c->cpu_core_id = ebx & 0xff; | ||
321 | 314 | ||
322 | /* | 315 | /* |
323 | * We may have multiple LLCs if L3 caches exist, so check if we | 316 | * We may have multiple LLCs if L3 caches exist, so check if we |
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index dc1697ca5191..9bab7a8a4293 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1221,7 +1221,7 @@ static __init int setup_disablecpuid(char *arg) | |||
1221 | { | 1221 | { |
1222 | int bit; | 1222 | int bit; |
1223 | 1223 | ||
1224 | if (get_option(&arg, &bit) && bit < NCAPINTS*32) | 1224 | if (get_option(&arg, &bit) && bit >= 0 && bit < NCAPINTS * 32) |
1225 | setup_clear_cpu_cap(bit); | 1225 | setup_clear_cpu_cap(bit); |
1226 | else | 1226 | else |
1227 | return 0; | 1227 | return 0; |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index fcd484d2bb03..203f860d2ab3 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <asm/bugs.h> | 14 | #include <asm/bugs.h> |
15 | #include <asm/cpu.h> | 15 | #include <asm/cpu.h> |
16 | #include <asm/intel-family.h> | 16 | #include <asm/intel-family.h> |
17 | #include <asm/microcode_intel.h> | ||
17 | 18 | ||
18 | #ifdef CONFIG_X86_64 | 19 | #ifdef CONFIG_X86_64 |
19 | #include <linux/topology.h> | 20 | #include <linux/topology.h> |
@@ -78,14 +79,8 @@ static void early_init_intel(struct cpuinfo_x86 *c) | |||
78 | (c->x86 == 0x6 && c->x86_model >= 0x0e)) | 79 | (c->x86 == 0x6 && c->x86_model >= 0x0e)) |
79 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); | 80 | set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); |
80 | 81 | ||
81 | if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) { | 82 | if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) |
82 | unsigned lower_word; | 83 | c->microcode = intel_get_microcode_revision(); |
83 | |||
84 | wrmsr(MSR_IA32_UCODE_REV, 0, 0); | ||
85 | /* Required by the SDM */ | ||
86 | sync_core(); | ||
87 | rdmsr(MSR_IA32_UCODE_REV, lower_word, c->microcode); | ||
88 | } | ||
89 | 84 | ||
90 | /* | 85 | /* |
91 | * Atom erratum AAE44/AAF40/AAG38/AAH41: | 86 | * Atom erratum AAE44/AAF40/AAG38/AAH41: |
diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index b624b54912e1..3f329b74e040 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c | |||
@@ -150,7 +150,7 @@ static struct ucode_patch *__alloc_microcode_buf(void *data, unsigned int size) | |||
150 | { | 150 | { |
151 | struct ucode_patch *p; | 151 | struct ucode_patch *p; |
152 | 152 | ||
153 | p = kzalloc(size, GFP_KERNEL); | 153 | p = kzalloc(sizeof(struct ucode_patch), GFP_KERNEL); |
154 | if (!p) | 154 | if (!p) |
155 | return ERR_PTR(-ENOMEM); | 155 | return ERR_PTR(-ENOMEM); |
156 | 156 | ||
@@ -368,26 +368,6 @@ next: | |||
368 | return patch; | 368 | return patch; |
369 | } | 369 | } |
370 | 370 | ||
371 | static void cpuid_1(void) | ||
372 | { | ||
373 | /* | ||
374 | * According to the Intel SDM, Volume 3, 9.11.7: | ||
375 | * | ||
376 | * CPUID returns a value in a model specific register in | ||
377 | * addition to its usual register return values. The | ||
378 | * semantics of CPUID cause it to deposit an update ID value | ||
379 | * in the 64-bit model-specific register at address 08BH | ||
380 | * (IA32_BIOS_SIGN_ID). If no update is present in the | ||
381 | * processor, the value in the MSR remains unmodified. | ||
382 | * | ||
383 | * Use native_cpuid -- this code runs very early and we don't | ||
384 | * want to mess with paravirt. | ||
385 | */ | ||
386 | unsigned int eax = 1, ebx, ecx = 0, edx; | ||
387 | |||
388 | native_cpuid(&eax, &ebx, &ecx, &edx); | ||
389 | } | ||
390 | |||
391 | static int collect_cpu_info_early(struct ucode_cpu_info *uci) | 371 | static int collect_cpu_info_early(struct ucode_cpu_info *uci) |
392 | { | 372 | { |
393 | unsigned int val[2]; | 373 | unsigned int val[2]; |
@@ -410,15 +390,8 @@ static int collect_cpu_info_early(struct ucode_cpu_info *uci) | |||
410 | native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); | 390 | native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]); |
411 | csig.pf = 1 << ((val[1] >> 18) & 7); | 391 | csig.pf = 1 << ((val[1] >> 18) & 7); |
412 | } | 392 | } |
413 | native_wrmsrl(MSR_IA32_UCODE_REV, 0); | ||
414 | |||
415 | /* As documented in the SDM: Do a CPUID 1 here */ | ||
416 | cpuid_1(); | ||
417 | 393 | ||
418 | /* get the current revision from MSR 0x8B */ | 394 | csig.rev = intel_get_microcode_revision(); |
419 | native_rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); | ||
420 | |||
421 | csig.rev = val[1]; | ||
422 | 395 | ||
423 | uci->cpu_sig = csig; | 396 | uci->cpu_sig = csig; |
424 | uci->valid = 1; | 397 | uci->valid = 1; |
@@ -602,7 +575,7 @@ static inline void print_ucode(struct ucode_cpu_info *uci) | |||
602 | static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) | 575 | static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) |
603 | { | 576 | { |
604 | struct microcode_intel *mc; | 577 | struct microcode_intel *mc; |
605 | unsigned int val[2]; | 578 | u32 rev; |
606 | 579 | ||
607 | mc = uci->mc; | 580 | mc = uci->mc; |
608 | if (!mc) | 581 | if (!mc) |
@@ -610,21 +583,16 @@ static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) | |||
610 | 583 | ||
611 | /* write microcode via MSR 0x79 */ | 584 | /* write microcode via MSR 0x79 */ |
612 | native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); | 585 | native_wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); |
613 | native_wrmsrl(MSR_IA32_UCODE_REV, 0); | ||
614 | 586 | ||
615 | /* As documented in the SDM: Do a CPUID 1 here */ | 587 | rev = intel_get_microcode_revision(); |
616 | cpuid_1(); | 588 | if (rev != mc->hdr.rev) |
617 | |||
618 | /* get the current revision from MSR 0x8B */ | ||
619 | native_rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); | ||
620 | if (val[1] != mc->hdr.rev) | ||
621 | return -1; | 589 | return -1; |
622 | 590 | ||
623 | #ifdef CONFIG_X86_64 | 591 | #ifdef CONFIG_X86_64 |
624 | /* Flush global tlb. This is precaution. */ | 592 | /* Flush global tlb. This is precaution. */ |
625 | flush_tlb_early(); | 593 | flush_tlb_early(); |
626 | #endif | 594 | #endif |
627 | uci->cpu_sig.rev = val[1]; | 595 | uci->cpu_sig.rev = rev; |
628 | 596 | ||
629 | if (early) | 597 | if (early) |
630 | print_ucode(uci); | 598 | print_ucode(uci); |
@@ -804,8 +772,8 @@ static int apply_microcode_intel(int cpu) | |||
804 | struct microcode_intel *mc; | 772 | struct microcode_intel *mc; |
805 | struct ucode_cpu_info *uci; | 773 | struct ucode_cpu_info *uci; |
806 | struct cpuinfo_x86 *c; | 774 | struct cpuinfo_x86 *c; |
807 | unsigned int val[2]; | ||
808 | static int prev_rev; | 775 | static int prev_rev; |
776 | u32 rev; | ||
809 | 777 | ||
810 | /* We should bind the task to the CPU */ | 778 | /* We should bind the task to the CPU */ |
811 | if (WARN_ON(raw_smp_processor_id() != cpu)) | 779 | if (WARN_ON(raw_smp_processor_id() != cpu)) |
@@ -822,33 +790,28 @@ static int apply_microcode_intel(int cpu) | |||
822 | 790 | ||
823 | /* write microcode via MSR 0x79 */ | 791 | /* write microcode via MSR 0x79 */ |
824 | wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); | 792 | wrmsrl(MSR_IA32_UCODE_WRITE, (unsigned long)mc->bits); |
825 | wrmsrl(MSR_IA32_UCODE_REV, 0); | ||
826 | |||
827 | /* As documented in the SDM: Do a CPUID 1 here */ | ||
828 | cpuid_1(); | ||
829 | 793 | ||
830 | /* get the current revision from MSR 0x8B */ | 794 | rev = intel_get_microcode_revision(); |
831 | rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]); | ||
832 | 795 | ||
833 | if (val[1] != mc->hdr.rev) { | 796 | if (rev != mc->hdr.rev) { |
834 | pr_err("CPU%d update to revision 0x%x failed\n", | 797 | pr_err("CPU%d update to revision 0x%x failed\n", |
835 | cpu, mc->hdr.rev); | 798 | cpu, mc->hdr.rev); |
836 | return -1; | 799 | return -1; |
837 | } | 800 | } |
838 | 801 | ||
839 | if (val[1] != prev_rev) { | 802 | if (rev != prev_rev) { |
840 | pr_info("updated to revision 0x%x, date = %04x-%02x-%02x\n", | 803 | pr_info("updated to revision 0x%x, date = %04x-%02x-%02x\n", |
841 | val[1], | 804 | rev, |
842 | mc->hdr.date & 0xffff, | 805 | mc->hdr.date & 0xffff, |
843 | mc->hdr.date >> 24, | 806 | mc->hdr.date >> 24, |
844 | (mc->hdr.date >> 16) & 0xff); | 807 | (mc->hdr.date >> 16) & 0xff); |
845 | prev_rev = val[1]; | 808 | prev_rev = rev; |
846 | } | 809 | } |
847 | 810 | ||
848 | c = &cpu_data(cpu); | 811 | c = &cpu_data(cpu); |
849 | 812 | ||
850 | uci->cpu_sig.rev = val[1]; | 813 | uci->cpu_sig.rev = rev; |
851 | c->microcode = val[1]; | 814 | c->microcode = rev; |
852 | 815 | ||
853 | return 0; | 816 | return 0; |
854 | } | 817 | } |
@@ -860,7 +823,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, | |||
860 | u8 *ucode_ptr = data, *new_mc = NULL, *mc = NULL; | 823 | u8 *ucode_ptr = data, *new_mc = NULL, *mc = NULL; |
861 | int new_rev = uci->cpu_sig.rev; | 824 | int new_rev = uci->cpu_sig.rev; |
862 | unsigned int leftover = size; | 825 | unsigned int leftover = size; |
863 | unsigned int curr_mc_size = 0; | 826 | unsigned int curr_mc_size = 0, new_mc_size = 0; |
864 | unsigned int csig, cpf; | 827 | unsigned int csig, cpf; |
865 | 828 | ||
866 | while (leftover) { | 829 | while (leftover) { |
@@ -901,6 +864,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, | |||
901 | vfree(new_mc); | 864 | vfree(new_mc); |
902 | new_rev = mc_header.rev; | 865 | new_rev = mc_header.rev; |
903 | new_mc = mc; | 866 | new_mc = mc; |
867 | new_mc_size = mc_size; | ||
904 | mc = NULL; /* trigger new vmalloc */ | 868 | mc = NULL; /* trigger new vmalloc */ |
905 | } | 869 | } |
906 | 870 | ||
@@ -926,7 +890,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, | |||
926 | * permanent memory. So it will be loaded early when a CPU is hot added | 890 | * permanent memory. So it will be loaded early when a CPU is hot added |
927 | * or resumes. | 891 | * or resumes. |
928 | */ | 892 | */ |
929 | save_mc_for_early(new_mc, curr_mc_size); | 893 | save_mc_for_early(new_mc, new_mc_size); |
930 | 894 | ||
931 | pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n", | 895 | pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n", |
932 | cpu, new_rev, uci->cpu_sig.rev); | 896 | cpu, new_rev, uci->cpu_sig.rev); |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index be3a49ee0356..e41af597aed8 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
@@ -694,6 +694,7 @@ unsigned long native_calibrate_tsc(void) | |||
694 | crystal_khz = 24000; /* 24.0 MHz */ | 694 | crystal_khz = 24000; /* 24.0 MHz */ |
695 | break; | 695 | break; |
696 | case INTEL_FAM6_SKYLAKE_X: | 696 | case INTEL_FAM6_SKYLAKE_X: |
697 | case INTEL_FAM6_ATOM_DENVERTON: | ||
697 | crystal_khz = 25000; /* 25.0 MHz */ | 698 | crystal_khz = 25000; /* 25.0 MHz */ |
698 | break; | 699 | break; |
699 | case INTEL_FAM6_ATOM_GOLDMONT: | 700 | case INTEL_FAM6_ATOM_GOLDMONT: |
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c index 4443e499f279..23d15565d02a 100644 --- a/arch/x86/kernel/unwind_frame.c +++ b/arch/x86/kernel/unwind_frame.c | |||
@@ -6,6 +6,21 @@ | |||
6 | 6 | ||
7 | #define FRAME_HEADER_SIZE (sizeof(long) * 2) | 7 | #define FRAME_HEADER_SIZE (sizeof(long) * 2) |
8 | 8 | ||
9 | /* | ||
10 | * This disables KASAN checking when reading a value from another task's stack, | ||
11 | * since the other task could be running on another CPU and could have poisoned | ||
12 | * the stack in the meantime. | ||
13 | */ | ||
14 | #define READ_ONCE_TASK_STACK(task, x) \ | ||
15 | ({ \ | ||
16 | unsigned long val; \ | ||
17 | if (task == current) \ | ||
18 | val = READ_ONCE(x); \ | ||
19 | else \ | ||
20 | val = READ_ONCE_NOCHECK(x); \ | ||
21 | val; \ | ||
22 | }) | ||
23 | |||
9 | static void unwind_dump(struct unwind_state *state, unsigned long *sp) | 24 | static void unwind_dump(struct unwind_state *state, unsigned long *sp) |
10 | { | 25 | { |
11 | static bool dumped_before = false; | 26 | static bool dumped_before = false; |
@@ -48,7 +63,8 @@ unsigned long unwind_get_return_address(struct unwind_state *state) | |||
48 | if (state->regs && user_mode(state->regs)) | 63 | if (state->regs && user_mode(state->regs)) |
49 | return 0; | 64 | return 0; |
50 | 65 | ||
51 | addr = ftrace_graph_ret_addr(state->task, &state->graph_idx, *addr_p, | 66 | addr = READ_ONCE_TASK_STACK(state->task, *addr_p); |
67 | addr = ftrace_graph_ret_addr(state->task, &state->graph_idx, addr, | ||
52 | addr_p); | 68 | addr_p); |
53 | 69 | ||
54 | return __kernel_text_address(addr) ? addr : 0; | 70 | return __kernel_text_address(addr) ? addr : 0; |
@@ -162,7 +178,7 @@ bool unwind_next_frame(struct unwind_state *state) | |||
162 | if (state->regs) | 178 | if (state->regs) |
163 | next_bp = (unsigned long *)state->regs->bp; | 179 | next_bp = (unsigned long *)state->regs->bp; |
164 | else | 180 | else |
165 | next_bp = (unsigned long *)*state->bp; | 181 | next_bp = (unsigned long *)READ_ONCE_TASK_STACK(state->task,*state->bp); |
166 | 182 | ||
167 | /* is the next frame pointer an encoded pointer to pt_regs? */ | 183 | /* is the next frame pointer an encoded pointer to pt_regs? */ |
168 | regs = decode_frame_pointer(next_bp); | 184 | regs = decode_frame_pointer(next_bp); |
@@ -207,6 +223,16 @@ bool unwind_next_frame(struct unwind_state *state) | |||
207 | return true; | 223 | return true; |
208 | 224 | ||
209 | bad_address: | 225 | bad_address: |
226 | /* | ||
227 | * When unwinding a non-current task, the task might actually be | ||
228 | * running on another CPU, in which case it could be modifying its | ||
229 | * stack while we're reading it. This is generally not a problem and | ||
230 | * can be ignored as long as the caller understands that unwinding | ||
231 | * another task will not always succeed. | ||
232 | */ | ||
233 | if (state->task != current) | ||
234 | goto the_end; | ||
235 | |||
210 | if (state->regs) { | 236 | if (state->regs) { |
211 | printk_deferred_once(KERN_WARNING | 237 | printk_deferred_once(KERN_WARNING |
212 | "WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n", | 238 | "WARNING: kernel stack regs at %p in %s:%d has bad 'bp' value %p\n", |
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c index 324e5713d386..af59f808742f 100644 --- a/arch/x86/mm/mpx.c +++ b/arch/x86/mm/mpx.c | |||
@@ -293,7 +293,7 @@ siginfo_t *mpx_generate_siginfo(struct pt_regs *regs) | |||
293 | * We were not able to extract an address from the instruction, | 293 | * We were not able to extract an address from the instruction, |
294 | * probably because there was something invalid in it. | 294 | * probably because there was something invalid in it. |
295 | */ | 295 | */ |
296 | if (info->si_addr == (void *)-1) { | 296 | if (info->si_addr == (void __user *)-1) { |
297 | err = -EINVAL; | 297 | err = -EINVAL; |
298 | goto err_out; | 298 | goto err_out; |
299 | } | 299 | } |
diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile index 61b5ed2b7d40..90e4f2a6625b 100644 --- a/arch/x86/platform/intel-mid/device_libs/Makefile +++ b/arch/x86/platform/intel-mid/device_libs/Makefile | |||
@@ -15,7 +15,7 @@ obj-$(subst m,y,$(CONFIG_INTEL_MID_POWER_BUTTON)) += platform_msic_power_btn.o | |||
15 | obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o | 15 | obj-$(subst m,y,$(CONFIG_GPIO_INTEL_PMIC)) += platform_pmic_gpio.o |
16 | obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o | 16 | obj-$(subst m,y,$(CONFIG_INTEL_MFLD_THERMAL)) += platform_msic_thermal.o |
17 | # SPI Devices | 17 | # SPI Devices |
18 | obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_spidev.o | 18 | obj-$(subst m,y,$(CONFIG_SPI_SPIDEV)) += platform_mrfld_spidev.o |
19 | # I2C Devices | 19 | # I2C Devices |
20 | obj-$(subst m,y,$(CONFIG_SENSORS_EMC1403)) += platform_emc1403.o | 20 | obj-$(subst m,y,$(CONFIG_SENSORS_EMC1403)) += platform_emc1403.o |
21 | obj-$(subst m,y,$(CONFIG_SENSORS_LIS3LV02D)) += platform_lis331.o | 21 | obj-$(subst m,y,$(CONFIG_SENSORS_LIS3LV02D)) += platform_lis331.o |
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_spidev.c b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c index 30c601b399ee..27186ad654c9 100644 --- a/arch/x86/platform/intel-mid/device_libs/platform_spidev.c +++ b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_spidev.c | |||
@@ -11,6 +11,7 @@ | |||
11 | * of the License. | 11 | * of the License. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/err.h> | ||
14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
15 | #include <linux/sfi.h> | 16 | #include <linux/sfi.h> |
16 | #include <linux/spi/pxa2xx_spi.h> | 17 | #include <linux/spi/pxa2xx_spi.h> |
@@ -34,6 +35,9 @@ static void __init *spidev_platform_data(void *info) | |||
34 | { | 35 | { |
35 | struct spi_board_info *spi_info = info; | 36 | struct spi_board_info *spi_info = info; |
36 | 37 | ||
38 | if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER) | ||
39 | return ERR_PTR(-ENODEV); | ||
40 | |||
37 | spi_info->mode = SPI_MODE_0; | 41 | spi_info->mode = SPI_MODE_0; |
38 | spi_info->controller_data = &spidev_spi_chip; | 42 | spi_info->controller_data = &spidev_spi_chip; |
39 | 43 | ||