diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-12-15 15:14:33 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-12-15 15:14:33 -0500 |
commit | e53000b1ed936e5fe898161918962382b4c7af9b (patch) | |
tree | ea14dbcc15d3e05d9b9310501dd9a55a6f731320 | |
parent | 1f76a75561a006fc03559f665c835e0e69c9014d (diff) | |
parent | 215eada73e77ede7e15531d99f712481ddd429be (diff) |
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar:
"Misc fixes:
- fix the s2ram regression related to confusion around segment
register restoration, plus related cleanups that make the code more
robust
- a guess-unwinder Kconfig dependency fix
- an isoimage build target fix for certain tool chain combinations
- instruction decoder opcode map fixes+updates, and the syncing of
the kernel decoder headers to the objtool headers
- a kmmio tracing fix
- two 5-level paging related fixes
- a topology enumeration fix on certain SMP systems"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
objtool: Resync objtool's instruction decoder source code copy with the kernel's latest version
x86/decoder: Fix and update the opcodes map
x86/power: Make restore_processor_context() sane
x86/power/32: Move SYSENTER MSR restoration to fix_processor_context()
x86/power/64: Use struct desc_ptr for the IDT in struct saved_context
x86/unwinder/guess: Prevent using CONFIG_UNWINDER_GUESS=y with CONFIG_STACKDEPOT=y
x86/build: Don't verify mtools configuration file for isoimage
x86/mm/kmmio: Fix mmiotrace for page unaligned addresses
x86/boot/compressed/64: Print error if 5-level paging is not supported
x86/boot/compressed/64: Detect and handle 5-level paging at boot-time
x86/smpboot: Do not use smp_num_siblings in __max_logical_packages calculation
-rw-r--r-- | arch/x86/Kconfig.debug | 1 | ||||
-rw-r--r-- | arch/x86/boot/compressed/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/boot/compressed/head_64.S | 16 | ||||
-rw-r--r-- | arch/x86/boot/compressed/misc.c | 16 | ||||
-rw-r--r-- | arch/x86/boot/compressed/pgtable_64.c | 28 | ||||
-rw-r--r-- | arch/x86/boot/genimage.sh | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/suspend_32.h | 8 | ||||
-rw-r--r-- | arch/x86/include/asm/suspend_64.h | 19 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 4 | ||||
-rw-r--r-- | arch/x86/lib/x86-opcode-map.txt | 13 | ||||
-rw-r--r-- | arch/x86/mm/ioremap.c | 4 | ||||
-rw-r--r-- | arch/x86/mm/kmmio.c | 12 | ||||
-rw-r--r-- | arch/x86/power/cpu.c | 99 | ||||
-rw-r--r-- | tools/objtool/arch/x86/lib/x86-opcode-map.txt | 15 | ||||
-rw-r--r-- | tools/perf/util/intel-pt-decoder/x86-opcode-map.txt | 13 |
15 files changed, 173 insertions, 80 deletions
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug index 6293a8768a91..672441c008c7 100644 --- a/arch/x86/Kconfig.debug +++ b/arch/x86/Kconfig.debug | |||
@@ -400,6 +400,7 @@ config UNWINDER_FRAME_POINTER | |||
400 | config UNWINDER_GUESS | 400 | config UNWINDER_GUESS |
401 | bool "Guess unwinder" | 401 | bool "Guess unwinder" |
402 | depends on EXPERT | 402 | depends on EXPERT |
403 | depends on !STACKDEPOT | ||
403 | ---help--- | 404 | ---help--- |
404 | This option enables the "guess" unwinder for unwinding kernel stack | 405 | This option enables the "guess" unwinder for unwinding kernel stack |
405 | traces. It scans the stack and reports every kernel text address it | 406 | traces. It scans the stack and reports every kernel text address it |
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index 1e9c322e973a..f25e1530e064 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile | |||
@@ -80,6 +80,7 @@ vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/kaslr.o | |||
80 | ifdef CONFIG_X86_64 | 80 | ifdef CONFIG_X86_64 |
81 | vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/pagetable.o | 81 | vmlinux-objs-$(CONFIG_RANDOMIZE_BASE) += $(obj)/pagetable.o |
82 | vmlinux-objs-y += $(obj)/mem_encrypt.o | 82 | vmlinux-objs-y += $(obj)/mem_encrypt.o |
83 | vmlinux-objs-y += $(obj)/pgtable_64.o | ||
83 | endif | 84 | endif |
84 | 85 | ||
85 | $(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone | 86 | $(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone |
diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S index 20919b4f3133..fc313e29fe2c 100644 --- a/arch/x86/boot/compressed/head_64.S +++ b/arch/x86/boot/compressed/head_64.S | |||
@@ -305,10 +305,18 @@ ENTRY(startup_64) | |||
305 | leaq boot_stack_end(%rbx), %rsp | 305 | leaq boot_stack_end(%rbx), %rsp |
306 | 306 | ||
307 | #ifdef CONFIG_X86_5LEVEL | 307 | #ifdef CONFIG_X86_5LEVEL |
308 | /* Check if 5-level paging has already enabled */ | 308 | /* |
309 | movq %cr4, %rax | 309 | * Check if we need to enable 5-level paging. |
310 | testl $X86_CR4_LA57, %eax | 310 | * RSI holds real mode data and need to be preserved across |
311 | jnz lvl5 | 311 | * a function call. |
312 | */ | ||
313 | pushq %rsi | ||
314 | call l5_paging_required | ||
315 | popq %rsi | ||
316 | |||
317 | /* If l5_paging_required() returned zero, we're done here. */ | ||
318 | cmpq $0, %rax | ||
319 | je lvl5 | ||
312 | 320 | ||
313 | /* | 321 | /* |
314 | * At this point we are in long mode with 4-level paging enabled, | 322 | * At this point we are in long mode with 4-level paging enabled, |
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index b50c42455e25..98761a1576ce 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c | |||
@@ -169,6 +169,16 @@ void __puthex(unsigned long value) | |||
169 | } | 169 | } |
170 | } | 170 | } |
171 | 171 | ||
172 | static bool l5_supported(void) | ||
173 | { | ||
174 | /* Check if leaf 7 is supported. */ | ||
175 | if (native_cpuid_eax(0) < 7) | ||
176 | return 0; | ||
177 | |||
178 | /* Check if la57 is supported. */ | ||
179 | return native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)); | ||
180 | } | ||
181 | |||
172 | #if CONFIG_X86_NEED_RELOCS | 182 | #if CONFIG_X86_NEED_RELOCS |
173 | static void handle_relocations(void *output, unsigned long output_len, | 183 | static void handle_relocations(void *output, unsigned long output_len, |
174 | unsigned long virt_addr) | 184 | unsigned long virt_addr) |
@@ -362,6 +372,12 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap, | |||
362 | console_init(); | 372 | console_init(); |
363 | debug_putstr("early console in extract_kernel\n"); | 373 | debug_putstr("early console in extract_kernel\n"); |
364 | 374 | ||
375 | if (IS_ENABLED(CONFIG_X86_5LEVEL) && !l5_supported()) { | ||
376 | error("This linux kernel as configured requires 5-level paging\n" | ||
377 | "This CPU does not support the required 'cr4.la57' feature\n" | ||
378 | "Unable to boot - please use a kernel appropriate for your CPU\n"); | ||
379 | } | ||
380 | |||
365 | free_mem_ptr = heap; /* Heap */ | 381 | free_mem_ptr = heap; /* Heap */ |
366 | free_mem_end_ptr = heap + BOOT_HEAP_SIZE; | 382 | free_mem_end_ptr = heap + BOOT_HEAP_SIZE; |
367 | 383 | ||
diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c new file mode 100644 index 000000000000..b4469a37e9a1 --- /dev/null +++ b/arch/x86/boot/compressed/pgtable_64.c | |||
@@ -0,0 +1,28 @@ | |||
1 | #include <asm/processor.h> | ||
2 | |||
3 | /* | ||
4 | * __force_order is used by special_insns.h asm code to force instruction | ||
5 | * serialization. | ||
6 | * | ||
7 | * It is not referenced from the code, but GCC < 5 with -fPIE would fail | ||
8 | * due to an undefined symbol. Define it to make these ancient GCCs work. | ||
9 | */ | ||
10 | unsigned long __force_order; | ||
11 | |||
12 | int l5_paging_required(void) | ||
13 | { | ||
14 | /* Check if leaf 7 is supported. */ | ||
15 | |||
16 | if (native_cpuid_eax(0) < 7) | ||
17 | return 0; | ||
18 | |||
19 | /* Check if la57 is supported. */ | ||
20 | if (!(native_cpuid_ecx(7) & (1 << (X86_FEATURE_LA57 & 31)))) | ||
21 | return 0; | ||
22 | |||
23 | /* Check if 5-level paging has already been enabled. */ | ||
24 | if (native_read_cr4() & X86_CR4_LA57) | ||
25 | return 0; | ||
26 | |||
27 | return 1; | ||
28 | } | ||
diff --git a/arch/x86/boot/genimage.sh b/arch/x86/boot/genimage.sh index 49f4970f693b..c9e8499fbfe7 100644 --- a/arch/x86/boot/genimage.sh +++ b/arch/x86/boot/genimage.sh | |||
@@ -44,9 +44,9 @@ FDINITRD=$6 | |||
44 | 44 | ||
45 | # Make sure the files actually exist | 45 | # Make sure the files actually exist |
46 | verify "$FBZIMAGE" | 46 | verify "$FBZIMAGE" |
47 | verify "$MTOOLSRC" | ||
48 | 47 | ||
49 | genbzdisk() { | 48 | genbzdisk() { |
49 | verify "$MTOOLSRC" | ||
50 | mformat a: | 50 | mformat a: |
51 | syslinux $FIMAGE | 51 | syslinux $FIMAGE |
52 | echo "$KCMDLINE" | mcopy - a:syslinux.cfg | 52 | echo "$KCMDLINE" | mcopy - a:syslinux.cfg |
@@ -57,6 +57,7 @@ genbzdisk() { | |||
57 | } | 57 | } |
58 | 58 | ||
59 | genfdimage144() { | 59 | genfdimage144() { |
60 | verify "$MTOOLSRC" | ||
60 | dd if=/dev/zero of=$FIMAGE bs=1024 count=1440 2> /dev/null | 61 | dd if=/dev/zero of=$FIMAGE bs=1024 count=1440 2> /dev/null |
61 | mformat v: | 62 | mformat v: |
62 | syslinux $FIMAGE | 63 | syslinux $FIMAGE |
@@ -68,6 +69,7 @@ genfdimage144() { | |||
68 | } | 69 | } |
69 | 70 | ||
70 | genfdimage288() { | 71 | genfdimage288() { |
72 | verify "$MTOOLSRC" | ||
71 | dd if=/dev/zero of=$FIMAGE bs=1024 count=2880 2> /dev/null | 73 | dd if=/dev/zero of=$FIMAGE bs=1024 count=2880 2> /dev/null |
72 | mformat w: | 74 | mformat w: |
73 | syslinux $FIMAGE | 75 | syslinux $FIMAGE |
diff --git a/arch/x86/include/asm/suspend_32.h b/arch/x86/include/asm/suspend_32.h index 982c325dad33..8be6afb58471 100644 --- a/arch/x86/include/asm/suspend_32.h +++ b/arch/x86/include/asm/suspend_32.h | |||
@@ -12,7 +12,13 @@ | |||
12 | 12 | ||
13 | /* image of the saved processor state */ | 13 | /* image of the saved processor state */ |
14 | struct saved_context { | 14 | struct saved_context { |
15 | u16 es, fs, gs, ss; | 15 | /* |
16 | * On x86_32, all segment registers, with the possible exception of | ||
17 | * gs, are saved at kernel entry in pt_regs. | ||
18 | */ | ||
19 | #ifdef CONFIG_X86_32_LAZY_GS | ||
20 | u16 gs; | ||
21 | #endif | ||
16 | unsigned long cr0, cr2, cr3, cr4; | 22 | unsigned long cr0, cr2, cr3, cr4; |
17 | u64 misc_enable; | 23 | u64 misc_enable; |
18 | bool misc_enable_saved; | 24 | bool misc_enable_saved; |
diff --git a/arch/x86/include/asm/suspend_64.h b/arch/x86/include/asm/suspend_64.h index 7306e911faee..a7af9f53c0cb 100644 --- a/arch/x86/include/asm/suspend_64.h +++ b/arch/x86/include/asm/suspend_64.h | |||
@@ -20,8 +20,20 @@ | |||
20 | */ | 20 | */ |
21 | struct saved_context { | 21 | struct saved_context { |
22 | struct pt_regs regs; | 22 | struct pt_regs regs; |
23 | u16 ds, es, fs, gs, ss; | 23 | |
24 | unsigned long gs_base, gs_kernel_base, fs_base; | 24 | /* |
25 | * User CS and SS are saved in current_pt_regs(). The rest of the | ||
26 | * segment selectors need to be saved and restored here. | ||
27 | */ | ||
28 | u16 ds, es, fs, gs; | ||
29 | |||
30 | /* | ||
31 | * Usermode FSBASE and GSBASE may not match the fs and gs selectors, | ||
32 | * so we save them separately. We save the kernelmode GSBASE to | ||
33 | * restore percpu access after resume. | ||
34 | */ | ||
35 | unsigned long kernelmode_gs_base, usermode_gs_base, fs_base; | ||
36 | |||
25 | unsigned long cr0, cr2, cr3, cr4, cr8; | 37 | unsigned long cr0, cr2, cr3, cr4, cr8; |
26 | u64 misc_enable; | 38 | u64 misc_enable; |
27 | bool misc_enable_saved; | 39 | bool misc_enable_saved; |
@@ -30,8 +42,7 @@ struct saved_context { | |||
30 | u16 gdt_pad; /* Unused */ | 42 | u16 gdt_pad; /* Unused */ |
31 | struct desc_ptr gdt_desc; | 43 | struct desc_ptr gdt_desc; |
32 | u16 idt_pad; | 44 | u16 idt_pad; |
33 | u16 idt_limit; | 45 | struct desc_ptr idt; |
34 | unsigned long idt_base; | ||
35 | u16 ldt; | 46 | u16 ldt; |
36 | u16 tss; | 47 | u16 tss; |
37 | unsigned long tr; | 48 | unsigned long tr; |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 05a97d5fe298..35cb20994e32 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -106,7 +106,7 @@ EXPORT_SYMBOL(__max_logical_packages); | |||
106 | static unsigned int logical_packages __read_mostly; | 106 | static unsigned int logical_packages __read_mostly; |
107 | 107 | ||
108 | /* Maximum number of SMT threads on any online core */ | 108 | /* Maximum number of SMT threads on any online core */ |
109 | int __max_smt_threads __read_mostly; | 109 | int __read_mostly __max_smt_threads = 1; |
110 | 110 | ||
111 | /* Flag to indicate if a complete sched domain rebuild is required */ | 111 | /* Flag to indicate if a complete sched domain rebuild is required */ |
112 | bool x86_topology_update; | 112 | bool x86_topology_update; |
@@ -1304,7 +1304,7 @@ void __init native_smp_cpus_done(unsigned int max_cpus) | |||
1304 | * Today neither Intel nor AMD support heterogenous systems so | 1304 | * Today neither Intel nor AMD support heterogenous systems so |
1305 | * extrapolate the boot cpu's data to all packages. | 1305 | * extrapolate the boot cpu's data to all packages. |
1306 | */ | 1306 | */ |
1307 | ncpus = cpu_data(0).booted_cores * smp_num_siblings; | 1307 | ncpus = cpu_data(0).booted_cores * topology_max_smt_threads(); |
1308 | __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); | 1308 | __max_logical_packages = DIV_ROUND_UP(nr_cpu_ids, ncpus); |
1309 | pr_info("Max logical packages: %u\n", __max_logical_packages); | 1309 | pr_info("Max logical packages: %u\n", __max_logical_packages); |
1310 | 1310 | ||
diff --git a/arch/x86/lib/x86-opcode-map.txt b/arch/x86/lib/x86-opcode-map.txt index c4d55919fac1..e0b85930dd77 100644 --- a/arch/x86/lib/x86-opcode-map.txt +++ b/arch/x86/lib/x86-opcode-map.txt | |||
@@ -607,7 +607,7 @@ fb: psubq Pq,Qq | vpsubq Vx,Hx,Wx (66),(v1) | |||
607 | fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) | 607 | fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) |
608 | fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) | 608 | fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) |
609 | fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) | 609 | fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) |
610 | ff: | 610 | ff: UD0 |
611 | EndTable | 611 | EndTable |
612 | 612 | ||
613 | Table: 3-byte opcode 1 (0x0f 0x38) | 613 | Table: 3-byte opcode 1 (0x0f 0x38) |
@@ -717,7 +717,7 @@ AVXcode: 2 | |||
717 | 7e: vpermt2d/q Vx,Hx,Wx (66),(ev) | 717 | 7e: vpermt2d/q Vx,Hx,Wx (66),(ev) |
718 | 7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) | 718 | 7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) |
719 | 80: INVEPT Gy,Mdq (66) | 719 | 80: INVEPT Gy,Mdq (66) |
720 | 81: INVPID Gy,Mdq (66) | 720 | 81: INVVPID Gy,Mdq (66) |
721 | 82: INVPCID Gy,Mdq (66) | 721 | 82: INVPCID Gy,Mdq (66) |
722 | 83: vpmultishiftqb Vx,Hx,Wx (66),(ev) | 722 | 83: vpmultishiftqb Vx,Hx,Wx (66),(ev) |
723 | 88: vexpandps/d Vpd,Wpd (66),(ev) | 723 | 88: vexpandps/d Vpd,Wpd (66),(ev) |
@@ -970,6 +970,15 @@ GrpTable: Grp9 | |||
970 | EndTable | 970 | EndTable |
971 | 971 | ||
972 | GrpTable: Grp10 | 972 | GrpTable: Grp10 |
973 | # all are UD1 | ||
974 | 0: UD1 | ||
975 | 1: UD1 | ||
976 | 2: UD1 | ||
977 | 3: UD1 | ||
978 | 4: UD1 | ||
979 | 5: UD1 | ||
980 | 6: UD1 | ||
981 | 7: UD1 | ||
973 | EndTable | 982 | EndTable |
974 | 983 | ||
975 | # Grp11A and Grp11B are expressed as Grp11 in Intel SDM | 984 | # Grp11A and Grp11B are expressed as Grp11 in Intel SDM |
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 6e4573b1da34..c45b6ec5357b 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c | |||
@@ -404,11 +404,11 @@ void iounmap(volatile void __iomem *addr) | |||
404 | return; | 404 | return; |
405 | } | 405 | } |
406 | 406 | ||
407 | mmiotrace_iounmap(addr); | ||
408 | |||
407 | addr = (volatile void __iomem *) | 409 | addr = (volatile void __iomem *) |
408 | (PAGE_MASK & (unsigned long __force)addr); | 410 | (PAGE_MASK & (unsigned long __force)addr); |
409 | 411 | ||
410 | mmiotrace_iounmap(addr); | ||
411 | |||
412 | /* Use the vm area unlocked, assuming the caller | 412 | /* Use the vm area unlocked, assuming the caller |
413 | ensures there isn't another iounmap for the same address | 413 | ensures there isn't another iounmap for the same address |
414 | in parallel. Reuse of the virtual address is prevented by | 414 | in parallel. Reuse of the virtual address is prevented by |
diff --git a/arch/x86/mm/kmmio.c b/arch/x86/mm/kmmio.c index c21c2ed04612..58477ec3d66d 100644 --- a/arch/x86/mm/kmmio.c +++ b/arch/x86/mm/kmmio.c | |||
@@ -435,17 +435,18 @@ int register_kmmio_probe(struct kmmio_probe *p) | |||
435 | unsigned long flags; | 435 | unsigned long flags; |
436 | int ret = 0; | 436 | int ret = 0; |
437 | unsigned long size = 0; | 437 | unsigned long size = 0; |
438 | unsigned long addr = p->addr & PAGE_MASK; | ||
438 | const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); | 439 | const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); |
439 | unsigned int l; | 440 | unsigned int l; |
440 | pte_t *pte; | 441 | pte_t *pte; |
441 | 442 | ||
442 | spin_lock_irqsave(&kmmio_lock, flags); | 443 | spin_lock_irqsave(&kmmio_lock, flags); |
443 | if (get_kmmio_probe(p->addr)) { | 444 | if (get_kmmio_probe(addr)) { |
444 | ret = -EEXIST; | 445 | ret = -EEXIST; |
445 | goto out; | 446 | goto out; |
446 | } | 447 | } |
447 | 448 | ||
448 | pte = lookup_address(p->addr, &l); | 449 | pte = lookup_address(addr, &l); |
449 | if (!pte) { | 450 | if (!pte) { |
450 | ret = -EINVAL; | 451 | ret = -EINVAL; |
451 | goto out; | 452 | goto out; |
@@ -454,7 +455,7 @@ int register_kmmio_probe(struct kmmio_probe *p) | |||
454 | kmmio_count++; | 455 | kmmio_count++; |
455 | list_add_rcu(&p->list, &kmmio_probes); | 456 | list_add_rcu(&p->list, &kmmio_probes); |
456 | while (size < size_lim) { | 457 | while (size < size_lim) { |
457 | if (add_kmmio_fault_page(p->addr + size)) | 458 | if (add_kmmio_fault_page(addr + size)) |
458 | pr_err("Unable to set page fault.\n"); | 459 | pr_err("Unable to set page fault.\n"); |
459 | size += page_level_size(l); | 460 | size += page_level_size(l); |
460 | } | 461 | } |
@@ -528,19 +529,20 @@ void unregister_kmmio_probe(struct kmmio_probe *p) | |||
528 | { | 529 | { |
529 | unsigned long flags; | 530 | unsigned long flags; |
530 | unsigned long size = 0; | 531 | unsigned long size = 0; |
532 | unsigned long addr = p->addr & PAGE_MASK; | ||
531 | const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); | 533 | const unsigned long size_lim = p->len + (p->addr & ~PAGE_MASK); |
532 | struct kmmio_fault_page *release_list = NULL; | 534 | struct kmmio_fault_page *release_list = NULL; |
533 | struct kmmio_delayed_release *drelease; | 535 | struct kmmio_delayed_release *drelease; |
534 | unsigned int l; | 536 | unsigned int l; |
535 | pte_t *pte; | 537 | pte_t *pte; |
536 | 538 | ||
537 | pte = lookup_address(p->addr, &l); | 539 | pte = lookup_address(addr, &l); |
538 | if (!pte) | 540 | if (!pte) |
539 | return; | 541 | return; |
540 | 542 | ||
541 | spin_lock_irqsave(&kmmio_lock, flags); | 543 | spin_lock_irqsave(&kmmio_lock, flags); |
542 | while (size < size_lim) { | 544 | while (size < size_lim) { |
543 | release_kmmio_fault_page(p->addr + size, &release_list); | 545 | release_kmmio_fault_page(addr + size, &release_list); |
544 | size += page_level_size(l); | 546 | size += page_level_size(l); |
545 | } | 547 | } |
546 | list_del_rcu(&p->list); | 548 | list_del_rcu(&p->list); |
diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c index 5191de14f4df..36a28eddb435 100644 --- a/arch/x86/power/cpu.c +++ b/arch/x86/power/cpu.c | |||
@@ -82,12 +82,8 @@ static void __save_processor_state(struct saved_context *ctxt) | |||
82 | /* | 82 | /* |
83 | * descriptor tables | 83 | * descriptor tables |
84 | */ | 84 | */ |
85 | #ifdef CONFIG_X86_32 | ||
86 | store_idt(&ctxt->idt); | 85 | store_idt(&ctxt->idt); |
87 | #else | 86 | |
88 | /* CONFIG_X86_64 */ | ||
89 | store_idt((struct desc_ptr *)&ctxt->idt_limit); | ||
90 | #endif | ||
91 | /* | 87 | /* |
92 | * We save it here, but restore it only in the hibernate case. | 88 | * We save it here, but restore it only in the hibernate case. |
93 | * For ACPI S3 resume, this is loaded via 'early_gdt_desc' in 64-bit | 89 | * For ACPI S3 resume, this is loaded via 'early_gdt_desc' in 64-bit |
@@ -103,22 +99,18 @@ static void __save_processor_state(struct saved_context *ctxt) | |||
103 | /* | 99 | /* |
104 | * segment registers | 100 | * segment registers |
105 | */ | 101 | */ |
106 | #ifdef CONFIG_X86_32 | 102 | #ifdef CONFIG_X86_32_LAZY_GS |
107 | savesegment(es, ctxt->es); | ||
108 | savesegment(fs, ctxt->fs); | ||
109 | savesegment(gs, ctxt->gs); | 103 | savesegment(gs, ctxt->gs); |
110 | savesegment(ss, ctxt->ss); | 104 | #endif |
111 | #else | 105 | #ifdef CONFIG_X86_64 |
112 | /* CONFIG_X86_64 */ | 106 | savesegment(gs, ctxt->gs); |
113 | asm volatile ("movw %%ds, %0" : "=m" (ctxt->ds)); | 107 | savesegment(fs, ctxt->fs); |
114 | asm volatile ("movw %%es, %0" : "=m" (ctxt->es)); | 108 | savesegment(ds, ctxt->ds); |
115 | asm volatile ("movw %%fs, %0" : "=m" (ctxt->fs)); | 109 | savesegment(es, ctxt->es); |
116 | asm volatile ("movw %%gs, %0" : "=m" (ctxt->gs)); | ||
117 | asm volatile ("movw %%ss, %0" : "=m" (ctxt->ss)); | ||
118 | 110 | ||
119 | rdmsrl(MSR_FS_BASE, ctxt->fs_base); | 111 | rdmsrl(MSR_FS_BASE, ctxt->fs_base); |
120 | rdmsrl(MSR_GS_BASE, ctxt->gs_base); | 112 | rdmsrl(MSR_GS_BASE, ctxt->kernelmode_gs_base); |
121 | rdmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); | 113 | rdmsrl(MSR_KERNEL_GS_BASE, ctxt->usermode_gs_base); |
122 | mtrr_save_fixed_ranges(NULL); | 114 | mtrr_save_fixed_ranges(NULL); |
123 | 115 | ||
124 | rdmsrl(MSR_EFER, ctxt->efer); | 116 | rdmsrl(MSR_EFER, ctxt->efer); |
@@ -178,6 +170,9 @@ static void fix_processor_context(void) | |||
178 | write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS); | 170 | write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS); |
179 | 171 | ||
180 | syscall_init(); /* This sets MSR_*STAR and related */ | 172 | syscall_init(); /* This sets MSR_*STAR and related */ |
173 | #else | ||
174 | if (boot_cpu_has(X86_FEATURE_SEP)) | ||
175 | enable_sep_cpu(); | ||
181 | #endif | 176 | #endif |
182 | load_TR_desc(); /* This does ltr */ | 177 | load_TR_desc(); /* This does ltr */ |
183 | load_mm_ldt(current->active_mm); /* This does lldt */ | 178 | load_mm_ldt(current->active_mm); /* This does lldt */ |
@@ -190,9 +185,12 @@ static void fix_processor_context(void) | |||
190 | } | 185 | } |
191 | 186 | ||
192 | /** | 187 | /** |
193 | * __restore_processor_state - restore the contents of CPU registers saved | 188 | * __restore_processor_state - restore the contents of CPU registers saved |
194 | * by __save_processor_state() | 189 | * by __save_processor_state() |
195 | * @ctxt - structure to load the registers contents from | 190 | * @ctxt - structure to load the registers contents from |
191 | * | ||
192 | * The asm code that gets us here will have restored a usable GDT, although | ||
193 | * it will be pointing to the wrong alias. | ||
196 | */ | 194 | */ |
197 | static void notrace __restore_processor_state(struct saved_context *ctxt) | 195 | static void notrace __restore_processor_state(struct saved_context *ctxt) |
198 | { | 196 | { |
@@ -215,57 +213,50 @@ static void notrace __restore_processor_state(struct saved_context *ctxt) | |||
215 | write_cr2(ctxt->cr2); | 213 | write_cr2(ctxt->cr2); |
216 | write_cr0(ctxt->cr0); | 214 | write_cr0(ctxt->cr0); |
217 | 215 | ||
216 | /* Restore the IDT. */ | ||
217 | load_idt(&ctxt->idt); | ||
218 | |||
218 | /* | 219 | /* |
219 | * now restore the descriptor tables to their proper values | 220 | * Just in case the asm code got us here with the SS, DS, or ES |
220 | * ltr is done i fix_processor_context(). | 221 | * out of sync with the GDT, update them. |
221 | */ | 222 | */ |
222 | #ifdef CONFIG_X86_32 | 223 | loadsegment(ss, __KERNEL_DS); |
223 | load_idt(&ctxt->idt); | 224 | loadsegment(ds, __USER_DS); |
224 | #else | 225 | loadsegment(es, __USER_DS); |
225 | /* CONFIG_X86_64 */ | ||
226 | load_idt((const struct desc_ptr *)&ctxt->idt_limit); | ||
227 | #endif | ||
228 | 226 | ||
229 | #ifdef CONFIG_X86_64 | ||
230 | /* | 227 | /* |
231 | * We need GSBASE restored before percpu access can work. | 228 | * Restore percpu access. Percpu access can happen in exception |
232 | * percpu access can happen in exception handlers or in complicated | 229 | * handlers or in complicated helpers like load_gs_index(). |
233 | * helpers like load_gs_index(). | ||
234 | */ | 230 | */ |
235 | wrmsrl(MSR_GS_BASE, ctxt->gs_base); | 231 | #ifdef CONFIG_X86_64 |
232 | wrmsrl(MSR_GS_BASE, ctxt->kernelmode_gs_base); | ||
233 | #else | ||
234 | loadsegment(fs, __KERNEL_PERCPU); | ||
235 | loadsegment(gs, __KERNEL_STACK_CANARY); | ||
236 | #endif | 236 | #endif |
237 | 237 | ||
238 | /* Restore the TSS, RO GDT, LDT, and usermode-relevant MSRs. */ | ||
238 | fix_processor_context(); | 239 | fix_processor_context(); |
239 | 240 | ||
240 | /* | 241 | /* |
241 | * Restore segment registers. This happens after restoring the GDT | 242 | * Now that we have descriptor tables fully restored and working |
242 | * and LDT, which happen in fix_processor_context(). | 243 | * exception handling, restore the usermode segments. |
243 | */ | 244 | */ |
244 | #ifdef CONFIG_X86_32 | 245 | #ifdef CONFIG_X86_64 |
246 | loadsegment(ds, ctxt->es); | ||
245 | loadsegment(es, ctxt->es); | 247 | loadsegment(es, ctxt->es); |
246 | loadsegment(fs, ctxt->fs); | 248 | loadsegment(fs, ctxt->fs); |
247 | loadsegment(gs, ctxt->gs); | ||
248 | loadsegment(ss, ctxt->ss); | ||
249 | |||
250 | /* | ||
251 | * sysenter MSRs | ||
252 | */ | ||
253 | if (boot_cpu_has(X86_FEATURE_SEP)) | ||
254 | enable_sep_cpu(); | ||
255 | #else | ||
256 | /* CONFIG_X86_64 */ | ||
257 | asm volatile ("movw %0, %%ds" :: "r" (ctxt->ds)); | ||
258 | asm volatile ("movw %0, %%es" :: "r" (ctxt->es)); | ||
259 | asm volatile ("movw %0, %%fs" :: "r" (ctxt->fs)); | ||
260 | load_gs_index(ctxt->gs); | 249 | load_gs_index(ctxt->gs); |
261 | asm volatile ("movw %0, %%ss" :: "r" (ctxt->ss)); | ||
262 | 250 | ||
263 | /* | 251 | /* |
264 | * Restore FSBASE and user GSBASE after reloading the respective | 252 | * Restore FSBASE and GSBASE after restoring the selectors, since |
265 | * segment selectors. | 253 | * restoring the selectors clobbers the bases. Keep in mind |
254 | * that MSR_KERNEL_GS_BASE is horribly misnamed. | ||
266 | */ | 255 | */ |
267 | wrmsrl(MSR_FS_BASE, ctxt->fs_base); | 256 | wrmsrl(MSR_FS_BASE, ctxt->fs_base); |
268 | wrmsrl(MSR_KERNEL_GS_BASE, ctxt->gs_kernel_base); | 257 | wrmsrl(MSR_KERNEL_GS_BASE, ctxt->usermode_gs_base); |
258 | #elif defined(CONFIG_X86_32_LAZY_GS) | ||
259 | loadsegment(gs, ctxt->gs); | ||
269 | #endif | 260 | #endif |
270 | 261 | ||
271 | do_fpu_end(); | 262 | do_fpu_end(); |
diff --git a/tools/objtool/arch/x86/lib/x86-opcode-map.txt b/tools/objtool/arch/x86/lib/x86-opcode-map.txt index 12e377184ee4..e0b85930dd77 100644 --- a/tools/objtool/arch/x86/lib/x86-opcode-map.txt +++ b/tools/objtool/arch/x86/lib/x86-opcode-map.txt | |||
@@ -607,7 +607,7 @@ fb: psubq Pq,Qq | vpsubq Vx,Hx,Wx (66),(v1) | |||
607 | fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) | 607 | fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) |
608 | fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) | 608 | fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) |
609 | fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) | 609 | fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) |
610 | ff: | 610 | ff: UD0 |
611 | EndTable | 611 | EndTable |
612 | 612 | ||
613 | Table: 3-byte opcode 1 (0x0f 0x38) | 613 | Table: 3-byte opcode 1 (0x0f 0x38) |
@@ -717,7 +717,7 @@ AVXcode: 2 | |||
717 | 7e: vpermt2d/q Vx,Hx,Wx (66),(ev) | 717 | 7e: vpermt2d/q Vx,Hx,Wx (66),(ev) |
718 | 7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) | 718 | 7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) |
719 | 80: INVEPT Gy,Mdq (66) | 719 | 80: INVEPT Gy,Mdq (66) |
720 | 81: INVPID Gy,Mdq (66) | 720 | 81: INVVPID Gy,Mdq (66) |
721 | 82: INVPCID Gy,Mdq (66) | 721 | 82: INVPCID Gy,Mdq (66) |
722 | 83: vpmultishiftqb Vx,Hx,Wx (66),(ev) | 722 | 83: vpmultishiftqb Vx,Hx,Wx (66),(ev) |
723 | 88: vexpandps/d Vpd,Wpd (66),(ev) | 723 | 88: vexpandps/d Vpd,Wpd (66),(ev) |
@@ -896,7 +896,7 @@ EndTable | |||
896 | 896 | ||
897 | GrpTable: Grp3_1 | 897 | GrpTable: Grp3_1 |
898 | 0: TEST Eb,Ib | 898 | 0: TEST Eb,Ib |
899 | 1: | 899 | 1: TEST Eb,Ib |
900 | 2: NOT Eb | 900 | 2: NOT Eb |
901 | 3: NEG Eb | 901 | 3: NEG Eb |
902 | 4: MUL AL,Eb | 902 | 4: MUL AL,Eb |
@@ -970,6 +970,15 @@ GrpTable: Grp9 | |||
970 | EndTable | 970 | EndTable |
971 | 971 | ||
972 | GrpTable: Grp10 | 972 | GrpTable: Grp10 |
973 | # all are UD1 | ||
974 | 0: UD1 | ||
975 | 1: UD1 | ||
976 | 2: UD1 | ||
977 | 3: UD1 | ||
978 | 4: UD1 | ||
979 | 5: UD1 | ||
980 | 6: UD1 | ||
981 | 7: UD1 | ||
973 | EndTable | 982 | EndTable |
974 | 983 | ||
975 | # Grp11A and Grp11B are expressed as Grp11 in Intel SDM | 984 | # Grp11A and Grp11B are expressed as Grp11 in Intel SDM |
diff --git a/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt b/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt index c4d55919fac1..e0b85930dd77 100644 --- a/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt +++ b/tools/perf/util/intel-pt-decoder/x86-opcode-map.txt | |||
@@ -607,7 +607,7 @@ fb: psubq Pq,Qq | vpsubq Vx,Hx,Wx (66),(v1) | |||
607 | fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) | 607 | fc: paddb Pq,Qq | vpaddb Vx,Hx,Wx (66),(v1) |
608 | fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) | 608 | fd: paddw Pq,Qq | vpaddw Vx,Hx,Wx (66),(v1) |
609 | fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) | 609 | fe: paddd Pq,Qq | vpaddd Vx,Hx,Wx (66),(v1) |
610 | ff: | 610 | ff: UD0 |
611 | EndTable | 611 | EndTable |
612 | 612 | ||
613 | Table: 3-byte opcode 1 (0x0f 0x38) | 613 | Table: 3-byte opcode 1 (0x0f 0x38) |
@@ -717,7 +717,7 @@ AVXcode: 2 | |||
717 | 7e: vpermt2d/q Vx,Hx,Wx (66),(ev) | 717 | 7e: vpermt2d/q Vx,Hx,Wx (66),(ev) |
718 | 7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) | 718 | 7f: vpermt2ps/d Vx,Hx,Wx (66),(ev) |
719 | 80: INVEPT Gy,Mdq (66) | 719 | 80: INVEPT Gy,Mdq (66) |
720 | 81: INVPID Gy,Mdq (66) | 720 | 81: INVVPID Gy,Mdq (66) |
721 | 82: INVPCID Gy,Mdq (66) | 721 | 82: INVPCID Gy,Mdq (66) |
722 | 83: vpmultishiftqb Vx,Hx,Wx (66),(ev) | 722 | 83: vpmultishiftqb Vx,Hx,Wx (66),(ev) |
723 | 88: vexpandps/d Vpd,Wpd (66),(ev) | 723 | 88: vexpandps/d Vpd,Wpd (66),(ev) |
@@ -970,6 +970,15 @@ GrpTable: Grp9 | |||
970 | EndTable | 970 | EndTable |
971 | 971 | ||
972 | GrpTable: Grp10 | 972 | GrpTable: Grp10 |
973 | # all are UD1 | ||
974 | 0: UD1 | ||
975 | 1: UD1 | ||
976 | 2: UD1 | ||
977 | 3: UD1 | ||
978 | 4: UD1 | ||
979 | 5: UD1 | ||
980 | 6: UD1 | ||
981 | 7: UD1 | ||
973 | EndTable | 982 | EndTable |
974 | 983 | ||
975 | # Grp11A and Grp11B are expressed as Grp11 in Intel SDM | 984 | # Grp11A and Grp11B are expressed as Grp11 in Intel SDM |