diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2015-01-30 04:38:15 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-01-30 04:38:15 -0500 |
commit | b6afdbe8e841e20297a38e2af0a053d8eb26c19b (patch) | |
tree | 4a336799dcd7d77a7d1f1e9b46b9e48551053524 /arch/x86 | |
parent | 8090f7917b5d7cc2390afe33cb12f819173ef9c8 (diff) | |
parent | 26bc420b59a38e4e6685a73345a0def461136dce (diff) |
Merge tag 'v3.19-rc6' into devel
Linux 3.19-rc6
Diffstat (limited to 'arch/x86')
38 files changed, 424 insertions, 225 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index ba397bde7948..0dc9d0144a27 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -857,7 +857,7 @@ source "kernel/Kconfig.preempt" | |||
857 | 857 | ||
858 | config X86_UP_APIC | 858 | config X86_UP_APIC |
859 | bool "Local APIC support on uniprocessors" | 859 | bool "Local APIC support on uniprocessors" |
860 | depends on X86_32 && !SMP && !X86_32_NON_STANDARD && !PCI_MSI | 860 | depends on X86_32 && !SMP && !X86_32_NON_STANDARD |
861 | ---help--- | 861 | ---help--- |
862 | A local APIC (Advanced Programmable Interrupt Controller) is an | 862 | A local APIC (Advanced Programmable Interrupt Controller) is an |
863 | integrated interrupt controller in the CPU. If you have a single-CPU | 863 | integrated interrupt controller in the CPU. If you have a single-CPU |
@@ -868,6 +868,10 @@ config X86_UP_APIC | |||
868 | performance counters), and the NMI watchdog which detects hard | 868 | performance counters), and the NMI watchdog which detects hard |
869 | lockups. | 869 | lockups. |
870 | 870 | ||
871 | config X86_UP_APIC_MSI | ||
872 | def_bool y | ||
873 | select X86_UP_APIC if X86_32 && !SMP && !X86_32_NON_STANDARD && PCI_MSI | ||
874 | |||
871 | config X86_UP_IOAPIC | 875 | config X86_UP_IOAPIC |
872 | bool "IO-APIC support on uniprocessors" | 876 | bool "IO-APIC support on uniprocessors" |
873 | depends on X86_UP_APIC | 877 | depends on X86_UP_APIC |
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 5b016e2498f3..3db07f30636f 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile | |||
@@ -51,6 +51,7 @@ targets += cpustr.h | |||
51 | $(obj)/cpustr.h: $(obj)/mkcpustr FORCE | 51 | $(obj)/cpustr.h: $(obj)/mkcpustr FORCE |
52 | $(call if_changed,cpustr) | 52 | $(call if_changed,cpustr) |
53 | endif | 53 | endif |
54 | clean-files += cpustr.h | ||
54 | 55 | ||
55 | # --------------------------------------------------------------------------- | 56 | # --------------------------------------------------------------------------- |
56 | 57 | ||
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index dcc1c536cc21..a950864a64da 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c | |||
@@ -373,6 +373,8 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, | |||
373 | unsigned long output_len, | 373 | unsigned long output_len, |
374 | unsigned long run_size) | 374 | unsigned long run_size) |
375 | { | 375 | { |
376 | unsigned char *output_orig = output; | ||
377 | |||
376 | real_mode = rmode; | 378 | real_mode = rmode; |
377 | 379 | ||
378 | sanitize_boot_params(real_mode); | 380 | sanitize_boot_params(real_mode); |
@@ -421,7 +423,12 @@ asmlinkage __visible void *decompress_kernel(void *rmode, memptr heap, | |||
421 | debug_putstr("\nDecompressing Linux... "); | 423 | debug_putstr("\nDecompressing Linux... "); |
422 | decompress(input_data, input_len, NULL, NULL, output, NULL, error); | 424 | decompress(input_data, input_len, NULL, NULL, output, NULL, error); |
423 | parse_elf(output); | 425 | parse_elf(output); |
424 | handle_relocations(output, output_len); | 426 | /* |
427 | * 32-bit always performs relocations. 64-bit relocations are only | ||
428 | * needed if kASLR has chosen a different load address. | ||
429 | */ | ||
430 | if (!IS_ENABLED(CONFIG_X86_64) || output != output_orig) | ||
431 | handle_relocations(output, output_len); | ||
425 | debug_putstr("done.\nBooting the kernel.\n"); | 432 | debug_putstr("done.\nBooting the kernel.\n"); |
426 | return output; | 433 | return output; |
427 | } | 434 | } |
diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile index fd0f848938cc..5a4a089e8b1f 100644 --- a/arch/x86/crypto/Makefile +++ b/arch/x86/crypto/Makefile | |||
@@ -26,7 +26,6 @@ obj-$(CONFIG_CRYPTO_GHASH_CLMUL_NI_INTEL) += ghash-clmulni-intel.o | |||
26 | 26 | ||
27 | obj-$(CONFIG_CRYPTO_CRC32C_INTEL) += crc32c-intel.o | 27 | obj-$(CONFIG_CRYPTO_CRC32C_INTEL) += crc32c-intel.o |
28 | obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o | 28 | obj-$(CONFIG_CRYPTO_SHA1_SSSE3) += sha1-ssse3.o |
29 | obj-$(CONFIG_CRYPTO_SHA1_MB) += sha-mb/ | ||
30 | obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o | 29 | obj-$(CONFIG_CRYPTO_CRC32_PCLMUL) += crc32-pclmul.o |
31 | obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o | 30 | obj-$(CONFIG_CRYPTO_SHA256_SSSE3) += sha256-ssse3.o |
32 | obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o | 31 | obj-$(CONFIG_CRYPTO_SHA512_SSSE3) += sha512-ssse3.o |
@@ -46,6 +45,7 @@ endif | |||
46 | ifeq ($(avx2_supported),yes) | 45 | ifeq ($(avx2_supported),yes) |
47 | obj-$(CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64) += camellia-aesni-avx2.o | 46 | obj-$(CONFIG_CRYPTO_CAMELLIA_AESNI_AVX2_X86_64) += camellia-aesni-avx2.o |
48 | obj-$(CONFIG_CRYPTO_SERPENT_AVX2_X86_64) += serpent-avx2.o | 47 | obj-$(CONFIG_CRYPTO_SERPENT_AVX2_X86_64) += serpent-avx2.o |
48 | obj-$(CONFIG_CRYPTO_SHA1_MB) += sha-mb/ | ||
49 | endif | 49 | endif |
50 | 50 | ||
51 | aes-i586-y := aes-i586-asm_32.o aes_glue.o | 51 | aes-i586-y := aes-i586-asm_32.o aes_glue.o |
diff --git a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S index 2df2a0298f5a..a916c4a61165 100644 --- a/arch/x86/crypto/aes_ctrby8_avx-x86_64.S +++ b/arch/x86/crypto/aes_ctrby8_avx-x86_64.S | |||
@@ -208,7 +208,7 @@ ddq_add_8: | |||
208 | 208 | ||
209 | .if (klen == KEY_128) | 209 | .if (klen == KEY_128) |
210 | .if (load_keys) | 210 | .if (load_keys) |
211 | vmovdqa 3*16(p_keys), xkeyA | 211 | vmovdqa 3*16(p_keys), xkey4 |
212 | .endif | 212 | .endif |
213 | .else | 213 | .else |
214 | vmovdqa 3*16(p_keys), xkeyA | 214 | vmovdqa 3*16(p_keys), xkeyA |
@@ -224,7 +224,7 @@ ddq_add_8: | |||
224 | add $(16*by), p_in | 224 | add $(16*by), p_in |
225 | 225 | ||
226 | .if (klen == KEY_128) | 226 | .if (klen == KEY_128) |
227 | vmovdqa 4*16(p_keys), xkey4 | 227 | vmovdqa 4*16(p_keys), xkeyB |
228 | .else | 228 | .else |
229 | .if (load_keys) | 229 | .if (load_keys) |
230 | vmovdqa 4*16(p_keys), xkey4 | 230 | vmovdqa 4*16(p_keys), xkey4 |
@@ -234,7 +234,12 @@ ddq_add_8: | |||
234 | .set i, 0 | 234 | .set i, 0 |
235 | .rept by | 235 | .rept by |
236 | club XDATA, i | 236 | club XDATA, i |
237 | vaesenc xkeyA, var_xdata, var_xdata /* key 3 */ | 237 | /* key 3 */ |
238 | .if (klen == KEY_128) | ||
239 | vaesenc xkey4, var_xdata, var_xdata | ||
240 | .else | ||
241 | vaesenc xkeyA, var_xdata, var_xdata | ||
242 | .endif | ||
238 | .set i, (i +1) | 243 | .set i, (i +1) |
239 | .endr | 244 | .endr |
240 | 245 | ||
@@ -243,13 +248,18 @@ ddq_add_8: | |||
243 | .set i, 0 | 248 | .set i, 0 |
244 | .rept by | 249 | .rept by |
245 | club XDATA, i | 250 | club XDATA, i |
246 | vaesenc xkey4, var_xdata, var_xdata /* key 4 */ | 251 | /* key 4 */ |
252 | .if (klen == KEY_128) | ||
253 | vaesenc xkeyB, var_xdata, var_xdata | ||
254 | .else | ||
255 | vaesenc xkey4, var_xdata, var_xdata | ||
256 | .endif | ||
247 | .set i, (i +1) | 257 | .set i, (i +1) |
248 | .endr | 258 | .endr |
249 | 259 | ||
250 | .if (klen == KEY_128) | 260 | .if (klen == KEY_128) |
251 | .if (load_keys) | 261 | .if (load_keys) |
252 | vmovdqa 6*16(p_keys), xkeyB | 262 | vmovdqa 6*16(p_keys), xkey8 |
253 | .endif | 263 | .endif |
254 | .else | 264 | .else |
255 | vmovdqa 6*16(p_keys), xkeyB | 265 | vmovdqa 6*16(p_keys), xkeyB |
@@ -267,12 +277,17 @@ ddq_add_8: | |||
267 | .set i, 0 | 277 | .set i, 0 |
268 | .rept by | 278 | .rept by |
269 | club XDATA, i | 279 | club XDATA, i |
270 | vaesenc xkeyB, var_xdata, var_xdata /* key 6 */ | 280 | /* key 6 */ |
281 | .if (klen == KEY_128) | ||
282 | vaesenc xkey8, var_xdata, var_xdata | ||
283 | .else | ||
284 | vaesenc xkeyB, var_xdata, var_xdata | ||
285 | .endif | ||
271 | .set i, (i +1) | 286 | .set i, (i +1) |
272 | .endr | 287 | .endr |
273 | 288 | ||
274 | .if (klen == KEY_128) | 289 | .if (klen == KEY_128) |
275 | vmovdqa 8*16(p_keys), xkey8 | 290 | vmovdqa 8*16(p_keys), xkeyB |
276 | .else | 291 | .else |
277 | .if (load_keys) | 292 | .if (load_keys) |
278 | vmovdqa 8*16(p_keys), xkey8 | 293 | vmovdqa 8*16(p_keys), xkey8 |
@@ -288,7 +303,7 @@ ddq_add_8: | |||
288 | 303 | ||
289 | .if (klen == KEY_128) | 304 | .if (klen == KEY_128) |
290 | .if (load_keys) | 305 | .if (load_keys) |
291 | vmovdqa 9*16(p_keys), xkeyA | 306 | vmovdqa 9*16(p_keys), xkey12 |
292 | .endif | 307 | .endif |
293 | .else | 308 | .else |
294 | vmovdqa 9*16(p_keys), xkeyA | 309 | vmovdqa 9*16(p_keys), xkeyA |
@@ -297,7 +312,12 @@ ddq_add_8: | |||
297 | .set i, 0 | 312 | .set i, 0 |
298 | .rept by | 313 | .rept by |
299 | club XDATA, i | 314 | club XDATA, i |
300 | vaesenc xkey8, var_xdata, var_xdata /* key 8 */ | 315 | /* key 8 */ |
316 | .if (klen == KEY_128) | ||
317 | vaesenc xkeyB, var_xdata, var_xdata | ||
318 | .else | ||
319 | vaesenc xkey8, var_xdata, var_xdata | ||
320 | .endif | ||
301 | .set i, (i +1) | 321 | .set i, (i +1) |
302 | .endr | 322 | .endr |
303 | 323 | ||
@@ -306,7 +326,12 @@ ddq_add_8: | |||
306 | .set i, 0 | 326 | .set i, 0 |
307 | .rept by | 327 | .rept by |
308 | club XDATA, i | 328 | club XDATA, i |
309 | vaesenc xkeyA, var_xdata, var_xdata /* key 9 */ | 329 | /* key 9 */ |
330 | .if (klen == KEY_128) | ||
331 | vaesenc xkey12, var_xdata, var_xdata | ||
332 | .else | ||
333 | vaesenc xkeyA, var_xdata, var_xdata | ||
334 | .endif | ||
310 | .set i, (i +1) | 335 | .set i, (i +1) |
311 | .endr | 336 | .endr |
312 | 337 | ||
@@ -412,7 +437,6 @@ ddq_add_8: | |||
412 | /* main body of aes ctr load */ | 437 | /* main body of aes ctr load */ |
413 | 438 | ||
414 | .macro do_aes_ctrmain key_len | 439 | .macro do_aes_ctrmain key_len |
415 | |||
416 | cmp $16, num_bytes | 440 | cmp $16, num_bytes |
417 | jb .Ldo_return2\key_len | 441 | jb .Ldo_return2\key_len |
418 | 442 | ||
diff --git a/arch/x86/crypto/sha-mb/sha1_mb.c b/arch/x86/crypto/sha-mb/sha1_mb.c index a225a5ca1037..fd9f6b035b16 100644 --- a/arch/x86/crypto/sha-mb/sha1_mb.c +++ b/arch/x86/crypto/sha-mb/sha1_mb.c | |||
@@ -931,4 +931,4 @@ module_exit(sha1_mb_mod_fini); | |||
931 | MODULE_LICENSE("GPL"); | 931 | MODULE_LICENSE("GPL"); |
932 | MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, multi buffer accelerated"); | 932 | MODULE_DESCRIPTION("SHA1 Secure Hash Algorithm, multi buffer accelerated"); |
933 | 933 | ||
934 | MODULE_ALIAS("sha1"); | 934 | MODULE_ALIAS_CRYPTO("sha1"); |
diff --git a/arch/x86/include/asm/acpi.h b/arch/x86/include/asm/acpi.h index 0ab4f9fd2687..3a45668f6dc3 100644 --- a/arch/x86/include/asm/acpi.h +++ b/arch/x86/include/asm/acpi.h | |||
@@ -50,6 +50,7 @@ void acpi_pic_sci_set_trigger(unsigned int, u16); | |||
50 | 50 | ||
51 | extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi, | 51 | extern int (*__acpi_register_gsi)(struct device *dev, u32 gsi, |
52 | int trigger, int polarity); | 52 | int trigger, int polarity); |
53 | extern void (*__acpi_unregister_gsi)(u32 gsi); | ||
53 | 54 | ||
54 | static inline void disable_acpi(void) | 55 | static inline void disable_acpi(void) |
55 | { | 56 | { |
diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h index 50d033a8947d..a94b82e8f156 100644 --- a/arch/x86/include/asm/desc.h +++ b/arch/x86/include/asm/desc.h | |||
@@ -251,7 +251,8 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu) | |||
251 | gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]; | 251 | gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i]; |
252 | } | 252 | } |
253 | 253 | ||
254 | #define _LDT_empty(info) \ | 254 | /* This intentionally ignores lm, since 32-bit apps don't have that field. */ |
255 | #define LDT_empty(info) \ | ||
255 | ((info)->base_addr == 0 && \ | 256 | ((info)->base_addr == 0 && \ |
256 | (info)->limit == 0 && \ | 257 | (info)->limit == 0 && \ |
257 | (info)->contents == 0 && \ | 258 | (info)->contents == 0 && \ |
@@ -261,11 +262,18 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu) | |||
261 | (info)->seg_not_present == 1 && \ | 262 | (info)->seg_not_present == 1 && \ |
262 | (info)->useable == 0) | 263 | (info)->useable == 0) |
263 | 264 | ||
264 | #ifdef CONFIG_X86_64 | 265 | /* Lots of programs expect an all-zero user_desc to mean "no segment at all". */ |
265 | #define LDT_empty(info) (_LDT_empty(info) && ((info)->lm == 0)) | 266 | static inline bool LDT_zero(const struct user_desc *info) |
266 | #else | 267 | { |
267 | #define LDT_empty(info) (_LDT_empty(info)) | 268 | return (info->base_addr == 0 && |
268 | #endif | 269 | info->limit == 0 && |
270 | info->contents == 0 && | ||
271 | info->read_exec_only == 0 && | ||
272 | info->seg_32bit == 0 && | ||
273 | info->limit_in_pages == 0 && | ||
274 | info->seg_not_present == 0 && | ||
275 | info->useable == 0); | ||
276 | } | ||
269 | 277 | ||
270 | static inline void clear_LDT(void) | 278 | static inline void clear_LDT(void) |
271 | { | 279 | { |
diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index 40269a2bf6f9..4b75d591eb5e 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h | |||
@@ -130,7 +130,25 @@ static inline void arch_bprm_mm_init(struct mm_struct *mm, | |||
130 | static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, | 130 | static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma, |
131 | unsigned long start, unsigned long end) | 131 | unsigned long start, unsigned long end) |
132 | { | 132 | { |
133 | mpx_notify_unmap(mm, vma, start, end); | 133 | /* |
134 | * mpx_notify_unmap() goes and reads a rarely-hot | ||
135 | * cacheline in the mm_struct. That can be expensive | ||
136 | * enough to be seen in profiles. | ||
137 | * | ||
138 | * The mpx_notify_unmap() call and its contents have been | ||
139 | * observed to affect munmap() performance on hardware | ||
140 | * where MPX is not present. | ||
141 | * | ||
142 | * The unlikely() optimizes for the fast case: no MPX | ||
143 | * in the CPU, or no MPX use in the process. Even if | ||
144 | * we get this wrong (in the unlikely event that MPX | ||
145 | * is widely enabled on some system) the overhead of | ||
146 | * MPX itself (reading bounds tables) is expected to | ||
147 | * overwhelm the overhead of getting this unlikely() | ||
148 | * consistently wrong. | ||
149 | */ | ||
150 | if (unlikely(cpu_feature_enabled(X86_FEATURE_MPX))) | ||
151 | mpx_notify_unmap(mm, vma, start, end); | ||
134 | } | 152 | } |
135 | 153 | ||
136 | #endif /* _ASM_X86_MMU_CONTEXT_H */ | 154 | #endif /* _ASM_X86_MMU_CONTEXT_H */ |
diff --git a/arch/x86/include/asm/vgtod.h b/arch/x86/include/asm/vgtod.h index e7e9682a33e9..f556c4843aa1 100644 --- a/arch/x86/include/asm/vgtod.h +++ b/arch/x86/include/asm/vgtod.h | |||
@@ -80,9 +80,11 @@ static inline unsigned int __getcpu(void) | |||
80 | 80 | ||
81 | /* | 81 | /* |
82 | * Load per CPU data from GDT. LSL is faster than RDTSCP and | 82 | * Load per CPU data from GDT. LSL is faster than RDTSCP and |
83 | * works on all CPUs. | 83 | * works on all CPUs. This is volatile so that it orders |
84 | * correctly wrt barrier() and to keep gcc from cleverly | ||
85 | * hoisting it out of the calling function. | ||
84 | */ | 86 | */ |
85 | asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG)); | 87 | asm volatile ("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG)); |
86 | 88 | ||
87 | return p; | 89 | return p; |
88 | } | 90 | } |
diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c index 4433a4be8171..b9e30daa0881 100644 --- a/arch/x86/kernel/acpi/boot.c +++ b/arch/x86/kernel/acpi/boot.c | |||
@@ -611,20 +611,20 @@ void __init acpi_pic_sci_set_trigger(unsigned int irq, u16 trigger) | |||
611 | 611 | ||
612 | int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) | 612 | int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp) |
613 | { | 613 | { |
614 | int irq; | 614 | int rc, irq, trigger, polarity; |
615 | 615 | ||
616 | if (acpi_irq_model == ACPI_IRQ_MODEL_PIC) { | 616 | rc = acpi_get_override_irq(gsi, &trigger, &polarity); |
617 | *irqp = gsi; | 617 | if (rc == 0) { |
618 | } else { | 618 | trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; |
619 | mutex_lock(&acpi_ioapic_lock); | 619 | polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; |
620 | irq = mp_map_gsi_to_irq(gsi, | 620 | irq = acpi_register_gsi(NULL, gsi, trigger, polarity); |
621 | IOAPIC_MAP_ALLOC | IOAPIC_MAP_CHECK); | 621 | if (irq >= 0) { |
622 | mutex_unlock(&acpi_ioapic_lock); | 622 | *irqp = irq; |
623 | if (irq < 0) | 623 | return 0; |
624 | return -1; | 624 | } |
625 | *irqp = irq; | ||
626 | } | 625 | } |
627 | return 0; | 626 | |
627 | return -1; | ||
628 | } | 628 | } |
629 | EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); | 629 | EXPORT_SYMBOL_GPL(acpi_gsi_to_irq); |
630 | 630 | ||
@@ -750,13 +750,13 @@ static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) | |||
750 | } | 750 | } |
751 | 751 | ||
752 | /* wrapper to silence section mismatch warning */ | 752 | /* wrapper to silence section mismatch warning */ |
753 | int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu) | 753 | int __ref acpi_map_cpu(acpi_handle handle, int physid, int *pcpu) |
754 | { | 754 | { |
755 | return _acpi_map_lsapic(handle, physid, pcpu); | 755 | return _acpi_map_lsapic(handle, physid, pcpu); |
756 | } | 756 | } |
757 | EXPORT_SYMBOL(acpi_map_lsapic); | 757 | EXPORT_SYMBOL(acpi_map_cpu); |
758 | 758 | ||
759 | int acpi_unmap_lsapic(int cpu) | 759 | int acpi_unmap_cpu(int cpu) |
760 | { | 760 | { |
761 | #ifdef CONFIG_ACPI_NUMA | 761 | #ifdef CONFIG_ACPI_NUMA |
762 | set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE); | 762 | set_apicid_to_node(per_cpu(x86_cpu_to_apicid, cpu), NUMA_NO_NODE); |
@@ -768,8 +768,7 @@ int acpi_unmap_lsapic(int cpu) | |||
768 | 768 | ||
769 | return (0); | 769 | return (0); |
770 | } | 770 | } |
771 | 771 | EXPORT_SYMBOL(acpi_unmap_cpu); | |
772 | EXPORT_SYMBOL(acpi_unmap_lsapic); | ||
773 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ | 772 | #endif /* CONFIG_ACPI_HOTPLUG_CPU */ |
774 | 773 | ||
775 | int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) | 774 | int acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base) |
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile index e27b49d7c922..80091ae54c2b 100644 --- a/arch/x86/kernel/cpu/Makefile +++ b/arch/x86/kernel/cpu/Makefile | |||
@@ -66,3 +66,4 @@ targets += capflags.c | |||
66 | $(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.sh FORCE | 66 | $(obj)/capflags.c: $(cpufeature) $(src)/mkcapflags.sh FORCE |
67 | $(call if_changed,mkcapflags) | 67 | $(call if_changed,mkcapflags) |
68 | endif | 68 | endif |
69 | clean-files += capflags.c | ||
diff --git a/arch/x86/kernel/cpu/mkcapflags.sh b/arch/x86/kernel/cpu/mkcapflags.sh index e2b22df964cd..36d99a337b49 100644 --- a/arch/x86/kernel/cpu/mkcapflags.sh +++ b/arch/x86/kernel/cpu/mkcapflags.sh | |||
@@ -28,7 +28,7 @@ function dump_array() | |||
28 | # If the /* comment */ starts with a quote string, grab that. | 28 | # If the /* comment */ starts with a quote string, grab that. |
29 | VALUE="$(echo "$i" | sed -n 's@.*/\* *\("[^"]*"\).*\*/@\1@p')" | 29 | VALUE="$(echo "$i" | sed -n 's@.*/\* *\("[^"]*"\).*\*/@\1@p')" |
30 | [ -z "$VALUE" ] && VALUE="\"$NAME\"" | 30 | [ -z "$VALUE" ] && VALUE="\"$NAME\"" |
31 | [ "$VALUE" == '""' ] && continue | 31 | [ "$VALUE" = '""' ] && continue |
32 | 32 | ||
33 | # Name is uppercase, VALUE is all lowercase | 33 | # Name is uppercase, VALUE is all lowercase |
34 | VALUE="$(echo "$VALUE" | tr A-Z a-z)" | 34 | VALUE="$(echo "$VALUE" | tr A-Z a-z)" |
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index a450373e8e91..939155ffdece 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c | |||
@@ -107,6 +107,7 @@ static struct clocksource hyperv_cs = { | |||
107 | .rating = 400, /* use this when running on Hyperv*/ | 107 | .rating = 400, /* use this when running on Hyperv*/ |
108 | .read = read_hv_clock, | 108 | .read = read_hv_clock, |
109 | .mask = CLOCKSOURCE_MASK(64), | 109 | .mask = CLOCKSOURCE_MASK(64), |
110 | .flags = CLOCK_SOURCE_IS_CONTINUOUS, | ||
110 | }; | 111 | }; |
111 | 112 | ||
112 | static void __init ms_hyperv_init_platform(void) | 113 | static void __init ms_hyperv_init_platform(void) |
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c index 3c895d480cd7..073983398364 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c | |||
@@ -568,8 +568,8 @@ struct event_constraint intel_atom_pebs_event_constraints[] = { | |||
568 | }; | 568 | }; |
569 | 569 | ||
570 | struct event_constraint intel_slm_pebs_event_constraints[] = { | 570 | struct event_constraint intel_slm_pebs_event_constraints[] = { |
571 | /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ | 571 | /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ |
572 | INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), | 572 | INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x1), |
573 | /* Allow all events as PEBS with no flags */ | 573 | /* Allow all events as PEBS with no flags */ |
574 | INTEL_ALL_EVENT_CONSTRAINT(0, 0x1), | 574 | INTEL_ALL_EVENT_CONSTRAINT(0, 0x1), |
575 | EVENT_CONSTRAINT_END | 575 | EVENT_CONSTRAINT_END |
diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c index 673f930c700f..6e434f8e5fc8 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c +++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c | |||
@@ -103,6 +103,13 @@ static struct kobj_attribute format_attr_##_var = \ | |||
103 | 103 | ||
104 | #define RAPL_CNTR_WIDTH 32 /* 32-bit rapl counters */ | 104 | #define RAPL_CNTR_WIDTH 32 /* 32-bit rapl counters */ |
105 | 105 | ||
106 | #define RAPL_EVENT_ATTR_STR(_name, v, str) \ | ||
107 | static struct perf_pmu_events_attr event_attr_##v = { \ | ||
108 | .attr = __ATTR(_name, 0444, rapl_sysfs_show, NULL), \ | ||
109 | .id = 0, \ | ||
110 | .event_str = str, \ | ||
111 | }; | ||
112 | |||
106 | struct rapl_pmu { | 113 | struct rapl_pmu { |
107 | spinlock_t lock; | 114 | spinlock_t lock; |
108 | int hw_unit; /* 1/2^hw_unit Joule */ | 115 | int hw_unit; /* 1/2^hw_unit Joule */ |
@@ -379,23 +386,36 @@ static struct attribute_group rapl_pmu_attr_group = { | |||
379 | .attrs = rapl_pmu_attrs, | 386 | .attrs = rapl_pmu_attrs, |
380 | }; | 387 | }; |
381 | 388 | ||
382 | EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); | 389 | static ssize_t rapl_sysfs_show(struct device *dev, |
383 | EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); | 390 | struct device_attribute *attr, |
384 | EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); | 391 | char *page) |
385 | EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); | 392 | { |
393 | struct perf_pmu_events_attr *pmu_attr = \ | ||
394 | container_of(attr, struct perf_pmu_events_attr, attr); | ||
395 | |||
396 | if (pmu_attr->event_str) | ||
397 | return sprintf(page, "%s", pmu_attr->event_str); | ||
398 | |||
399 | return 0; | ||
400 | } | ||
401 | |||
402 | RAPL_EVENT_ATTR_STR(energy-cores, rapl_cores, "event=0x01"); | ||
403 | RAPL_EVENT_ATTR_STR(energy-pkg , rapl_pkg, "event=0x02"); | ||
404 | RAPL_EVENT_ATTR_STR(energy-ram , rapl_ram, "event=0x03"); | ||
405 | RAPL_EVENT_ATTR_STR(energy-gpu , rapl_gpu, "event=0x04"); | ||
386 | 406 | ||
387 | EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); | 407 | RAPL_EVENT_ATTR_STR(energy-cores.unit, rapl_cores_unit, "Joules"); |
388 | EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); | 408 | RAPL_EVENT_ATTR_STR(energy-pkg.unit , rapl_pkg_unit, "Joules"); |
389 | EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); | 409 | RAPL_EVENT_ATTR_STR(energy-ram.unit , rapl_ram_unit, "Joules"); |
390 | EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); | 410 | RAPL_EVENT_ATTR_STR(energy-gpu.unit , rapl_gpu_unit, "Joules"); |
391 | 411 | ||
392 | /* | 412 | /* |
393 | * we compute in 0.23 nJ increments regardless of MSR | 413 | * we compute in 0.23 nJ increments regardless of MSR |
394 | */ | 414 | */ |
395 | EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890625e-10"); | 415 | RAPL_EVENT_ATTR_STR(energy-cores.scale, rapl_cores_scale, "2.3283064365386962890625e-10"); |
396 | EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10"); | 416 | RAPL_EVENT_ATTR_STR(energy-pkg.scale, rapl_pkg_scale, "2.3283064365386962890625e-10"); |
397 | EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); | 417 | RAPL_EVENT_ATTR_STR(energy-ram.scale, rapl_ram_scale, "2.3283064365386962890625e-10"); |
398 | EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); | 418 | RAPL_EVENT_ATTR_STR(energy-gpu.scale, rapl_gpu_scale, "2.3283064365386962890625e-10"); |
399 | 419 | ||
400 | static struct attribute *rapl_events_srv_attr[] = { | 420 | static struct attribute *rapl_events_srv_attr[] = { |
401 | EVENT_PTR(rapl_cores), | 421 | EVENT_PTR(rapl_cores), |
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h index 18eb78bbdd10..863d9b02563e 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h | |||
@@ -17,7 +17,7 @@ | |||
17 | #define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff) | 17 | #define UNCORE_PCI_DEV_TYPE(data) ((data >> 8) & 0xff) |
18 | #define UNCORE_PCI_DEV_IDX(data) (data & 0xff) | 18 | #define UNCORE_PCI_DEV_IDX(data) (data & 0xff) |
19 | #define UNCORE_EXTRA_PCI_DEV 0xff | 19 | #define UNCORE_EXTRA_PCI_DEV 0xff |
20 | #define UNCORE_EXTRA_PCI_DEV_MAX 2 | 20 | #define UNCORE_EXTRA_PCI_DEV_MAX 3 |
21 | 21 | ||
22 | /* support up to 8 sockets */ | 22 | /* support up to 8 sockets */ |
23 | #define UNCORE_SOCKET_MAX 8 | 23 | #define UNCORE_SOCKET_MAX 8 |
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c index 745b158e9a65..21af6149edf2 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore_snbep.c | |||
@@ -891,6 +891,7 @@ void snbep_uncore_cpu_init(void) | |||
891 | enum { | 891 | enum { |
892 | SNBEP_PCI_QPI_PORT0_FILTER, | 892 | SNBEP_PCI_QPI_PORT0_FILTER, |
893 | SNBEP_PCI_QPI_PORT1_FILTER, | 893 | SNBEP_PCI_QPI_PORT1_FILTER, |
894 | HSWEP_PCI_PCU_3, | ||
894 | }; | 895 | }; |
895 | 896 | ||
896 | static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event) | 897 | static int snbep_qpi_hw_config(struct intel_uncore_box *box, struct perf_event *event) |
@@ -2026,6 +2027,17 @@ void hswep_uncore_cpu_init(void) | |||
2026 | { | 2027 | { |
2027 | if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) | 2028 | if (hswep_uncore_cbox.num_boxes > boot_cpu_data.x86_max_cores) |
2028 | hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; | 2029 | hswep_uncore_cbox.num_boxes = boot_cpu_data.x86_max_cores; |
2030 | |||
2031 | /* Detect 6-8 core systems with only two SBOXes */ | ||
2032 | if (uncore_extra_pci_dev[0][HSWEP_PCI_PCU_3]) { | ||
2033 | u32 capid4; | ||
2034 | |||
2035 | pci_read_config_dword(uncore_extra_pci_dev[0][HSWEP_PCI_PCU_3], | ||
2036 | 0x94, &capid4); | ||
2037 | if (((capid4 >> 6) & 0x3) == 0) | ||
2038 | hswep_uncore_sbox.num_boxes = 2; | ||
2039 | } | ||
2040 | |||
2029 | uncore_msr_uncores = hswep_msr_uncores; | 2041 | uncore_msr_uncores = hswep_msr_uncores; |
2030 | } | 2042 | } |
2031 | 2043 | ||
@@ -2287,6 +2299,11 @@ static DEFINE_PCI_DEVICE_TABLE(hswep_uncore_pci_ids) = { | |||
2287 | .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, | 2299 | .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, |
2288 | SNBEP_PCI_QPI_PORT1_FILTER), | 2300 | SNBEP_PCI_QPI_PORT1_FILTER), |
2289 | }, | 2301 | }, |
2302 | { /* PCU.3 (for Capability registers) */ | ||
2303 | PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x2fc0), | ||
2304 | .driver_data = UNCORE_PCI_DEV_DATA(UNCORE_EXTRA_PCI_DEV, | ||
2305 | HSWEP_PCI_PCU_3), | ||
2306 | }, | ||
2290 | { /* end: all zeroes */ } | 2307 | { /* end: all zeroes */ } |
2291 | }; | 2308 | }; |
2292 | 2309 | ||
diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 2142376dc8c6..8b7b0a51e742 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c | |||
@@ -674,7 +674,7 @@ static inline void *alloc_tramp(unsigned long size) | |||
674 | } | 674 | } |
675 | static inline void tramp_free(void *tramp) | 675 | static inline void tramp_free(void *tramp) |
676 | { | 676 | { |
677 | module_free(NULL, tramp); | 677 | module_memfree(tramp); |
678 | } | 678 | } |
679 | #else | 679 | #else |
680 | /* Trampolines can only be created if modules are supported */ | 680 | /* Trampolines can only be created if modules are supported */ |
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 6307a0f0cf17..705ef8d48e2d 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c | |||
@@ -127,7 +127,7 @@ int arch_show_interrupts(struct seq_file *p, int prec) | |||
127 | seq_puts(p, " Machine check polls\n"); | 127 | seq_puts(p, " Machine check polls\n"); |
128 | #endif | 128 | #endif |
129 | #if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN) | 129 | #if IS_ENABLED(CONFIG_HYPERV) || defined(CONFIG_XEN) |
130 | seq_printf(p, "%*s: ", prec, "THR"); | 130 | seq_printf(p, "%*s: ", prec, "HYP"); |
131 | for_each_online_cpu(j) | 131 | for_each_online_cpu(j) |
132 | seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count); | 132 | seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count); |
133 | seq_puts(p, " Hypervisor callback interrupts\n"); | 133 | seq_puts(p, " Hypervisor callback interrupts\n"); |
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index f7e3cd50ece0..98f654d466e5 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
@@ -1020,6 +1020,15 @@ int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) | |||
1020 | regs->flags &= ~X86_EFLAGS_IF; | 1020 | regs->flags &= ~X86_EFLAGS_IF; |
1021 | trace_hardirqs_off(); | 1021 | trace_hardirqs_off(); |
1022 | regs->ip = (unsigned long)(jp->entry); | 1022 | regs->ip = (unsigned long)(jp->entry); |
1023 | |||
1024 | /* | ||
1025 | * jprobes use jprobe_return() which skips the normal return | ||
1026 | * path of the function, and this messes up the accounting of the | ||
1027 | * function graph tracer to get messed up. | ||
1028 | * | ||
1029 | * Pause function graph tracing while performing the jprobe function. | ||
1030 | */ | ||
1031 | pause_graph_tracing(); | ||
1023 | return 1; | 1032 | return 1; |
1024 | } | 1033 | } |
1025 | NOKPROBE_SYMBOL(setjmp_pre_handler); | 1034 | NOKPROBE_SYMBOL(setjmp_pre_handler); |
@@ -1048,24 +1057,25 @@ int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) | |||
1048 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); | 1057 | struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); |
1049 | u8 *addr = (u8 *) (regs->ip - 1); | 1058 | u8 *addr = (u8 *) (regs->ip - 1); |
1050 | struct jprobe *jp = container_of(p, struct jprobe, kp); | 1059 | struct jprobe *jp = container_of(p, struct jprobe, kp); |
1060 | void *saved_sp = kcb->jprobe_saved_sp; | ||
1051 | 1061 | ||
1052 | if ((addr > (u8 *) jprobe_return) && | 1062 | if ((addr > (u8 *) jprobe_return) && |
1053 | (addr < (u8 *) jprobe_return_end)) { | 1063 | (addr < (u8 *) jprobe_return_end)) { |
1054 | if (stack_addr(regs) != kcb->jprobe_saved_sp) { | 1064 | if (stack_addr(regs) != saved_sp) { |
1055 | struct pt_regs *saved_regs = &kcb->jprobe_saved_regs; | 1065 | struct pt_regs *saved_regs = &kcb->jprobe_saved_regs; |
1056 | printk(KERN_ERR | 1066 | printk(KERN_ERR |
1057 | "current sp %p does not match saved sp %p\n", | 1067 | "current sp %p does not match saved sp %p\n", |
1058 | stack_addr(regs), kcb->jprobe_saved_sp); | 1068 | stack_addr(regs), saved_sp); |
1059 | printk(KERN_ERR "Saved registers for jprobe %p\n", jp); | 1069 | printk(KERN_ERR "Saved registers for jprobe %p\n", jp); |
1060 | show_regs(saved_regs); | 1070 | show_regs(saved_regs); |
1061 | printk(KERN_ERR "Current registers\n"); | 1071 | printk(KERN_ERR "Current registers\n"); |
1062 | show_regs(regs); | 1072 | show_regs(regs); |
1063 | BUG(); | 1073 | BUG(); |
1064 | } | 1074 | } |
1075 | /* It's OK to start function graph tracing again */ | ||
1076 | unpause_graph_tracing(); | ||
1065 | *regs = kcb->jprobe_saved_regs; | 1077 | *regs = kcb->jprobe_saved_regs; |
1066 | memcpy((kprobe_opcode_t *)(kcb->jprobe_saved_sp), | 1078 | memcpy(saved_sp, kcb->jprobes_stack, MIN_STACK_SIZE(saved_sp)); |
1067 | kcb->jprobes_stack, | ||
1068 | MIN_STACK_SIZE(kcb->jprobe_saved_sp)); | ||
1069 | preempt_enable_no_resched(); | 1079 | preempt_enable_no_resched(); |
1070 | return 1; | 1080 | return 1; |
1071 | } | 1081 | } |
diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c index e309cc5c276e..781861cc5ee8 100644 --- a/arch/x86/kernel/perf_regs.c +++ b/arch/x86/kernel/perf_regs.c | |||
@@ -78,6 +78,14 @@ u64 perf_reg_abi(struct task_struct *task) | |||
78 | { | 78 | { |
79 | return PERF_SAMPLE_REGS_ABI_32; | 79 | return PERF_SAMPLE_REGS_ABI_32; |
80 | } | 80 | } |
81 | |||
82 | void perf_get_regs_user(struct perf_regs *regs_user, | ||
83 | struct pt_regs *regs, | ||
84 | struct pt_regs *regs_user_copy) | ||
85 | { | ||
86 | regs_user->regs = task_pt_regs(current); | ||
87 | regs_user->abi = perf_reg_abi(current); | ||
88 | } | ||
81 | #else /* CONFIG_X86_64 */ | 89 | #else /* CONFIG_X86_64 */ |
82 | #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \ | 90 | #define REG_NOSUPPORT ((1ULL << PERF_REG_X86_DS) | \ |
83 | (1ULL << PERF_REG_X86_ES) | \ | 91 | (1ULL << PERF_REG_X86_ES) | \ |
@@ -102,4 +110,86 @@ u64 perf_reg_abi(struct task_struct *task) | |||
102 | else | 110 | else |
103 | return PERF_SAMPLE_REGS_ABI_64; | 111 | return PERF_SAMPLE_REGS_ABI_64; |
104 | } | 112 | } |
113 | |||
114 | void perf_get_regs_user(struct perf_regs *regs_user, | ||
115 | struct pt_regs *regs, | ||
116 | struct pt_regs *regs_user_copy) | ||
117 | { | ||
118 | struct pt_regs *user_regs = task_pt_regs(current); | ||
119 | |||
120 | /* | ||
121 | * If we're in an NMI that interrupted task_pt_regs setup, then | ||
122 | * we can't sample user regs at all. This check isn't really | ||
123 | * sufficient, though, as we could be in an NMI inside an interrupt | ||
124 | * that happened during task_pt_regs setup. | ||
125 | */ | ||
126 | if (regs->sp > (unsigned long)&user_regs->r11 && | ||
127 | regs->sp <= (unsigned long)(user_regs + 1)) { | ||
128 | regs_user->abi = PERF_SAMPLE_REGS_ABI_NONE; | ||
129 | regs_user->regs = NULL; | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * RIP, flags, and the argument registers are usually saved. | ||
135 | * orig_ax is probably okay, too. | ||
136 | */ | ||
137 | regs_user_copy->ip = user_regs->ip; | ||
138 | regs_user_copy->cx = user_regs->cx; | ||
139 | regs_user_copy->dx = user_regs->dx; | ||
140 | regs_user_copy->si = user_regs->si; | ||
141 | regs_user_copy->di = user_regs->di; | ||
142 | regs_user_copy->r8 = user_regs->r8; | ||
143 | regs_user_copy->r9 = user_regs->r9; | ||
144 | regs_user_copy->r10 = user_regs->r10; | ||
145 | regs_user_copy->r11 = user_regs->r11; | ||
146 | regs_user_copy->orig_ax = user_regs->orig_ax; | ||
147 | regs_user_copy->flags = user_regs->flags; | ||
148 | |||
149 | /* | ||
150 | * Don't even try to report the "rest" regs. | ||
151 | */ | ||
152 | regs_user_copy->bx = -1; | ||
153 | regs_user_copy->bp = -1; | ||
154 | regs_user_copy->r12 = -1; | ||
155 | regs_user_copy->r13 = -1; | ||
156 | regs_user_copy->r14 = -1; | ||
157 | regs_user_copy->r15 = -1; | ||
158 | |||
159 | /* | ||
160 | * For this to be at all useful, we need a reasonable guess for | ||
161 | * sp and the ABI. Be careful: we're in NMI context, and we're | ||
162 | * considering current to be the current task, so we should | ||
163 | * be careful not to look at any other percpu variables that might | ||
164 | * change during context switches. | ||
165 | */ | ||
166 | if (IS_ENABLED(CONFIG_IA32_EMULATION) && | ||
167 | task_thread_info(current)->status & TS_COMPAT) { | ||
168 | /* Easy case: we're in a compat syscall. */ | ||
169 | regs_user->abi = PERF_SAMPLE_REGS_ABI_32; | ||
170 | regs_user_copy->sp = user_regs->sp; | ||
171 | regs_user_copy->cs = user_regs->cs; | ||
172 | regs_user_copy->ss = user_regs->ss; | ||
173 | } else if (user_regs->orig_ax != -1) { | ||
174 | /* | ||
175 | * We're probably in a 64-bit syscall. | ||
176 | * Warning: this code is severely racy. At least it's better | ||
177 | * than just blindly copying user_regs. | ||
178 | */ | ||
179 | regs_user->abi = PERF_SAMPLE_REGS_ABI_64; | ||
180 | regs_user_copy->sp = this_cpu_read(old_rsp); | ||
181 | regs_user_copy->cs = __USER_CS; | ||
182 | regs_user_copy->ss = __USER_DS; | ||
183 | regs_user_copy->cx = -1; /* usually contains garbage */ | ||
184 | } else { | ||
185 | /* We're probably in an interrupt or exception. */ | ||
186 | regs_user->abi = user_64bit_mode(user_regs) ? | ||
187 | PERF_SAMPLE_REGS_ABI_64 : PERF_SAMPLE_REGS_ABI_32; | ||
188 | regs_user_copy->sp = user_regs->sp; | ||
189 | regs_user_copy->cs = user_regs->cs; | ||
190 | regs_user_copy->ss = user_regs->ss; | ||
191 | } | ||
192 | |||
193 | regs_user->regs = regs_user_copy; | ||
194 | } | ||
105 | #endif /* CONFIG_X86_32 */ | 195 | #endif /* CONFIG_X86_32 */ |
diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c index 4e942f31b1a7..7fc5e843f247 100644 --- a/arch/x86/kernel/tls.c +++ b/arch/x86/kernel/tls.c | |||
@@ -29,7 +29,28 @@ static int get_free_idx(void) | |||
29 | 29 | ||
30 | static bool tls_desc_okay(const struct user_desc *info) | 30 | static bool tls_desc_okay(const struct user_desc *info) |
31 | { | 31 | { |
32 | if (LDT_empty(info)) | 32 | /* |
33 | * For historical reasons (i.e. no one ever documented how any | ||
34 | * of the segmentation APIs work), user programs can and do | ||
35 | * assume that a struct user_desc that's all zeros except for | ||
36 | * entry_number means "no segment at all". This never actually | ||
37 | * worked. In fact, up to Linux 3.19, a struct user_desc like | ||
38 | * this would create a 16-bit read-write segment with base and | ||
39 | * limit both equal to zero. | ||
40 | * | ||
41 | * That was close enough to "no segment at all" until we | ||
42 | * hardened this function to disallow 16-bit TLS segments. Fix | ||
43 | * it up by interpreting these zeroed segments the way that they | ||
44 | * were almost certainly intended to be interpreted. | ||
45 | * | ||
46 | * The correct way to ask for "no segment at all" is to specify | ||
47 | * a user_desc that satisfies LDT_empty. To keep everything | ||
48 | * working, we accept both. | ||
49 | * | ||
50 | * Note that there's a similar kludge in modify_ldt -- look at | ||
51 | * the distinction between modes 1 and 0x11. | ||
52 | */ | ||
53 | if (LDT_empty(info) || LDT_zero(info)) | ||
33 | return true; | 54 | return true; |
34 | 55 | ||
35 | /* | 56 | /* |
@@ -71,7 +92,7 @@ static void set_tls_desc(struct task_struct *p, int idx, | |||
71 | cpu = get_cpu(); | 92 | cpu = get_cpu(); |
72 | 93 | ||
73 | while (n-- > 0) { | 94 | while (n-- > 0) { |
74 | if (LDT_empty(info)) | 95 | if (LDT_empty(info) || LDT_zero(info)) |
75 | desc->a = desc->b = 0; | 96 | desc->a = desc->b = 0; |
76 | else | 97 | else |
77 | fill_ldt(desc, info); | 98 | fill_ldt(desc, info); |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index b7e50bba3bbb..505449700e0c 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
@@ -617,7 +617,7 @@ static unsigned long quick_pit_calibrate(void) | |||
617 | goto success; | 617 | goto success; |
618 | } | 618 | } |
619 | } | 619 | } |
620 | pr_err("Fast TSC calibration failed\n"); | 620 | pr_info("Fast TSC calibration failed\n"); |
621 | return 0; | 621 | return 0; |
622 | 622 | ||
623 | success: | 623 | success: |
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 169b09d76ddd..de12c1d379f1 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -2348,7 +2348,7 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) | |||
2348 | * Not recognized on AMD in compat mode (but is recognized in legacy | 2348 | * Not recognized on AMD in compat mode (but is recognized in legacy |
2349 | * mode). | 2349 | * mode). |
2350 | */ | 2350 | */ |
2351 | if ((ctxt->mode == X86EMUL_MODE_PROT32) && (efer & EFER_LMA) | 2351 | if ((ctxt->mode != X86EMUL_MODE_PROT64) && (efer & EFER_LMA) |
2352 | && !vendor_intel(ctxt)) | 2352 | && !vendor_intel(ctxt)) |
2353 | return emulate_ud(ctxt); | 2353 | return emulate_ud(ctxt); |
2354 | 2354 | ||
@@ -2359,25 +2359,13 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) | |||
2359 | setup_syscalls_segments(ctxt, &cs, &ss); | 2359 | setup_syscalls_segments(ctxt, &cs, &ss); |
2360 | 2360 | ||
2361 | ops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data); | 2361 | ops->get_msr(ctxt, MSR_IA32_SYSENTER_CS, &msr_data); |
2362 | switch (ctxt->mode) { | 2362 | if ((msr_data & 0xfffc) == 0x0) |
2363 | case X86EMUL_MODE_PROT32: | 2363 | return emulate_gp(ctxt, 0); |
2364 | if ((msr_data & 0xfffc) == 0x0) | ||
2365 | return emulate_gp(ctxt, 0); | ||
2366 | break; | ||
2367 | case X86EMUL_MODE_PROT64: | ||
2368 | if (msr_data == 0x0) | ||
2369 | return emulate_gp(ctxt, 0); | ||
2370 | break; | ||
2371 | default: | ||
2372 | break; | ||
2373 | } | ||
2374 | 2364 | ||
2375 | ctxt->eflags &= ~(EFLG_VM | EFLG_IF); | 2365 | ctxt->eflags &= ~(EFLG_VM | EFLG_IF); |
2376 | cs_sel = (u16)msr_data; | 2366 | cs_sel = (u16)msr_data & ~SELECTOR_RPL_MASK; |
2377 | cs_sel &= ~SELECTOR_RPL_MASK; | ||
2378 | ss_sel = cs_sel + 8; | 2367 | ss_sel = cs_sel + 8; |
2379 | ss_sel &= ~SELECTOR_RPL_MASK; | 2368 | if (efer & EFER_LMA) { |
2380 | if (ctxt->mode == X86EMUL_MODE_PROT64 || (efer & EFER_LMA)) { | ||
2381 | cs.d = 0; | 2369 | cs.d = 0; |
2382 | cs.l = 1; | 2370 | cs.l = 1; |
2383 | } | 2371 | } |
@@ -2386,10 +2374,11 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) | |||
2386 | ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); | 2374 | ops->set_segment(ctxt, ss_sel, &ss, 0, VCPU_SREG_SS); |
2387 | 2375 | ||
2388 | ops->get_msr(ctxt, MSR_IA32_SYSENTER_EIP, &msr_data); | 2376 | ops->get_msr(ctxt, MSR_IA32_SYSENTER_EIP, &msr_data); |
2389 | ctxt->_eip = msr_data; | 2377 | ctxt->_eip = (efer & EFER_LMA) ? msr_data : (u32)msr_data; |
2390 | 2378 | ||
2391 | ops->get_msr(ctxt, MSR_IA32_SYSENTER_ESP, &msr_data); | 2379 | ops->get_msr(ctxt, MSR_IA32_SYSENTER_ESP, &msr_data); |
2392 | *reg_write(ctxt, VCPU_REGS_RSP) = msr_data; | 2380 | *reg_write(ctxt, VCPU_REGS_RSP) = (efer & EFER_LMA) ? msr_data : |
2381 | (u32)msr_data; | ||
2393 | 2382 | ||
2394 | return X86EMUL_CONTINUE; | 2383 | return X86EMUL_CONTINUE; |
2395 | } | 2384 | } |
@@ -3791,8 +3780,8 @@ static const struct opcode group5[] = { | |||
3791 | }; | 3780 | }; |
3792 | 3781 | ||
3793 | static const struct opcode group6[] = { | 3782 | static const struct opcode group6[] = { |
3794 | DI(Prot, sldt), | 3783 | DI(Prot | DstMem, sldt), |
3795 | DI(Prot, str), | 3784 | DI(Prot | DstMem, str), |
3796 | II(Prot | Priv | SrcMem16, em_lldt, lldt), | 3785 | II(Prot | Priv | SrcMem16, em_lldt, lldt), |
3797 | II(Prot | Priv | SrcMem16, em_ltr, ltr), | 3786 | II(Prot | Priv | SrcMem16, em_ltr, ltr), |
3798 | N, N, N, N, | 3787 | N, N, N, N, |
diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c index 2480978b31cc..1313ae6b478b 100644 --- a/arch/x86/lib/insn.c +++ b/arch/x86/lib/insn.c | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | /* Verify next sizeof(t) bytes can be on the same instruction */ | 29 | /* Verify next sizeof(t) bytes can be on the same instruction */ |
30 | #define validate_next(t, insn, n) \ | 30 | #define validate_next(t, insn, n) \ |
31 | ((insn)->next_byte + sizeof(t) + n < (insn)->end_kaddr) | 31 | ((insn)->next_byte + sizeof(t) + n <= (insn)->end_kaddr) |
32 | 32 | ||
33 | #define __get_next(t, insn) \ | 33 | #define __get_next(t, insn) \ |
34 | ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) | 34 | ({ t r = *(t*)insn->next_byte; insn->next_byte += sizeof(t); r; }) |
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index a97ee0801475..079c3b6a3ff1 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
@@ -43,7 +43,7 @@ uint16_t __cachemode2pte_tbl[_PAGE_CACHE_MODE_NUM] = { | |||
43 | [_PAGE_CACHE_MODE_WT] = _PAGE_PCD, | 43 | [_PAGE_CACHE_MODE_WT] = _PAGE_PCD, |
44 | [_PAGE_CACHE_MODE_WP] = _PAGE_PCD, | 44 | [_PAGE_CACHE_MODE_WP] = _PAGE_PCD, |
45 | }; | 45 | }; |
46 | EXPORT_SYMBOL_GPL(__cachemode2pte_tbl); | 46 | EXPORT_SYMBOL(__cachemode2pte_tbl); |
47 | uint8_t __pte2cachemode_tbl[8] = { | 47 | uint8_t __pte2cachemode_tbl[8] = { |
48 | [__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB, | 48 | [__pte2cm_idx(0)] = _PAGE_CACHE_MODE_WB, |
49 | [__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC, | 49 | [__pte2cm_idx(_PAGE_PWT)] = _PAGE_CACHE_MODE_WC, |
@@ -54,7 +54,7 @@ uint8_t __pte2cachemode_tbl[8] = { | |||
54 | [__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS, | 54 | [__pte2cm_idx(_PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC_MINUS, |
55 | [__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC, | 55 | [__pte2cm_idx(_PAGE_PWT | _PAGE_PCD | _PAGE_PAT)] = _PAGE_CACHE_MODE_UC, |
56 | }; | 56 | }; |
57 | EXPORT_SYMBOL_GPL(__pte2cachemode_tbl); | 57 | EXPORT_SYMBOL(__pte2cachemode_tbl); |
58 | 58 | ||
59 | static unsigned long __initdata pgt_buf_start; | 59 | static unsigned long __initdata pgt_buf_start; |
60 | static unsigned long __initdata pgt_buf_end; | 60 | static unsigned long __initdata pgt_buf_end; |
@@ -438,20 +438,20 @@ static unsigned long __init init_range_memory_mapping( | |||
438 | static unsigned long __init get_new_step_size(unsigned long step_size) | 438 | static unsigned long __init get_new_step_size(unsigned long step_size) |
439 | { | 439 | { |
440 | /* | 440 | /* |
441 | * Explain why we shift by 5 and why we don't have to worry about | 441 | * Initial mapped size is PMD_SIZE (2M). |
442 | * 'step_size << 5' overflowing: | ||
443 | * | ||
444 | * initial mapped size is PMD_SIZE (2M). | ||
445 | * We can not set step_size to be PUD_SIZE (1G) yet. | 442 | * We can not set step_size to be PUD_SIZE (1G) yet. |
446 | * In worse case, when we cross the 1G boundary, and | 443 | * In worse case, when we cross the 1G boundary, and |
447 | * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k) | 444 | * PG_LEVEL_2M is not set, we will need 1+1+512 pages (2M + 8k) |
448 | * to map 1G range with PTE. Use 5 as shift for now. | 445 | * to map 1G range with PTE. Hence we use one less than the |
446 | * difference of page table level shifts. | ||
449 | * | 447 | * |
450 | * Don't need to worry about overflow, on 32bit, when step_size | 448 | * Don't need to worry about overflow in the top-down case, on 32bit, |
451 | * is 0, round_down() returns 0 for start, and that turns it | 449 | * when step_size is 0, round_down() returns 0 for start, and that |
452 | * into 0x100000000ULL. | 450 | * turns it into 0x100000000ULL. |
451 | * In the bottom-up case, round_up(x, 0) returns 0 though too, which | ||
452 | * needs to be taken into consideration by the code below. | ||
453 | */ | 453 | */ |
454 | return step_size << 5; | 454 | return step_size << (PMD_SHIFT - PAGE_SHIFT - 1); |
455 | } | 455 | } |
456 | 456 | ||
457 | /** | 457 | /** |
@@ -471,7 +471,6 @@ static void __init memory_map_top_down(unsigned long map_start, | |||
471 | unsigned long step_size; | 471 | unsigned long step_size; |
472 | unsigned long addr; | 472 | unsigned long addr; |
473 | unsigned long mapped_ram_size = 0; | 473 | unsigned long mapped_ram_size = 0; |
474 | unsigned long new_mapped_ram_size; | ||
475 | 474 | ||
476 | /* xen has big range in reserved near end of ram, skip it at first.*/ | 475 | /* xen has big range in reserved near end of ram, skip it at first.*/ |
477 | addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE); | 476 | addr = memblock_find_in_range(map_start, map_end, PMD_SIZE, PMD_SIZE); |
@@ -496,14 +495,12 @@ static void __init memory_map_top_down(unsigned long map_start, | |||
496 | start = map_start; | 495 | start = map_start; |
497 | } else | 496 | } else |
498 | start = map_start; | 497 | start = map_start; |
499 | new_mapped_ram_size = init_range_memory_mapping(start, | 498 | mapped_ram_size += init_range_memory_mapping(start, |
500 | last_start); | 499 | last_start); |
501 | last_start = start; | 500 | last_start = start; |
502 | min_pfn_mapped = last_start >> PAGE_SHIFT; | 501 | min_pfn_mapped = last_start >> PAGE_SHIFT; |
503 | /* only increase step_size after big range get mapped */ | 502 | if (mapped_ram_size >= step_size) |
504 | if (new_mapped_ram_size > mapped_ram_size) | ||
505 | step_size = get_new_step_size(step_size); | 503 | step_size = get_new_step_size(step_size); |
506 | mapped_ram_size += new_mapped_ram_size; | ||
507 | } | 504 | } |
508 | 505 | ||
509 | if (real_end < map_end) | 506 | if (real_end < map_end) |
@@ -524,7 +521,7 @@ static void __init memory_map_top_down(unsigned long map_start, | |||
524 | static void __init memory_map_bottom_up(unsigned long map_start, | 521 | static void __init memory_map_bottom_up(unsigned long map_start, |
525 | unsigned long map_end) | 522 | unsigned long map_end) |
526 | { | 523 | { |
527 | unsigned long next, new_mapped_ram_size, start; | 524 | unsigned long next, start; |
528 | unsigned long mapped_ram_size = 0; | 525 | unsigned long mapped_ram_size = 0; |
529 | /* step_size need to be small so pgt_buf from BRK could cover it */ | 526 | /* step_size need to be small so pgt_buf from BRK could cover it */ |
530 | unsigned long step_size = PMD_SIZE; | 527 | unsigned long step_size = PMD_SIZE; |
@@ -539,19 +536,19 @@ static void __init memory_map_bottom_up(unsigned long map_start, | |||
539 | * for page table. | 536 | * for page table. |
540 | */ | 537 | */ |
541 | while (start < map_end) { | 538 | while (start < map_end) { |
542 | if (map_end - start > step_size) { | 539 | if (step_size && map_end - start > step_size) { |
543 | next = round_up(start + 1, step_size); | 540 | next = round_up(start + 1, step_size); |
544 | if (next > map_end) | 541 | if (next > map_end) |
545 | next = map_end; | 542 | next = map_end; |
546 | } else | 543 | } else { |
547 | next = map_end; | 544 | next = map_end; |
545 | } | ||
548 | 546 | ||
549 | new_mapped_ram_size = init_range_memory_mapping(start, next); | 547 | mapped_ram_size += init_range_memory_mapping(start, next); |
550 | start = next; | 548 | start = next; |
551 | 549 | ||
552 | if (new_mapped_ram_size > mapped_ram_size) | 550 | if (mapped_ram_size >= step_size) |
553 | step_size = get_new_step_size(step_size); | 551 | step_size = get_new_step_size(step_size); |
554 | mapped_ram_size += new_mapped_ram_size; | ||
555 | } | 552 | } |
556 | } | 553 | } |
557 | 554 | ||
diff --git a/arch/x86/mm/mpx.c b/arch/x86/mm/mpx.c index 67ebf5751222..c439ec478216 100644 --- a/arch/x86/mm/mpx.c +++ b/arch/x86/mm/mpx.c | |||
@@ -349,6 +349,12 @@ static __user void *task_get_bounds_dir(struct task_struct *tsk) | |||
349 | return MPX_INVALID_BOUNDS_DIR; | 349 | return MPX_INVALID_BOUNDS_DIR; |
350 | 350 | ||
351 | /* | 351 | /* |
352 | * 32-bit binaries on 64-bit kernels are currently | ||
353 | * unsupported. | ||
354 | */ | ||
355 | if (IS_ENABLED(CONFIG_X86_64) && test_thread_flag(TIF_IA32)) | ||
356 | return MPX_INVALID_BOUNDS_DIR; | ||
357 | /* | ||
352 | * The bounds directory pointer is stored in a register | 358 | * The bounds directory pointer is stored in a register |
353 | * only accessible if we first do an xsave. | 359 | * only accessible if we first do an xsave. |
354 | */ | 360 | */ |
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c index edf299c8ff6c..7ac68698406c 100644 --- a/arch/x86/mm/pat.c +++ b/arch/x86/mm/pat.c | |||
@@ -234,8 +234,13 @@ void pat_init(void) | |||
234 | PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC); | 234 | PAT(4, WB) | PAT(5, WC) | PAT(6, UC_MINUS) | PAT(7, UC); |
235 | 235 | ||
236 | /* Boot CPU check */ | 236 | /* Boot CPU check */ |
237 | if (!boot_pat_state) | 237 | if (!boot_pat_state) { |
238 | rdmsrl(MSR_IA32_CR_PAT, boot_pat_state); | 238 | rdmsrl(MSR_IA32_CR_PAT, boot_pat_state); |
239 | if (!boot_pat_state) { | ||
240 | pat_disable("PAT read returns always zero, disabled."); | ||
241 | return; | ||
242 | } | ||
243 | } | ||
239 | 244 | ||
240 | wrmsrl(MSR_IA32_CR_PAT, pat); | 245 | wrmsrl(MSR_IA32_CR_PAT, pat); |
241 | 246 | ||
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index 9b18ef315a55..349c0d32cc0b 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -216,7 +216,7 @@ static void pcibios_allocate_bridge_resources(struct pci_dev *dev) | |||
216 | continue; | 216 | continue; |
217 | if (r->parent) /* Already allocated */ | 217 | if (r->parent) /* Already allocated */ |
218 | continue; | 218 | continue; |
219 | if (!r->start || pci_claim_resource(dev, idx) < 0) { | 219 | if (!r->start || pci_claim_bridge_resource(dev, idx) < 0) { |
220 | /* | 220 | /* |
221 | * Something is wrong with the region. | 221 | * Something is wrong with the region. |
222 | * Invalidate the resource to prevent | 222 | * Invalidate the resource to prevent |
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c index c489ef2c1a39..9098d880c476 100644 --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c | |||
@@ -458,6 +458,7 @@ int __init pci_xen_hvm_init(void) | |||
458 | * just how GSIs get registered. | 458 | * just how GSIs get registered. |
459 | */ | 459 | */ |
460 | __acpi_register_gsi = acpi_register_gsi_xen_hvm; | 460 | __acpi_register_gsi = acpi_register_gsi_xen_hvm; |
461 | __acpi_unregister_gsi = NULL; | ||
461 | #endif | 462 | #endif |
462 | 463 | ||
463 | #ifdef CONFIG_PCI_MSI | 464 | #ifdef CONFIG_PCI_MSI |
@@ -471,52 +472,6 @@ int __init pci_xen_hvm_init(void) | |||
471 | } | 472 | } |
472 | 473 | ||
473 | #ifdef CONFIG_XEN_DOM0 | 474 | #ifdef CONFIG_XEN_DOM0 |
474 | static __init void xen_setup_acpi_sci(void) | ||
475 | { | ||
476 | int rc; | ||
477 | int trigger, polarity; | ||
478 | int gsi = acpi_sci_override_gsi; | ||
479 | int irq = -1; | ||
480 | int gsi_override = -1; | ||
481 | |||
482 | if (!gsi) | ||
483 | return; | ||
484 | |||
485 | rc = acpi_get_override_irq(gsi, &trigger, &polarity); | ||
486 | if (rc) { | ||
487 | printk(KERN_WARNING "xen: acpi_get_override_irq failed for acpi" | ||
488 | " sci, rc=%d\n", rc); | ||
489 | return; | ||
490 | } | ||
491 | trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE; | ||
492 | polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH; | ||
493 | |||
494 | printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d " | ||
495 | "polarity=%d\n", gsi, trigger, polarity); | ||
496 | |||
497 | /* Before we bind the GSI to a Linux IRQ, check whether | ||
498 | * we need to override it with bus_irq (IRQ) value. Usually for | ||
499 | * IRQs below IRQ_LEGACY_IRQ this holds IRQ == GSI, as so: | ||
500 | * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 low level) | ||
501 | * but there are oddballs where the IRQ != GSI: | ||
502 | * ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 20 low level) | ||
503 | * which ends up being: gsi_to_irq[9] == 20 | ||
504 | * (which is what acpi_gsi_to_irq ends up calling when starting the | ||
505 | * the ACPI interpreter and keels over since IRQ 9 has not been | ||
506 | * setup as we had setup IRQ 20 for it). | ||
507 | */ | ||
508 | if (acpi_gsi_to_irq(gsi, &irq) == 0) { | ||
509 | /* Use the provided value if it's valid. */ | ||
510 | if (irq >= 0) | ||
511 | gsi_override = irq; | ||
512 | } | ||
513 | |||
514 | gsi = xen_register_gsi(gsi, gsi_override, trigger, polarity); | ||
515 | printk(KERN_INFO "xen: acpi sci %d\n", gsi); | ||
516 | |||
517 | return; | ||
518 | } | ||
519 | |||
520 | int __init pci_xen_initial_domain(void) | 475 | int __init pci_xen_initial_domain(void) |
521 | { | 476 | { |
522 | int irq; | 477 | int irq; |
@@ -527,8 +482,8 @@ int __init pci_xen_initial_domain(void) | |||
527 | x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs; | 482 | x86_msi.restore_msi_irqs = xen_initdom_restore_msi_irqs; |
528 | pci_msi_ignore_mask = 1; | 483 | pci_msi_ignore_mask = 1; |
529 | #endif | 484 | #endif |
530 | xen_setup_acpi_sci(); | ||
531 | __acpi_register_gsi = acpi_register_gsi_xen; | 485 | __acpi_register_gsi = acpi_register_gsi_xen; |
486 | __acpi_unregister_gsi = NULL; | ||
532 | /* Pre-allocate legacy irqs */ | 487 | /* Pre-allocate legacy irqs */ |
533 | for (irq = 0; irq < nr_legacy_irqs(); irq++) { | 488 | for (irq = 0; irq < nr_legacy_irqs(); irq++) { |
534 | int trigger, polarity; | 489 | int trigger, polarity; |
diff --git a/arch/x86/um/sys_call_table_32.c b/arch/x86/um/sys_call_table_32.c index 531d4269e2e3..bd16d6c370ec 100644 --- a/arch/x86/um/sys_call_table_32.c +++ b/arch/x86/um/sys_call_table_32.c | |||
@@ -34,7 +34,7 @@ typedef asmlinkage void (*sys_call_ptr_t)(void); | |||
34 | 34 | ||
35 | extern asmlinkage void sys_ni_syscall(void); | 35 | extern asmlinkage void sys_ni_syscall(void); |
36 | 36 | ||
37 | const sys_call_ptr_t sys_call_table[] __cacheline_aligned = { | 37 | const sys_call_ptr_t sys_call_table[] ____cacheline_aligned = { |
38 | /* | 38 | /* |
39 | * Smells like a compiler bug -- it doesn't work | 39 | * Smells like a compiler bug -- it doesn't work |
40 | * when the & below is removed. | 40 | * when the & below is removed. |
diff --git a/arch/x86/um/sys_call_table_64.c b/arch/x86/um/sys_call_table_64.c index 20c3649d0691..5cdfa9db2217 100644 --- a/arch/x86/um/sys_call_table_64.c +++ b/arch/x86/um/sys_call_table_64.c | |||
@@ -47,7 +47,7 @@ typedef void (*sys_call_ptr_t)(void); | |||
47 | 47 | ||
48 | extern void sys_ni_syscall(void); | 48 | extern void sys_ni_syscall(void); |
49 | 49 | ||
50 | const sys_call_ptr_t sys_call_table[] __cacheline_aligned = { | 50 | const sys_call_ptr_t sys_call_table[] ____cacheline_aligned = { |
51 | /* | 51 | /* |
52 | * Smells like a compiler bug -- it doesn't work | 52 | * Smells like a compiler bug -- it doesn't work |
53 | * when the & below is removed. | 53 | * when the & below is removed. |
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c index 009495b9ab4b..1c9f750c3859 100644 --- a/arch/x86/vdso/vma.c +++ b/arch/x86/vdso/vma.c | |||
@@ -41,12 +41,17 @@ void __init init_vdso_image(const struct vdso_image *image) | |||
41 | 41 | ||
42 | struct linux_binprm; | 42 | struct linux_binprm; |
43 | 43 | ||
44 | /* Put the vdso above the (randomized) stack with another randomized offset. | 44 | /* |
45 | This way there is no hole in the middle of address space. | 45 | * Put the vdso above the (randomized) stack with another randomized |
46 | To save memory make sure it is still in the same PTE as the stack top. | 46 | * offset. This way there is no hole in the middle of address space. |
47 | This doesn't give that many random bits. | 47 | * To save memory make sure it is still in the same PTE as the stack |
48 | 48 | * top. This doesn't give that many random bits. | |
49 | Only used for the 64-bit and x32 vdsos. */ | 49 | * |
50 | * Note that this algorithm is imperfect: the distribution of the vdso | ||
51 | * start address within a PMD is biased toward the end. | ||
52 | * | ||
53 | * Only used for the 64-bit and x32 vdsos. | ||
54 | */ | ||
50 | static unsigned long vdso_addr(unsigned long start, unsigned len) | 55 | static unsigned long vdso_addr(unsigned long start, unsigned len) |
51 | { | 56 | { |
52 | #ifdef CONFIG_X86_32 | 57 | #ifdef CONFIG_X86_32 |
@@ -54,22 +59,30 @@ static unsigned long vdso_addr(unsigned long start, unsigned len) | |||
54 | #else | 59 | #else |
55 | unsigned long addr, end; | 60 | unsigned long addr, end; |
56 | unsigned offset; | 61 | unsigned offset; |
57 | end = (start + PMD_SIZE - 1) & PMD_MASK; | 62 | |
63 | /* | ||
64 | * Round up the start address. It can start out unaligned as a result | ||
65 | * of stack start randomization. | ||
66 | */ | ||
67 | start = PAGE_ALIGN(start); | ||
68 | |||
69 | /* Round the lowest possible end address up to a PMD boundary. */ | ||
70 | end = (start + len + PMD_SIZE - 1) & PMD_MASK; | ||
58 | if (end >= TASK_SIZE_MAX) | 71 | if (end >= TASK_SIZE_MAX) |
59 | end = TASK_SIZE_MAX; | 72 | end = TASK_SIZE_MAX; |
60 | end -= len; | 73 | end -= len; |
61 | /* This loses some more bits than a modulo, but is cheaper */ | 74 | |
62 | offset = get_random_int() & (PTRS_PER_PTE - 1); | 75 | if (end > start) { |
63 | addr = start + (offset << PAGE_SHIFT); | 76 | offset = get_random_int() % (((end - start) >> PAGE_SHIFT) + 1); |
64 | if (addr >= end) | 77 | addr = start + (offset << PAGE_SHIFT); |
65 | addr = end; | 78 | } else { |
79 | addr = start; | ||
80 | } | ||
66 | 81 | ||
67 | /* | 82 | /* |
68 | * page-align it here so that get_unmapped_area doesn't | 83 | * Forcibly align the final address in case we have a hardware |
69 | * align it wrongfully again to the next page. addr can come in 4K | 84 | * issue that requires alignment for performance reasons. |
70 | * unaligned here as a result of stack start randomization. | ||
71 | */ | 85 | */ |
72 | addr = PAGE_ALIGN(addr); | ||
73 | addr = align_vdso_addr(addr); | 86 | addr = align_vdso_addr(addr); |
74 | 87 | ||
75 | return addr; | 88 | return addr; |
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index 6bf3a13e3e0f..78a881b7fc41 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <xen/interface/physdev.h> | 40 | #include <xen/interface/physdev.h> |
41 | #include <xen/interface/vcpu.h> | 41 | #include <xen/interface/vcpu.h> |
42 | #include <xen/interface/memory.h> | 42 | #include <xen/interface/memory.h> |
43 | #include <xen/interface/nmi.h> | ||
43 | #include <xen/interface/xen-mca.h> | 44 | #include <xen/interface/xen-mca.h> |
44 | #include <xen/features.h> | 45 | #include <xen/features.h> |
45 | #include <xen/page.h> | 46 | #include <xen/page.h> |
@@ -66,6 +67,7 @@ | |||
66 | #include <asm/reboot.h> | 67 | #include <asm/reboot.h> |
67 | #include <asm/stackprotector.h> | 68 | #include <asm/stackprotector.h> |
68 | #include <asm/hypervisor.h> | 69 | #include <asm/hypervisor.h> |
70 | #include <asm/mach_traps.h> | ||
69 | #include <asm/mwait.h> | 71 | #include <asm/mwait.h> |
70 | #include <asm/pci_x86.h> | 72 | #include <asm/pci_x86.h> |
71 | #include <asm/pat.h> | 73 | #include <asm/pat.h> |
@@ -1351,6 +1353,21 @@ static const struct machine_ops xen_machine_ops __initconst = { | |||
1351 | .emergency_restart = xen_emergency_restart, | 1353 | .emergency_restart = xen_emergency_restart, |
1352 | }; | 1354 | }; |
1353 | 1355 | ||
1356 | static unsigned char xen_get_nmi_reason(void) | ||
1357 | { | ||
1358 | unsigned char reason = 0; | ||
1359 | |||
1360 | /* Construct a value which looks like it came from port 0x61. */ | ||
1361 | if (test_bit(_XEN_NMIREASON_io_error, | ||
1362 | &HYPERVISOR_shared_info->arch.nmi_reason)) | ||
1363 | reason |= NMI_REASON_IOCHK; | ||
1364 | if (test_bit(_XEN_NMIREASON_pci_serr, | ||
1365 | &HYPERVISOR_shared_info->arch.nmi_reason)) | ||
1366 | reason |= NMI_REASON_SERR; | ||
1367 | |||
1368 | return reason; | ||
1369 | } | ||
1370 | |||
1354 | static void __init xen_boot_params_init_edd(void) | 1371 | static void __init xen_boot_params_init_edd(void) |
1355 | { | 1372 | { |
1356 | #if IS_ENABLED(CONFIG_EDD) | 1373 | #if IS_ENABLED(CONFIG_EDD) |
@@ -1535,9 +1552,12 @@ asmlinkage __visible void __init xen_start_kernel(void) | |||
1535 | pv_info = xen_info; | 1552 | pv_info = xen_info; |
1536 | pv_init_ops = xen_init_ops; | 1553 | pv_init_ops = xen_init_ops; |
1537 | pv_apic_ops = xen_apic_ops; | 1554 | pv_apic_ops = xen_apic_ops; |
1538 | if (!xen_pvh_domain()) | 1555 | if (!xen_pvh_domain()) { |
1539 | pv_cpu_ops = xen_cpu_ops; | 1556 | pv_cpu_ops = xen_cpu_ops; |
1540 | 1557 | ||
1558 | x86_platform.get_nmi_reason = xen_get_nmi_reason; | ||
1559 | } | ||
1560 | |||
1541 | if (xen_feature(XENFEAT_auto_translated_physmap)) | 1561 | if (xen_feature(XENFEAT_auto_translated_physmap)) |
1542 | x86_init.resources.memory_setup = xen_auto_xlated_memory_setup; | 1562 | x86_init.resources.memory_setup = xen_auto_xlated_memory_setup; |
1543 | else | 1563 | else |
diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c index edbc7a63fd73..70fb5075c901 100644 --- a/arch/x86/xen/p2m.c +++ b/arch/x86/xen/p2m.c | |||
@@ -167,10 +167,13 @@ static void * __ref alloc_p2m_page(void) | |||
167 | return (void *)__get_free_page(GFP_KERNEL | __GFP_REPEAT); | 167 | return (void *)__get_free_page(GFP_KERNEL | __GFP_REPEAT); |
168 | } | 168 | } |
169 | 169 | ||
170 | /* Only to be called in case of a race for a page just allocated! */ | 170 | static void __ref free_p2m_page(void *p) |
171 | static void free_p2m_page(void *p) | ||
172 | { | 171 | { |
173 | BUG_ON(!slab_is_available()); | 172 | if (unlikely(!slab_is_available())) { |
173 | free_bootmem((unsigned long)p, PAGE_SIZE); | ||
174 | return; | ||
175 | } | ||
176 | |||
174 | free_page((unsigned long)p); | 177 | free_page((unsigned long)p); |
175 | } | 178 | } |
176 | 179 | ||
@@ -375,7 +378,7 @@ static void __init xen_rebuild_p2m_list(unsigned long *p2m) | |||
375 | p2m_missing_pte : p2m_identity_pte; | 378 | p2m_missing_pte : p2m_identity_pte; |
376 | for (i = 0; i < PMDS_PER_MID_PAGE; i++) { | 379 | for (i = 0; i < PMDS_PER_MID_PAGE; i++) { |
377 | pmdp = populate_extra_pmd( | 380 | pmdp = populate_extra_pmd( |
378 | (unsigned long)(p2m + pfn + i * PTRS_PER_PTE)); | 381 | (unsigned long)(p2m + pfn) + i * PMD_SIZE); |
379 | set_pmd(pmdp, __pmd(__pa(ptep) | _KERNPG_TABLE)); | 382 | set_pmd(pmdp, __pmd(__pa(ptep) | _KERNPG_TABLE)); |
380 | } | 383 | } |
381 | } | 384 | } |
@@ -436,10 +439,9 @@ EXPORT_SYMBOL_GPL(get_phys_to_machine); | |||
436 | * a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual | 439 | * a new pmd is to replace p2m_missing_pte or p2m_identity_pte by a individual |
437 | * pmd. In case of PAE/x86-32 there are multiple pmds to allocate! | 440 | * pmd. In case of PAE/x86-32 there are multiple pmds to allocate! |
438 | */ | 441 | */ |
439 | static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg) | 442 | static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *pte_pg) |
440 | { | 443 | { |
441 | pte_t *ptechk; | 444 | pte_t *ptechk; |
442 | pte_t *pteret = ptep; | ||
443 | pte_t *pte_newpg[PMDS_PER_MID_PAGE]; | 445 | pte_t *pte_newpg[PMDS_PER_MID_PAGE]; |
444 | pmd_t *pmdp; | 446 | pmd_t *pmdp; |
445 | unsigned int level; | 447 | unsigned int level; |
@@ -473,8 +475,6 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg) | |||
473 | if (ptechk == pte_pg) { | 475 | if (ptechk == pte_pg) { |
474 | set_pmd(pmdp, | 476 | set_pmd(pmdp, |
475 | __pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE)); | 477 | __pmd(__pa(pte_newpg[i]) | _KERNPG_TABLE)); |
476 | if (vaddr == (addr & ~(PMD_SIZE - 1))) | ||
477 | pteret = pte_offset_kernel(pmdp, addr); | ||
478 | pte_newpg[i] = NULL; | 478 | pte_newpg[i] = NULL; |
479 | } | 479 | } |
480 | 480 | ||
@@ -488,7 +488,7 @@ static pte_t *alloc_p2m_pmd(unsigned long addr, pte_t *ptep, pte_t *pte_pg) | |||
488 | vaddr += PMD_SIZE; | 488 | vaddr += PMD_SIZE; |
489 | } | 489 | } |
490 | 490 | ||
491 | return pteret; | 491 | return lookup_address(addr, &level); |
492 | } | 492 | } |
493 | 493 | ||
494 | /* | 494 | /* |
@@ -517,7 +517,7 @@ static bool alloc_p2m(unsigned long pfn) | |||
517 | 517 | ||
518 | if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) { | 518 | if (pte_pg == p2m_missing_pte || pte_pg == p2m_identity_pte) { |
519 | /* PMD level is missing, allocate a new one */ | 519 | /* PMD level is missing, allocate a new one */ |
520 | ptep = alloc_p2m_pmd(addr, ptep, pte_pg); | 520 | ptep = alloc_p2m_pmd(addr, pte_pg); |
521 | if (!ptep) | 521 | if (!ptep) |
522 | return false; | 522 | return false; |
523 | } | 523 | } |
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index dfd77dec8e2b..865e56cea7a0 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
@@ -140,7 +140,7 @@ static void __init xen_del_extra_mem(u64 start, u64 size) | |||
140 | unsigned long __ref xen_chk_extra_mem(unsigned long pfn) | 140 | unsigned long __ref xen_chk_extra_mem(unsigned long pfn) |
141 | { | 141 | { |
142 | int i; | 142 | int i; |
143 | unsigned long addr = PFN_PHYS(pfn); | 143 | phys_addr_t addr = PFN_PHYS(pfn); |
144 | 144 | ||
145 | for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) { | 145 | for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) { |
146 | if (addr >= xen_extra_mem[i].start && | 146 | if (addr >= xen_extra_mem[i].start && |
@@ -160,6 +160,8 @@ void __init xen_inv_extra_mem(void) | |||
160 | int i; | 160 | int i; |
161 | 161 | ||
162 | for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) { | 162 | for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++) { |
163 | if (!xen_extra_mem[i].size) | ||
164 | continue; | ||
163 | pfn_s = PFN_DOWN(xen_extra_mem[i].start); | 165 | pfn_s = PFN_DOWN(xen_extra_mem[i].start); |
164 | pfn_e = PFN_UP(xen_extra_mem[i].start + xen_extra_mem[i].size); | 166 | pfn_e = PFN_UP(xen_extra_mem[i].start + xen_extra_mem[i].size); |
165 | for (pfn = pfn_s; pfn < pfn_e; pfn++) | 167 | for (pfn = pfn_s; pfn < pfn_e; pfn++) |
@@ -229,15 +231,14 @@ static int __init xen_free_mfn(unsigned long mfn) | |||
229 | * as a fallback if the remapping fails. | 231 | * as a fallback if the remapping fails. |
230 | */ | 232 | */ |
231 | static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn, | 233 | static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn, |
232 | unsigned long end_pfn, unsigned long nr_pages, unsigned long *identity, | 234 | unsigned long end_pfn, unsigned long nr_pages, unsigned long *released) |
233 | unsigned long *released) | ||
234 | { | 235 | { |
235 | unsigned long len = 0; | ||
236 | unsigned long pfn, end; | 236 | unsigned long pfn, end; |
237 | int ret; | 237 | int ret; |
238 | 238 | ||
239 | WARN_ON(start_pfn > end_pfn); | 239 | WARN_ON(start_pfn > end_pfn); |
240 | 240 | ||
241 | /* Release pages first. */ | ||
241 | end = min(end_pfn, nr_pages); | 242 | end = min(end_pfn, nr_pages); |
242 | for (pfn = start_pfn; pfn < end; pfn++) { | 243 | for (pfn = start_pfn; pfn < end; pfn++) { |
243 | unsigned long mfn = pfn_to_mfn(pfn); | 244 | unsigned long mfn = pfn_to_mfn(pfn); |
@@ -250,16 +251,14 @@ static void __init xen_set_identity_and_release_chunk(unsigned long start_pfn, | |||
250 | WARN(ret != 1, "Failed to release pfn %lx err=%d\n", pfn, ret); | 251 | WARN(ret != 1, "Failed to release pfn %lx err=%d\n", pfn, ret); |
251 | 252 | ||
252 | if (ret == 1) { | 253 | if (ret == 1) { |
254 | (*released)++; | ||
253 | if (!__set_phys_to_machine(pfn, INVALID_P2M_ENTRY)) | 255 | if (!__set_phys_to_machine(pfn, INVALID_P2M_ENTRY)) |
254 | break; | 256 | break; |
255 | len++; | ||
256 | } else | 257 | } else |
257 | break; | 258 | break; |
258 | } | 259 | } |
259 | 260 | ||
260 | /* Need to release pages first */ | 261 | set_phys_range_identity(start_pfn, end_pfn); |
261 | *released += len; | ||
262 | *identity += set_phys_range_identity(start_pfn, end_pfn); | ||
263 | } | 262 | } |
264 | 263 | ||
265 | /* | 264 | /* |
@@ -287,7 +286,7 @@ static void __init xen_update_mem_tables(unsigned long pfn, unsigned long mfn) | |||
287 | } | 286 | } |
288 | 287 | ||
289 | /* Update kernel mapping, but not for highmem. */ | 288 | /* Update kernel mapping, but not for highmem. */ |
290 | if ((pfn << PAGE_SHIFT) >= __pa(high_memory)) | 289 | if (pfn >= PFN_UP(__pa(high_memory - 1))) |
291 | return; | 290 | return; |
292 | 291 | ||
293 | if (HYPERVISOR_update_va_mapping((unsigned long)__va(pfn << PAGE_SHIFT), | 292 | if (HYPERVISOR_update_va_mapping((unsigned long)__va(pfn << PAGE_SHIFT), |
@@ -318,7 +317,6 @@ static void __init xen_do_set_identity_and_remap_chunk( | |||
318 | unsigned long ident_pfn_iter, remap_pfn_iter; | 317 | unsigned long ident_pfn_iter, remap_pfn_iter; |
319 | unsigned long ident_end_pfn = start_pfn + size; | 318 | unsigned long ident_end_pfn = start_pfn + size; |
320 | unsigned long left = size; | 319 | unsigned long left = size; |
321 | unsigned long ident_cnt = 0; | ||
322 | unsigned int i, chunk; | 320 | unsigned int i, chunk; |
323 | 321 | ||
324 | WARN_ON(size == 0); | 322 | WARN_ON(size == 0); |
@@ -347,8 +345,7 @@ static void __init xen_do_set_identity_and_remap_chunk( | |||
347 | xen_remap_mfn = mfn; | 345 | xen_remap_mfn = mfn; |
348 | 346 | ||
349 | /* Set identity map */ | 347 | /* Set identity map */ |
350 | ident_cnt += set_phys_range_identity(ident_pfn_iter, | 348 | set_phys_range_identity(ident_pfn_iter, ident_pfn_iter + chunk); |
351 | ident_pfn_iter + chunk); | ||
352 | 349 | ||
353 | left -= chunk; | 350 | left -= chunk; |
354 | } | 351 | } |
@@ -371,7 +368,7 @@ static void __init xen_do_set_identity_and_remap_chunk( | |||
371 | static unsigned long __init xen_set_identity_and_remap_chunk( | 368 | static unsigned long __init xen_set_identity_and_remap_chunk( |
372 | const struct e820entry *list, size_t map_size, unsigned long start_pfn, | 369 | const struct e820entry *list, size_t map_size, unsigned long start_pfn, |
373 | unsigned long end_pfn, unsigned long nr_pages, unsigned long remap_pfn, | 370 | unsigned long end_pfn, unsigned long nr_pages, unsigned long remap_pfn, |
374 | unsigned long *identity, unsigned long *released) | 371 | unsigned long *released, unsigned long *remapped) |
375 | { | 372 | { |
376 | unsigned long pfn; | 373 | unsigned long pfn; |
377 | unsigned long i = 0; | 374 | unsigned long i = 0; |
@@ -386,8 +383,7 @@ static unsigned long __init xen_set_identity_and_remap_chunk( | |||
386 | /* Do not remap pages beyond the current allocation */ | 383 | /* Do not remap pages beyond the current allocation */ |
387 | if (cur_pfn >= nr_pages) { | 384 | if (cur_pfn >= nr_pages) { |
388 | /* Identity map remaining pages */ | 385 | /* Identity map remaining pages */ |
389 | *identity += set_phys_range_identity(cur_pfn, | 386 | set_phys_range_identity(cur_pfn, cur_pfn + size); |
390 | cur_pfn + size); | ||
391 | break; | 387 | break; |
392 | } | 388 | } |
393 | if (cur_pfn + size > nr_pages) | 389 | if (cur_pfn + size > nr_pages) |
@@ -398,7 +394,7 @@ static unsigned long __init xen_set_identity_and_remap_chunk( | |||
398 | if (!remap_range_size) { | 394 | if (!remap_range_size) { |
399 | pr_warning("Unable to find available pfn range, not remapping identity pages\n"); | 395 | pr_warning("Unable to find available pfn range, not remapping identity pages\n"); |
400 | xen_set_identity_and_release_chunk(cur_pfn, | 396 | xen_set_identity_and_release_chunk(cur_pfn, |
401 | cur_pfn + left, nr_pages, identity, released); | 397 | cur_pfn + left, nr_pages, released); |
402 | break; | 398 | break; |
403 | } | 399 | } |
404 | /* Adjust size to fit in current e820 RAM region */ | 400 | /* Adjust size to fit in current e820 RAM region */ |
@@ -410,7 +406,7 @@ static unsigned long __init xen_set_identity_and_remap_chunk( | |||
410 | /* Update variables to reflect new mappings. */ | 406 | /* Update variables to reflect new mappings. */ |
411 | i += size; | 407 | i += size; |
412 | remap_pfn += size; | 408 | remap_pfn += size; |
413 | *identity += size; | 409 | *remapped += size; |
414 | } | 410 | } |
415 | 411 | ||
416 | /* | 412 | /* |
@@ -427,13 +423,13 @@ static unsigned long __init xen_set_identity_and_remap_chunk( | |||
427 | 423 | ||
428 | static void __init xen_set_identity_and_remap( | 424 | static void __init xen_set_identity_and_remap( |
429 | const struct e820entry *list, size_t map_size, unsigned long nr_pages, | 425 | const struct e820entry *list, size_t map_size, unsigned long nr_pages, |
430 | unsigned long *released) | 426 | unsigned long *released, unsigned long *remapped) |
431 | { | 427 | { |
432 | phys_addr_t start = 0; | 428 | phys_addr_t start = 0; |
433 | unsigned long identity = 0; | ||
434 | unsigned long last_pfn = nr_pages; | 429 | unsigned long last_pfn = nr_pages; |
435 | const struct e820entry *entry; | 430 | const struct e820entry *entry; |
436 | unsigned long num_released = 0; | 431 | unsigned long num_released = 0; |
432 | unsigned long num_remapped = 0; | ||
437 | int i; | 433 | int i; |
438 | 434 | ||
439 | /* | 435 | /* |
@@ -460,14 +456,14 @@ static void __init xen_set_identity_and_remap( | |||
460 | last_pfn = xen_set_identity_and_remap_chunk( | 456 | last_pfn = xen_set_identity_and_remap_chunk( |
461 | list, map_size, start_pfn, | 457 | list, map_size, start_pfn, |
462 | end_pfn, nr_pages, last_pfn, | 458 | end_pfn, nr_pages, last_pfn, |
463 | &identity, &num_released); | 459 | &num_released, &num_remapped); |
464 | start = end; | 460 | start = end; |
465 | } | 461 | } |
466 | } | 462 | } |
467 | 463 | ||
468 | *released = num_released; | 464 | *released = num_released; |
465 | *remapped = num_remapped; | ||
469 | 466 | ||
470 | pr_info("Set %ld page(s) to 1-1 mapping\n", identity); | ||
471 | pr_info("Released %ld page(s)\n", num_released); | 467 | pr_info("Released %ld page(s)\n", num_released); |
472 | } | 468 | } |
473 | 469 | ||
@@ -586,6 +582,7 @@ char * __init xen_memory_setup(void) | |||
586 | struct xen_memory_map memmap; | 582 | struct xen_memory_map memmap; |
587 | unsigned long max_pages; | 583 | unsigned long max_pages; |
588 | unsigned long extra_pages = 0; | 584 | unsigned long extra_pages = 0; |
585 | unsigned long remapped_pages; | ||
589 | int i; | 586 | int i; |
590 | int op; | 587 | int op; |
591 | 588 | ||
@@ -635,9 +632,10 @@ char * __init xen_memory_setup(void) | |||
635 | * underlying RAM. | 632 | * underlying RAM. |
636 | */ | 633 | */ |
637 | xen_set_identity_and_remap(map, memmap.nr_entries, max_pfn, | 634 | xen_set_identity_and_remap(map, memmap.nr_entries, max_pfn, |
638 | &xen_released_pages); | 635 | &xen_released_pages, &remapped_pages); |
639 | 636 | ||
640 | extra_pages += xen_released_pages; | 637 | extra_pages += xen_released_pages; |
638 | extra_pages += remapped_pages; | ||
641 | 639 | ||
642 | /* | 640 | /* |
643 | * Clamp the amount of extra memory to a EXTRA_MEM_RATIO | 641 | * Clamp the amount of extra memory to a EXTRA_MEM_RATIO |
diff --git a/arch/x86/xen/time.c b/arch/x86/xen/time.c index f473d268d387..69087341d9ae 100644 --- a/arch/x86/xen/time.c +++ b/arch/x86/xen/time.c | |||
@@ -391,7 +391,7 @@ static const struct clock_event_device *xen_clockevent = | |||
391 | 391 | ||
392 | struct xen_clock_event_device { | 392 | struct xen_clock_event_device { |
393 | struct clock_event_device evt; | 393 | struct clock_event_device evt; |
394 | char *name; | 394 | char name[16]; |
395 | }; | 395 | }; |
396 | static DEFINE_PER_CPU(struct xen_clock_event_device, xen_clock_events) = { .evt.irq = -1 }; | 396 | static DEFINE_PER_CPU(struct xen_clock_event_device, xen_clock_events) = { .evt.irq = -1 }; |
397 | 397 | ||
@@ -420,46 +420,38 @@ void xen_teardown_timer(int cpu) | |||
420 | if (evt->irq >= 0) { | 420 | if (evt->irq >= 0) { |
421 | unbind_from_irqhandler(evt->irq, NULL); | 421 | unbind_from_irqhandler(evt->irq, NULL); |
422 | evt->irq = -1; | 422 | evt->irq = -1; |
423 | kfree(per_cpu(xen_clock_events, cpu).name); | ||
424 | per_cpu(xen_clock_events, cpu).name = NULL; | ||
425 | } | 423 | } |
426 | } | 424 | } |
427 | 425 | ||
428 | void xen_setup_timer(int cpu) | 426 | void xen_setup_timer(int cpu) |
429 | { | 427 | { |
430 | char *name; | 428 | struct xen_clock_event_device *xevt = &per_cpu(xen_clock_events, cpu); |
431 | struct clock_event_device *evt; | 429 | struct clock_event_device *evt = &xevt->evt; |
432 | int irq; | 430 | int irq; |
433 | 431 | ||
434 | evt = &per_cpu(xen_clock_events, cpu).evt; | ||
435 | WARN(evt->irq >= 0, "IRQ%d for CPU%d is already allocated\n", evt->irq, cpu); | 432 | WARN(evt->irq >= 0, "IRQ%d for CPU%d is already allocated\n", evt->irq, cpu); |
436 | if (evt->irq >= 0) | 433 | if (evt->irq >= 0) |
437 | xen_teardown_timer(cpu); | 434 | xen_teardown_timer(cpu); |
438 | 435 | ||
439 | printk(KERN_INFO "installing Xen timer for CPU %d\n", cpu); | 436 | printk(KERN_INFO "installing Xen timer for CPU %d\n", cpu); |
440 | 437 | ||
441 | name = kasprintf(GFP_KERNEL, "timer%d", cpu); | 438 | snprintf(xevt->name, sizeof(xevt->name), "timer%d", cpu); |
442 | if (!name) | ||
443 | name = "<timer kasprintf failed>"; | ||
444 | 439 | ||
445 | irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt, | 440 | irq = bind_virq_to_irqhandler(VIRQ_TIMER, cpu, xen_timer_interrupt, |
446 | IRQF_PERCPU|IRQF_NOBALANCING|IRQF_TIMER| | 441 | IRQF_PERCPU|IRQF_NOBALANCING|IRQF_TIMER| |
447 | IRQF_FORCE_RESUME|IRQF_EARLY_RESUME, | 442 | IRQF_FORCE_RESUME|IRQF_EARLY_RESUME, |
448 | name, NULL); | 443 | xevt->name, NULL); |
449 | (void)xen_set_irq_priority(irq, XEN_IRQ_PRIORITY_MAX); | 444 | (void)xen_set_irq_priority(irq, XEN_IRQ_PRIORITY_MAX); |
450 | 445 | ||
451 | memcpy(evt, xen_clockevent, sizeof(*evt)); | 446 | memcpy(evt, xen_clockevent, sizeof(*evt)); |
452 | 447 | ||
453 | evt->cpumask = cpumask_of(cpu); | 448 | evt->cpumask = cpumask_of(cpu); |
454 | evt->irq = irq; | 449 | evt->irq = irq; |
455 | per_cpu(xen_clock_events, cpu).name = name; | ||
456 | } | 450 | } |
457 | 451 | ||
458 | 452 | ||
459 | void xen_setup_cpu_clockevents(void) | 453 | void xen_setup_cpu_clockevents(void) |
460 | { | 454 | { |
461 | BUG_ON(preemptible()); | ||
462 | |||
463 | clockevents_register_device(this_cpu_ptr(&xen_clock_events.evt)); | 455 | clockevents_register_device(this_cpu_ptr(&xen_clock_events.evt)); |
464 | } | 456 | } |
465 | 457 | ||