diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-14 14:57:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-01-14 14:57:22 -0500 |
commit | 10a0c0f0595b20efa127a1816670c64a3d0e4965 (patch) | |
tree | 884e10109861e4e8c05aced820c36b4f06563be9 /tools | |
parent | dcd1bfd50ab6952e8c60fd99d065d5be38b4b8b4 (diff) | |
parent | 7030a7e9321166eef44c811fe4af4d460360d424 (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 changes:
- fix lguest bug
- fix /proc/meminfo output on certain configs
- fix pvclock bug
- fix reboot on certain iMacs by adding new reboot quirk
- fix bootup crash
- fix FPU boot line option parsing
- add more x86 self-tests
- small cleanups, documentation improvements, etc"
* 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86/cpu/amd: Remove an unneeded condition in srat_detect_node()
x86/vdso/pvclock: Protect STABLE check with the seqcount
x86/mm: Improve switch_mm() barrier comments
selftests/x86: Test __kernel_sigreturn and __kernel_rt_sigreturn
x86/reboot/quirks: Add iMac10,1 to pci_reboot_dmi_table[]
lguest: Map switcher text R/O
x86/boot: Hide local labels in verify_cpu()
x86/fpu: Disable AVX when eagerfpu is off
x86/fpu: Disable MPX when eagerfpu is off
x86/fpu: Disable XGETBV1 when no XSAVE
x86/fpu: Fix early FPU command-line parsing
x86/mm: Use PAGE_ALIGNED instead of IS_ALIGNED
selftests/x86: Disable the ldt_gdt_64 test for now
x86/mm/pat: Make split_page_count() check for empty levels to fix /proc/meminfo output
x86/boot: Double BOOT_HEAP_SIZE to 64KB
x86/mm: Add barriers and document switch_mm()-vs-flush synchronization
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/selftests/x86/Makefile | 6 | ||||
-rw-r--r-- | tools/testing/selftests/x86/vdso_restorer.c | 88 |
2 files changed, 92 insertions, 2 deletions
diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile index eabcff411984..d0c473f65850 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile | |||
@@ -4,9 +4,11 @@ include ../lib.mk | |||
4 | 4 | ||
5 | .PHONY: all all_32 all_64 warn_32bit_failure clean | 5 | .PHONY: all all_32 all_64 warn_32bit_failure clean |
6 | 6 | ||
7 | TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs ldt_gdt syscall_nt ptrace_syscall | 7 | TARGETS_C_BOTHBITS := single_step_syscall sysret_ss_attrs syscall_nt ptrace_syscall |
8 | TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault sigreturn test_syscall_vdso unwind_vdso \ | 8 | TARGETS_C_32BIT_ONLY := entry_from_vm86 syscall_arg_fault sigreturn test_syscall_vdso unwind_vdso \ |
9 | test_FCMOV test_FCOMI test_FISTTP | 9 | test_FCMOV test_FCOMI test_FISTTP \ |
10 | ldt_gdt \ | ||
11 | vdso_restorer | ||
10 | 12 | ||
11 | TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) | 13 | TARGETS_C_32BIT_ALL := $(TARGETS_C_BOTHBITS) $(TARGETS_C_32BIT_ONLY) |
12 | BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) | 14 | BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) |
diff --git a/tools/testing/selftests/x86/vdso_restorer.c b/tools/testing/selftests/x86/vdso_restorer.c new file mode 100644 index 000000000000..cb038424a403 --- /dev/null +++ b/tools/testing/selftests/x86/vdso_restorer.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * vdso_restorer.c - tests vDSO-based signal restore | ||
3 | * Copyright (c) 2015 Andrew Lutomirski | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful, but | ||
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | * General Public License for more details. | ||
13 | * | ||
14 | * This makes sure that sa_restorer == NULL keeps working on 32-bit | ||
15 | * configurations. Modern glibc doesn't use it under any circumstances, | ||
16 | * so it's easy to overlook breakage. | ||
17 | * | ||
18 | * 64-bit userspace has never supported sa_restorer == NULL, so this is | ||
19 | * 32-bit only. | ||
20 | */ | ||
21 | |||
22 | #define _GNU_SOURCE | ||
23 | |||
24 | #include <err.h> | ||
25 | #include <stdio.h> | ||
26 | #include <string.h> | ||
27 | #include <signal.h> | ||
28 | #include <unistd.h> | ||
29 | #include <syscall.h> | ||
30 | #include <sys/syscall.h> | ||
31 | |||
32 | /* Open-code this -- the headers are too messy to easily use them. */ | ||
33 | struct real_sigaction { | ||
34 | void *handler; | ||
35 | unsigned long flags; | ||
36 | void *restorer; | ||
37 | unsigned int mask[2]; | ||
38 | }; | ||
39 | |||
40 | static volatile sig_atomic_t handler_called; | ||
41 | |||
42 | static void handler_with_siginfo(int sig, siginfo_t *info, void *ctx_void) | ||
43 | { | ||
44 | handler_called = 1; | ||
45 | } | ||
46 | |||
47 | static void handler_without_siginfo(int sig) | ||
48 | { | ||
49 | handler_called = 1; | ||
50 | } | ||
51 | |||
52 | int main() | ||
53 | { | ||
54 | int nerrs = 0; | ||
55 | struct real_sigaction sa; | ||
56 | |||
57 | memset(&sa, 0, sizeof(sa)); | ||
58 | sa.handler = handler_with_siginfo; | ||
59 | sa.flags = SA_SIGINFO; | ||
60 | sa.restorer = NULL; /* request kernel-provided restorer */ | ||
61 | |||
62 | if (syscall(SYS_rt_sigaction, SIGUSR1, &sa, NULL, 8) != 0) | ||
63 | err(1, "raw rt_sigaction syscall"); | ||
64 | |||
65 | raise(SIGUSR1); | ||
66 | |||
67 | if (handler_called) { | ||
68 | printf("[OK]\tSA_SIGINFO handler returned successfully\n"); | ||
69 | } else { | ||
70 | printf("[FAIL]\tSA_SIGINFO handler was not called\n"); | ||
71 | nerrs++; | ||
72 | } | ||
73 | |||
74 | sa.flags = 0; | ||
75 | sa.handler = handler_without_siginfo; | ||
76 | if (syscall(SYS_sigaction, SIGUSR1, &sa, 0) != 0) | ||
77 | err(1, "raw sigaction syscall"); | ||
78 | handler_called = 0; | ||
79 | |||
80 | raise(SIGUSR1); | ||
81 | |||
82 | if (handler_called) { | ||
83 | printf("[OK]\t!SA_SIGINFO handler returned successfully\n"); | ||
84 | } else { | ||
85 | printf("[FAIL]\t!SA_SIGINFO handler was not called\n"); | ||
86 | nerrs++; | ||
87 | } | ||
88 | } | ||