diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-12 13:02:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-07-12 13:02:38 -0400 |
commit | 1daa1cfb7ab3b9f9b4c7e7a3f136e4e0066b123c (patch) | |
tree | 8deb1250fee8f49a50031c47d35863ceff7b3990 | |
parent | 7b732169e9d1f0f6614a8e85a9e65a9d755b3d86 (diff) | |
parent | 69711ca19b06d1b33d8f21213b540b5d1c638dbf (diff) |
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner:
- the high latency PIT detection fix, which slipped through the cracks
for rc1
- a regression fix for the early printk mechanism
- the x86 part to plug irq/vector related hotplug races
- move the allocation of the espfix pages on cpu hotplug to non atomic
context. The current code triggers a might_sleep() warning.
- a series of KASAN fixes addressing boot crashes and usability
- a trivial typo fix for Kconfig help text
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/kconfig: Fix typo in the CONFIG_CMDLINE_BOOL help text
x86/irq: Retrieve irq data after locking irq_desc
x86/irq: Use proper locking in check_irq_vectors_for_cpu_disable()
x86/irq: Plug irq vector hotplug race
x86/earlyprintk: Allow early_printk() to use console style parameters like '115200n8'
x86/espfix: Init espfix on the boot CPU side
x86/espfix: Add 'cpu' parameter to init_espfix_ap()
x86/kasan: Move KASAN_SHADOW_OFFSET to the arch Kconfig
x86/kasan: Add message about KASAN being initialized
x86/kasan: Fix boot crash on AMD processors
x86/kasan: Flush TLBs after switching CR3
x86/kasan: Fix KASAN shadow region page tables
x86/init: Clear 'init_level4_pgt' earlier
x86/tsc: Let high latency PIT fail fast in quick_pit_calibrate()
-rw-r--r-- | arch/x86/Kconfig | 7 | ||||
-rw-r--r-- | arch/x86/include/asm/espfix.h | 2 | ||||
-rw-r--r-- | arch/x86/include/asm/kasan.h | 8 | ||||
-rw-r--r-- | arch/x86/kernel/apic/vector.c | 10 | ||||
-rw-r--r-- | arch/x86/kernel/early_printk.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/espfix_64.c | 28 | ||||
-rw-r--r-- | arch/x86/kernel/head64.c | 10 | ||||
-rw-r--r-- | arch/x86/kernel/head_64.S | 29 | ||||
-rw-r--r-- | arch/x86/kernel/irq.c | 20 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 27 | ||||
-rw-r--r-- | arch/x86/kernel/tsc.c | 11 | ||||
-rw-r--r-- | arch/x86/mm/kasan_init_64.c | 47 | ||||
-rw-r--r-- | lib/Kconfig.kasan | 4 |
13 files changed, 116 insertions, 91 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 55bced17dc95..3dbb7e7909ca 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -254,6 +254,11 @@ config ARCH_SUPPORTS_OPTIMIZED_INLINING | |||
254 | config ARCH_SUPPORTS_DEBUG_PAGEALLOC | 254 | config ARCH_SUPPORTS_DEBUG_PAGEALLOC |
255 | def_bool y | 255 | def_bool y |
256 | 256 | ||
257 | config KASAN_SHADOW_OFFSET | ||
258 | hex | ||
259 | depends on KASAN | ||
260 | default 0xdffffc0000000000 | ||
261 | |||
257 | config HAVE_INTEL_TXT | 262 | config HAVE_INTEL_TXT |
258 | def_bool y | 263 | def_bool y |
259 | depends on INTEL_IOMMU && ACPI | 264 | depends on INTEL_IOMMU && ACPI |
@@ -2015,7 +2020,7 @@ config CMDLINE_BOOL | |||
2015 | 2020 | ||
2016 | To compile command line arguments into the kernel, | 2021 | To compile command line arguments into the kernel, |
2017 | set this option to 'Y', then fill in the | 2022 | set this option to 'Y', then fill in the |
2018 | the boot arguments in CONFIG_CMDLINE. | 2023 | boot arguments in CONFIG_CMDLINE. |
2019 | 2024 | ||
2020 | Systems with fully functional boot loaders (i.e. non-embedded) | 2025 | Systems with fully functional boot loaders (i.e. non-embedded) |
2021 | should leave this option set to 'N'. | 2026 | should leave this option set to 'N'. |
diff --git a/arch/x86/include/asm/espfix.h b/arch/x86/include/asm/espfix.h index 99efebb2f69d..ca3ce9ab9385 100644 --- a/arch/x86/include/asm/espfix.h +++ b/arch/x86/include/asm/espfix.h | |||
@@ -9,7 +9,7 @@ DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_stack); | |||
9 | DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr); | 9 | DECLARE_PER_CPU_READ_MOSTLY(unsigned long, espfix_waddr); |
10 | 10 | ||
11 | extern void init_espfix_bsp(void); | 11 | extern void init_espfix_bsp(void); |
12 | extern void init_espfix_ap(void); | 12 | extern void init_espfix_ap(int cpu); |
13 | 13 | ||
14 | #endif /* CONFIG_X86_64 */ | 14 | #endif /* CONFIG_X86_64 */ |
15 | 15 | ||
diff --git a/arch/x86/include/asm/kasan.h b/arch/x86/include/asm/kasan.h index 8b22422fbad8..74a2a8dc9908 100644 --- a/arch/x86/include/asm/kasan.h +++ b/arch/x86/include/asm/kasan.h | |||
@@ -14,15 +14,11 @@ | |||
14 | 14 | ||
15 | #ifndef __ASSEMBLY__ | 15 | #ifndef __ASSEMBLY__ |
16 | 16 | ||
17 | extern pte_t kasan_zero_pte[]; | ||
18 | extern pte_t kasan_zero_pmd[]; | ||
19 | extern pte_t kasan_zero_pud[]; | ||
20 | |||
21 | #ifdef CONFIG_KASAN | 17 | #ifdef CONFIG_KASAN |
22 | void __init kasan_map_early_shadow(pgd_t *pgd); | 18 | void __init kasan_early_init(void); |
23 | void __init kasan_init(void); | 19 | void __init kasan_init(void); |
24 | #else | 20 | #else |
25 | static inline void kasan_map_early_shadow(pgd_t *pgd) { } | 21 | static inline void kasan_early_init(void) { } |
26 | static inline void kasan_init(void) { } | 22 | static inline void kasan_init(void) { } |
27 | #endif | 23 | #endif |
28 | 24 | ||
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c index 28eba2d38b15..f813261d9740 100644 --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c | |||
@@ -409,12 +409,6 @@ static void __setup_vector_irq(int cpu) | |||
409 | int irq, vector; | 409 | int irq, vector; |
410 | struct apic_chip_data *data; | 410 | struct apic_chip_data *data; |
411 | 411 | ||
412 | /* | ||
413 | * vector_lock will make sure that we don't run into irq vector | ||
414 | * assignments that might be happening on another cpu in parallel, | ||
415 | * while we setup our initial vector to irq mappings. | ||
416 | */ | ||
417 | raw_spin_lock(&vector_lock); | ||
418 | /* Mark the inuse vectors */ | 412 | /* Mark the inuse vectors */ |
419 | for_each_active_irq(irq) { | 413 | for_each_active_irq(irq) { |
420 | data = apic_chip_data(irq_get_irq_data(irq)); | 414 | data = apic_chip_data(irq_get_irq_data(irq)); |
@@ -436,16 +430,16 @@ static void __setup_vector_irq(int cpu) | |||
436 | if (!cpumask_test_cpu(cpu, data->domain)) | 430 | if (!cpumask_test_cpu(cpu, data->domain)) |
437 | per_cpu(vector_irq, cpu)[vector] = VECTOR_UNDEFINED; | 431 | per_cpu(vector_irq, cpu)[vector] = VECTOR_UNDEFINED; |
438 | } | 432 | } |
439 | raw_spin_unlock(&vector_lock); | ||
440 | } | 433 | } |
441 | 434 | ||
442 | /* | 435 | /* |
443 | * Setup the vector to irq mappings. | 436 | * Setup the vector to irq mappings. Must be called with vector_lock held. |
444 | */ | 437 | */ |
445 | void setup_vector_irq(int cpu) | 438 | void setup_vector_irq(int cpu) |
446 | { | 439 | { |
447 | int irq; | 440 | int irq; |
448 | 441 | ||
442 | lockdep_assert_held(&vector_lock); | ||
449 | /* | 443 | /* |
450 | * On most of the platforms, legacy PIC delivers the interrupts on the | 444 | * On most of the platforms, legacy PIC delivers the interrupts on the |
451 | * boot cpu. But there are certain platforms where PIC interrupts are | 445 | * boot cpu. But there are certain platforms where PIC interrupts are |
diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c index 89427d8d4fc5..eec40f595ab9 100644 --- a/arch/x86/kernel/early_printk.c +++ b/arch/x86/kernel/early_printk.c | |||
@@ -175,7 +175,9 @@ static __init void early_serial_init(char *s) | |||
175 | } | 175 | } |
176 | 176 | ||
177 | if (*s) { | 177 | if (*s) { |
178 | if (kstrtoul(s, 0, &baud) < 0 || baud == 0) | 178 | baud = simple_strtoull(s, &e, 0); |
179 | |||
180 | if (baud == 0 || s == e) | ||
179 | baud = DEFAULT_BAUD; | 181 | baud = DEFAULT_BAUD; |
180 | } | 182 | } |
181 | 183 | ||
diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c index f5d0730e7b08..ce95676abd60 100644 --- a/arch/x86/kernel/espfix_64.c +++ b/arch/x86/kernel/espfix_64.c | |||
@@ -131,25 +131,24 @@ void __init init_espfix_bsp(void) | |||
131 | init_espfix_random(); | 131 | init_espfix_random(); |
132 | 132 | ||
133 | /* The rest is the same as for any other processor */ | 133 | /* The rest is the same as for any other processor */ |
134 | init_espfix_ap(); | 134 | init_espfix_ap(0); |
135 | } | 135 | } |
136 | 136 | ||
137 | void init_espfix_ap(void) | 137 | void init_espfix_ap(int cpu) |
138 | { | 138 | { |
139 | unsigned int cpu, page; | 139 | unsigned int page; |
140 | unsigned long addr; | 140 | unsigned long addr; |
141 | pud_t pud, *pud_p; | 141 | pud_t pud, *pud_p; |
142 | pmd_t pmd, *pmd_p; | 142 | pmd_t pmd, *pmd_p; |
143 | pte_t pte, *pte_p; | 143 | pte_t pte, *pte_p; |
144 | int n; | 144 | int n, node; |
145 | void *stack_page; | 145 | void *stack_page; |
146 | pteval_t ptemask; | 146 | pteval_t ptemask; |
147 | 147 | ||
148 | /* We only have to do this once... */ | 148 | /* We only have to do this once... */ |
149 | if (likely(this_cpu_read(espfix_stack))) | 149 | if (likely(per_cpu(espfix_stack, cpu))) |
150 | return; /* Already initialized */ | 150 | return; /* Already initialized */ |
151 | 151 | ||
152 | cpu = smp_processor_id(); | ||
153 | addr = espfix_base_addr(cpu); | 152 | addr = espfix_base_addr(cpu); |
154 | page = cpu/ESPFIX_STACKS_PER_PAGE; | 153 | page = cpu/ESPFIX_STACKS_PER_PAGE; |
155 | 154 | ||
@@ -165,12 +164,15 @@ void init_espfix_ap(void) | |||
165 | if (stack_page) | 164 | if (stack_page) |
166 | goto unlock_done; | 165 | goto unlock_done; |
167 | 166 | ||
167 | node = cpu_to_node(cpu); | ||
168 | ptemask = __supported_pte_mask; | 168 | ptemask = __supported_pte_mask; |
169 | 169 | ||
170 | pud_p = &espfix_pud_page[pud_index(addr)]; | 170 | pud_p = &espfix_pud_page[pud_index(addr)]; |
171 | pud = *pud_p; | 171 | pud = *pud_p; |
172 | if (!pud_present(pud)) { | 172 | if (!pud_present(pud)) { |
173 | pmd_p = (pmd_t *)__get_free_page(PGALLOC_GFP); | 173 | struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0); |
174 | |||
175 | pmd_p = (pmd_t *)page_address(page); | ||
174 | pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask)); | 176 | pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask)); |
175 | paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT); | 177 | paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT); |
176 | for (n = 0; n < ESPFIX_PUD_CLONES; n++) | 178 | for (n = 0; n < ESPFIX_PUD_CLONES; n++) |
@@ -180,7 +182,9 @@ void init_espfix_ap(void) | |||
180 | pmd_p = pmd_offset(&pud, addr); | 182 | pmd_p = pmd_offset(&pud, addr); |
181 | pmd = *pmd_p; | 183 | pmd = *pmd_p; |
182 | if (!pmd_present(pmd)) { | 184 | if (!pmd_present(pmd)) { |
183 | pte_p = (pte_t *)__get_free_page(PGALLOC_GFP); | 185 | struct page *page = alloc_pages_node(node, PGALLOC_GFP, 0); |
186 | |||
187 | pte_p = (pte_t *)page_address(page); | ||
184 | pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask)); | 188 | pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask)); |
185 | paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT); | 189 | paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT); |
186 | for (n = 0; n < ESPFIX_PMD_CLONES; n++) | 190 | for (n = 0; n < ESPFIX_PMD_CLONES; n++) |
@@ -188,7 +192,7 @@ void init_espfix_ap(void) | |||
188 | } | 192 | } |
189 | 193 | ||
190 | pte_p = pte_offset_kernel(&pmd, addr); | 194 | pte_p = pte_offset_kernel(&pmd, addr); |
191 | stack_page = (void *)__get_free_page(GFP_KERNEL); | 195 | stack_page = page_address(alloc_pages_node(node, GFP_KERNEL, 0)); |
192 | pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); | 196 | pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); |
193 | for (n = 0; n < ESPFIX_PTE_CLONES; n++) | 197 | for (n = 0; n < ESPFIX_PTE_CLONES; n++) |
194 | set_pte(&pte_p[n*PTE_STRIDE], pte); | 198 | set_pte(&pte_p[n*PTE_STRIDE], pte); |
@@ -199,7 +203,7 @@ void init_espfix_ap(void) | |||
199 | unlock_done: | 203 | unlock_done: |
200 | mutex_unlock(&espfix_init_mutex); | 204 | mutex_unlock(&espfix_init_mutex); |
201 | done: | 205 | done: |
202 | this_cpu_write(espfix_stack, addr); | 206 | per_cpu(espfix_stack, cpu) = addr; |
203 | this_cpu_write(espfix_waddr, (unsigned long)stack_page | 207 | per_cpu(espfix_waddr, cpu) = (unsigned long)stack_page |
204 | + (addr & ~PAGE_MASK)); | 208 | + (addr & ~PAGE_MASK); |
205 | } | 209 | } |
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c index 5a4668136e98..f129a9af6357 100644 --- a/arch/x86/kernel/head64.c +++ b/arch/x86/kernel/head64.c | |||
@@ -161,11 +161,12 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) | |||
161 | /* Kill off the identity-map trampoline */ | 161 | /* Kill off the identity-map trampoline */ |
162 | reset_early_page_tables(); | 162 | reset_early_page_tables(); |
163 | 163 | ||
164 | kasan_map_early_shadow(early_level4_pgt); | ||
165 | |||
166 | /* clear bss before set_intr_gate with early_idt_handler */ | ||
167 | clear_bss(); | 164 | clear_bss(); |
168 | 165 | ||
166 | clear_page(init_level4_pgt); | ||
167 | |||
168 | kasan_early_init(); | ||
169 | |||
169 | for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) | 170 | for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) |
170 | set_intr_gate(i, early_idt_handler_array[i]); | 171 | set_intr_gate(i, early_idt_handler_array[i]); |
171 | load_idt((const struct desc_ptr *)&idt_descr); | 172 | load_idt((const struct desc_ptr *)&idt_descr); |
@@ -177,12 +178,9 @@ asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) | |||
177 | */ | 178 | */ |
178 | load_ucode_bsp(); | 179 | load_ucode_bsp(); |
179 | 180 | ||
180 | clear_page(init_level4_pgt); | ||
181 | /* set init_level4_pgt kernel high mapping*/ | 181 | /* set init_level4_pgt kernel high mapping*/ |
182 | init_level4_pgt[511] = early_level4_pgt[511]; | 182 | init_level4_pgt[511] = early_level4_pgt[511]; |
183 | 183 | ||
184 | kasan_map_early_shadow(init_level4_pgt); | ||
185 | |||
186 | x86_64_start_reservations(real_mode_data); | 184 | x86_64_start_reservations(real_mode_data); |
187 | } | 185 | } |
188 | 186 | ||
diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S index e5c27f729a38..1d40ca8a73f2 100644 --- a/arch/x86/kernel/head_64.S +++ b/arch/x86/kernel/head_64.S | |||
@@ -516,38 +516,9 @@ ENTRY(phys_base) | |||
516 | /* This must match the first entry in level2_kernel_pgt */ | 516 | /* This must match the first entry in level2_kernel_pgt */ |
517 | .quad 0x0000000000000000 | 517 | .quad 0x0000000000000000 |
518 | 518 | ||
519 | #ifdef CONFIG_KASAN | ||
520 | #define FILL(VAL, COUNT) \ | ||
521 | .rept (COUNT) ; \ | ||
522 | .quad (VAL) ; \ | ||
523 | .endr | ||
524 | |||
525 | NEXT_PAGE(kasan_zero_pte) | ||
526 | FILL(kasan_zero_page - __START_KERNEL_map + _KERNPG_TABLE, 512) | ||
527 | NEXT_PAGE(kasan_zero_pmd) | ||
528 | FILL(kasan_zero_pte - __START_KERNEL_map + _KERNPG_TABLE, 512) | ||
529 | NEXT_PAGE(kasan_zero_pud) | ||
530 | FILL(kasan_zero_pmd - __START_KERNEL_map + _KERNPG_TABLE, 512) | ||
531 | |||
532 | #undef FILL | ||
533 | #endif | ||
534 | |||
535 | |||
536 | #include "../../x86/xen/xen-head.S" | 519 | #include "../../x86/xen/xen-head.S" |
537 | 520 | ||
538 | __PAGE_ALIGNED_BSS | 521 | __PAGE_ALIGNED_BSS |
539 | NEXT_PAGE(empty_zero_page) | 522 | NEXT_PAGE(empty_zero_page) |
540 | .skip PAGE_SIZE | 523 | .skip PAGE_SIZE |
541 | 524 | ||
542 | #ifdef CONFIG_KASAN | ||
543 | /* | ||
544 | * This page used as early shadow. We don't use empty_zero_page | ||
545 | * at early stages, stack instrumentation could write some garbage | ||
546 | * to this page. | ||
547 | * Latter we reuse it as zero shadow for large ranges of memory | ||
548 | * that allowed to access, but not instrumented by kasan | ||
549 | * (vmalloc/vmemmap ...). | ||
550 | */ | ||
551 | NEXT_PAGE(kasan_zero_page) | ||
552 | .skip PAGE_SIZE | ||
553 | #endif | ||
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 88b366487b0e..c7dfe1be784e 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c | |||
@@ -347,14 +347,22 @@ int check_irq_vectors_for_cpu_disable(void) | |||
347 | if (!desc) | 347 | if (!desc) |
348 | continue; | 348 | continue; |
349 | 349 | ||
350 | /* | ||
351 | * Protect against concurrent action removal, | ||
352 | * affinity changes etc. | ||
353 | */ | ||
354 | raw_spin_lock(&desc->lock); | ||
350 | data = irq_desc_get_irq_data(desc); | 355 | data = irq_desc_get_irq_data(desc); |
351 | cpumask_copy(&affinity_new, data->affinity); | 356 | cpumask_copy(&affinity_new, data->affinity); |
352 | cpumask_clear_cpu(this_cpu, &affinity_new); | 357 | cpumask_clear_cpu(this_cpu, &affinity_new); |
353 | 358 | ||
354 | /* Do not count inactive or per-cpu irqs. */ | 359 | /* Do not count inactive or per-cpu irqs. */ |
355 | if (!irq_has_action(irq) || irqd_is_per_cpu(data)) | 360 | if (!irq_has_action(irq) || irqd_is_per_cpu(data)) { |
361 | raw_spin_unlock(&desc->lock); | ||
356 | continue; | 362 | continue; |
363 | } | ||
357 | 364 | ||
365 | raw_spin_unlock(&desc->lock); | ||
358 | /* | 366 | /* |
359 | * A single irq may be mapped to multiple | 367 | * A single irq may be mapped to multiple |
360 | * cpu's vector_irq[] (for example IOAPIC cluster | 368 | * cpu's vector_irq[] (for example IOAPIC cluster |
@@ -385,6 +393,9 @@ int check_irq_vectors_for_cpu_disable(void) | |||
385 | * vector. If the vector is marked in the used vectors | 393 | * vector. If the vector is marked in the used vectors |
386 | * bitmap or an irq is assigned to it, we don't count | 394 | * bitmap or an irq is assigned to it, we don't count |
387 | * it as available. | 395 | * it as available. |
396 | * | ||
397 | * As this is an inaccurate snapshot anyway, we can do | ||
398 | * this w/o holding vector_lock. | ||
388 | */ | 399 | */ |
389 | for (vector = FIRST_EXTERNAL_VECTOR; | 400 | for (vector = FIRST_EXTERNAL_VECTOR; |
390 | vector < first_system_vector; vector++) { | 401 | vector < first_system_vector; vector++) { |
@@ -486,6 +497,11 @@ void fixup_irqs(void) | |||
486 | */ | 497 | */ |
487 | mdelay(1); | 498 | mdelay(1); |
488 | 499 | ||
500 | /* | ||
501 | * We can walk the vector array of this cpu without holding | ||
502 | * vector_lock because the cpu is already marked !online, so | ||
503 | * nothing else will touch it. | ||
504 | */ | ||
489 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { | 505 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { |
490 | unsigned int irr; | 506 | unsigned int irr; |
491 | 507 | ||
@@ -497,9 +513,9 @@ void fixup_irqs(void) | |||
497 | irq = __this_cpu_read(vector_irq[vector]); | 513 | irq = __this_cpu_read(vector_irq[vector]); |
498 | 514 | ||
499 | desc = irq_to_desc(irq); | 515 | desc = irq_to_desc(irq); |
516 | raw_spin_lock(&desc->lock); | ||
500 | data = irq_desc_get_irq_data(desc); | 517 | data = irq_desc_get_irq_data(desc); |
501 | chip = irq_data_get_irq_chip(data); | 518 | chip = irq_data_get_irq_chip(data); |
502 | raw_spin_lock(&desc->lock); | ||
503 | if (chip->irq_retrigger) { | 519 | if (chip->irq_retrigger) { |
504 | chip->irq_retrigger(data); | 520 | chip->irq_retrigger(data); |
505 | __this_cpu_write(vector_irq[vector], VECTOR_RETRIGGERED); | 521 | __this_cpu_write(vector_irq[vector], VECTOR_RETRIGGERED); |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 8add66b22f33..d3010aa79daf 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -171,11 +171,6 @@ static void smp_callin(void) | |||
171 | apic_ap_setup(); | 171 | apic_ap_setup(); |
172 | 172 | ||
173 | /* | 173 | /* |
174 | * Need to setup vector mappings before we enable interrupts. | ||
175 | */ | ||
176 | setup_vector_irq(smp_processor_id()); | ||
177 | |||
178 | /* | ||
179 | * Save our processor parameters. Note: this information | 174 | * Save our processor parameters. Note: this information |
180 | * is needed for clock calibration. | 175 | * is needed for clock calibration. |
181 | */ | 176 | */ |
@@ -239,18 +234,13 @@ static void notrace start_secondary(void *unused) | |||
239 | check_tsc_sync_target(); | 234 | check_tsc_sync_target(); |
240 | 235 | ||
241 | /* | 236 | /* |
242 | * Enable the espfix hack for this CPU | 237 | * Lock vector_lock and initialize the vectors on this cpu |
243 | */ | 238 | * before setting the cpu online. We must set it online with |
244 | #ifdef CONFIG_X86_ESPFIX64 | 239 | * vector_lock held to prevent a concurrent setup/teardown |
245 | init_espfix_ap(); | 240 | * from seeing a half valid vector space. |
246 | #endif | ||
247 | |||
248 | /* | ||
249 | * We need to hold vector_lock so there the set of online cpus | ||
250 | * does not change while we are assigning vectors to cpus. Holding | ||
251 | * this lock ensures we don't half assign or remove an irq from a cpu. | ||
252 | */ | 241 | */ |
253 | lock_vector_lock(); | 242 | lock_vector_lock(); |
243 | setup_vector_irq(smp_processor_id()); | ||
254 | set_cpu_online(smp_processor_id(), true); | 244 | set_cpu_online(smp_processor_id(), true); |
255 | unlock_vector_lock(); | 245 | unlock_vector_lock(); |
256 | cpu_set_state_online(smp_processor_id()); | 246 | cpu_set_state_online(smp_processor_id()); |
@@ -854,6 +844,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | |||
854 | initial_code = (unsigned long)start_secondary; | 844 | initial_code = (unsigned long)start_secondary; |
855 | stack_start = idle->thread.sp; | 845 | stack_start = idle->thread.sp; |
856 | 846 | ||
847 | /* | ||
848 | * Enable the espfix hack for this CPU | ||
849 | */ | ||
850 | #ifdef CONFIG_X86_ESPFIX64 | ||
851 | init_espfix_ap(cpu); | ||
852 | #endif | ||
853 | |||
857 | /* So we see what's up */ | 854 | /* So we see what's up */ |
858 | announce_cpu(cpu, apicid); | 855 | announce_cpu(cpu, apicid); |
859 | 856 | ||
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 505449700e0c..7437b41f6a47 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
@@ -598,10 +598,19 @@ static unsigned long quick_pit_calibrate(void) | |||
598 | if (!pit_expect_msb(0xff-i, &delta, &d2)) | 598 | if (!pit_expect_msb(0xff-i, &delta, &d2)) |
599 | break; | 599 | break; |
600 | 600 | ||
601 | delta -= tsc; | ||
602 | |||
603 | /* | ||
604 | * Extrapolate the error and fail fast if the error will | ||
605 | * never be below 500 ppm. | ||
606 | */ | ||
607 | if (i == 1 && | ||
608 | d1 + d2 >= (delta * MAX_QUICK_PIT_ITERATIONS) >> 11) | ||
609 | return 0; | ||
610 | |||
601 | /* | 611 | /* |
602 | * Iterate until the error is less than 500 ppm | 612 | * Iterate until the error is less than 500 ppm |
603 | */ | 613 | */ |
604 | delta -= tsc; | ||
605 | if (d1+d2 >= delta >> 11) | 614 | if (d1+d2 >= delta >> 11) |
606 | continue; | 615 | continue; |
607 | 616 | ||
diff --git a/arch/x86/mm/kasan_init_64.c b/arch/x86/mm/kasan_init_64.c index 4860906c6b9f..e1840f3db5b5 100644 --- a/arch/x86/mm/kasan_init_64.c +++ b/arch/x86/mm/kasan_init_64.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #define pr_fmt(fmt) "kasan: " fmt | ||
1 | #include <linux/bootmem.h> | 2 | #include <linux/bootmem.h> |
2 | #include <linux/kasan.h> | 3 | #include <linux/kasan.h> |
3 | #include <linux/kdebug.h> | 4 | #include <linux/kdebug.h> |
@@ -11,7 +12,19 @@ | |||
11 | extern pgd_t early_level4_pgt[PTRS_PER_PGD]; | 12 | extern pgd_t early_level4_pgt[PTRS_PER_PGD]; |
12 | extern struct range pfn_mapped[E820_X_MAX]; | 13 | extern struct range pfn_mapped[E820_X_MAX]; |
13 | 14 | ||
14 | extern unsigned char kasan_zero_page[PAGE_SIZE]; | 15 | static pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_bss; |
16 | static pmd_t kasan_zero_pmd[PTRS_PER_PMD] __page_aligned_bss; | ||
17 | static pte_t kasan_zero_pte[PTRS_PER_PTE] __page_aligned_bss; | ||
18 | |||
19 | /* | ||
20 | * This page used as early shadow. We don't use empty_zero_page | ||
21 | * at early stages, stack instrumentation could write some garbage | ||
22 | * to this page. | ||
23 | * Latter we reuse it as zero shadow for large ranges of memory | ||
24 | * that allowed to access, but not instrumented by kasan | ||
25 | * (vmalloc/vmemmap ...). | ||
26 | */ | ||
27 | static unsigned char kasan_zero_page[PAGE_SIZE] __page_aligned_bss; | ||
15 | 28 | ||
16 | static int __init map_range(struct range *range) | 29 | static int __init map_range(struct range *range) |
17 | { | 30 | { |
@@ -36,7 +49,7 @@ static void __init clear_pgds(unsigned long start, | |||
36 | pgd_clear(pgd_offset_k(start)); | 49 | pgd_clear(pgd_offset_k(start)); |
37 | } | 50 | } |
38 | 51 | ||
39 | void __init kasan_map_early_shadow(pgd_t *pgd) | 52 | static void __init kasan_map_early_shadow(pgd_t *pgd) |
40 | { | 53 | { |
41 | int i; | 54 | int i; |
42 | unsigned long start = KASAN_SHADOW_START; | 55 | unsigned long start = KASAN_SHADOW_START; |
@@ -73,7 +86,7 @@ static int __init zero_pmd_populate(pud_t *pud, unsigned long addr, | |||
73 | while (IS_ALIGNED(addr, PMD_SIZE) && addr + PMD_SIZE <= end) { | 86 | while (IS_ALIGNED(addr, PMD_SIZE) && addr + PMD_SIZE <= end) { |
74 | WARN_ON(!pmd_none(*pmd)); | 87 | WARN_ON(!pmd_none(*pmd)); |
75 | set_pmd(pmd, __pmd(__pa_nodebug(kasan_zero_pte) | 88 | set_pmd(pmd, __pmd(__pa_nodebug(kasan_zero_pte) |
76 | | __PAGE_KERNEL_RO)); | 89 | | _KERNPG_TABLE)); |
77 | addr += PMD_SIZE; | 90 | addr += PMD_SIZE; |
78 | pmd = pmd_offset(pud, addr); | 91 | pmd = pmd_offset(pud, addr); |
79 | } | 92 | } |
@@ -99,7 +112,7 @@ static int __init zero_pud_populate(pgd_t *pgd, unsigned long addr, | |||
99 | while (IS_ALIGNED(addr, PUD_SIZE) && addr + PUD_SIZE <= end) { | 112 | while (IS_ALIGNED(addr, PUD_SIZE) && addr + PUD_SIZE <= end) { |
100 | WARN_ON(!pud_none(*pud)); | 113 | WARN_ON(!pud_none(*pud)); |
101 | set_pud(pud, __pud(__pa_nodebug(kasan_zero_pmd) | 114 | set_pud(pud, __pud(__pa_nodebug(kasan_zero_pmd) |
102 | | __PAGE_KERNEL_RO)); | 115 | | _KERNPG_TABLE)); |
103 | addr += PUD_SIZE; | 116 | addr += PUD_SIZE; |
104 | pud = pud_offset(pgd, addr); | 117 | pud = pud_offset(pgd, addr); |
105 | } | 118 | } |
@@ -124,7 +137,7 @@ static int __init zero_pgd_populate(unsigned long addr, unsigned long end) | |||
124 | while (IS_ALIGNED(addr, PGDIR_SIZE) && addr + PGDIR_SIZE <= end) { | 137 | while (IS_ALIGNED(addr, PGDIR_SIZE) && addr + PGDIR_SIZE <= end) { |
125 | WARN_ON(!pgd_none(*pgd)); | 138 | WARN_ON(!pgd_none(*pgd)); |
126 | set_pgd(pgd, __pgd(__pa_nodebug(kasan_zero_pud) | 139 | set_pgd(pgd, __pgd(__pa_nodebug(kasan_zero_pud) |
127 | | __PAGE_KERNEL_RO)); | 140 | | _KERNPG_TABLE)); |
128 | addr += PGDIR_SIZE; | 141 | addr += PGDIR_SIZE; |
129 | pgd = pgd_offset_k(addr); | 142 | pgd = pgd_offset_k(addr); |
130 | } | 143 | } |
@@ -166,6 +179,26 @@ static struct notifier_block kasan_die_notifier = { | |||
166 | }; | 179 | }; |
167 | #endif | 180 | #endif |
168 | 181 | ||
182 | void __init kasan_early_init(void) | ||
183 | { | ||
184 | int i; | ||
185 | pteval_t pte_val = __pa_nodebug(kasan_zero_page) | __PAGE_KERNEL; | ||
186 | pmdval_t pmd_val = __pa_nodebug(kasan_zero_pte) | _KERNPG_TABLE; | ||
187 | pudval_t pud_val = __pa_nodebug(kasan_zero_pmd) | _KERNPG_TABLE; | ||
188 | |||
189 | for (i = 0; i < PTRS_PER_PTE; i++) | ||
190 | kasan_zero_pte[i] = __pte(pte_val); | ||
191 | |||
192 | for (i = 0; i < PTRS_PER_PMD; i++) | ||
193 | kasan_zero_pmd[i] = __pmd(pmd_val); | ||
194 | |||
195 | for (i = 0; i < PTRS_PER_PUD; i++) | ||
196 | kasan_zero_pud[i] = __pud(pud_val); | ||
197 | |||
198 | kasan_map_early_shadow(early_level4_pgt); | ||
199 | kasan_map_early_shadow(init_level4_pgt); | ||
200 | } | ||
201 | |||
169 | void __init kasan_init(void) | 202 | void __init kasan_init(void) |
170 | { | 203 | { |
171 | int i; | 204 | int i; |
@@ -176,6 +209,7 @@ void __init kasan_init(void) | |||
176 | 209 | ||
177 | memcpy(early_level4_pgt, init_level4_pgt, sizeof(early_level4_pgt)); | 210 | memcpy(early_level4_pgt, init_level4_pgt, sizeof(early_level4_pgt)); |
178 | load_cr3(early_level4_pgt); | 211 | load_cr3(early_level4_pgt); |
212 | __flush_tlb_all(); | ||
179 | 213 | ||
180 | clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); | 214 | clear_pgds(KASAN_SHADOW_START, KASAN_SHADOW_END); |
181 | 215 | ||
@@ -202,5 +236,8 @@ void __init kasan_init(void) | |||
202 | memset(kasan_zero_page, 0, PAGE_SIZE); | 236 | memset(kasan_zero_page, 0, PAGE_SIZE); |
203 | 237 | ||
204 | load_cr3(init_level4_pgt); | 238 | load_cr3(init_level4_pgt); |
239 | __flush_tlb_all(); | ||
205 | init_task.kasan_depth = 0; | 240 | init_task.kasan_depth = 0; |
241 | |||
242 | pr_info("Kernel address sanitizer initialized\n"); | ||
206 | } | 243 | } |
diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 777eda7d1ab4..39f24d6721e5 100644 --- a/lib/Kconfig.kasan +++ b/lib/Kconfig.kasan | |||
@@ -18,10 +18,6 @@ config KASAN | |||
18 | For better error detection enable CONFIG_STACKTRACE, | 18 | For better error detection enable CONFIG_STACKTRACE, |
19 | and add slub_debug=U to boot cmdline. | 19 | and add slub_debug=U to boot cmdline. |
20 | 20 | ||
21 | config KASAN_SHADOW_OFFSET | ||
22 | hex | ||
23 | default 0xdffffc0000000000 if X86_64 | ||
24 | |||
25 | choice | 21 | choice |
26 | prompt "Instrumentation type" | 22 | prompt "Instrumentation type" |
27 | depends on KASAN | 23 | depends on KASAN |