aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2018-03-23 11:24:57 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-23 11:31:58 -0400
commit03fe2debbb2771fb90881e4ce8109b09cf772a5c (patch)
treefbaf8738296b2e9dcba81c6daef2d515b6c4948c /tools
parent6686c459e1449a3ee5f3fd313b0a559ace7a700e (diff)
parentf36b7534b83357cf52e747905de6d65b4f7c2512 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Fun set of conflict resolutions here... For the mac80211 stuff, these were fortunately just parallel adds. Trivially resolved. In drivers/net/phy/phy.c we had a bug fix in 'net' that moved the function phy_disable_interrupts() earlier in the file, whilst in 'net-next' the phy_error() call from this function was removed. In net/ipv4/xfrm4_policy.c, David Ahern's changes to remove the 'rt_table_id' member of rtable collided with a bug fix in 'net' that added a new struct member "rt_mtu_locked" which needs to be copied over here. The mlxsw driver conflict consisted of net-next separating the span code and definitions into separate files, whilst a 'net' bug fix made some changes to that moved code. The mlx5 infiniband conflict resolution was quite non-trivial, the RDMA tree's merge commit was used as a guide here, and here are their notes: ==================== Due to bug fixes found by the syzkaller bot and taken into the for-rc branch after development for the 4.17 merge window had already started being taken into the for-next branch, there were fairly non-trivial merge issues that would need to be resolved between the for-rc branch and the for-next branch. This merge resolves those conflicts and provides a unified base upon which ongoing development for 4.17 can be based. Conflicts: drivers/infiniband/hw/mlx5/main.c - Commit 42cea83f9524 (IB/mlx5: Fix cleanup order on unload) added to for-rc and commit b5ca15ad7e61 (IB/mlx5: Add proper representors support) add as part of the devel cycle both needed to modify the init/de-init functions used by mlx5. To support the new representors, the new functions added by the cleanup patch needed to be made non-static, and the init/de-init list added by the representors patch needed to be modified to match the init/de-init list changes made by the cleanup patch. Updates: drivers/infiniband/hw/mlx5/mlx5_ib.h - Update function prototypes added by representors patch to reflect new function names as changed by cleanup patch drivers/infiniband/hw/mlx5/ib_rep.c - Update init/de-init stage list to match new order from cleanup patch ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/x86/include/asm/cpufeatures.h1
-rw-r--r--tools/bpf/bpftool/common.c4
-rw-r--r--tools/include/uapi/linux/kvm.h2
-rw-r--r--tools/objtool/check.c27
-rw-r--r--tools/perf/Documentation/perf-kallsyms.txt2
-rw-r--r--tools/perf/builtin-record.c9
-rw-r--r--tools/perf/builtin-stat.c2
-rw-r--r--tools/perf/builtin-top.c2
-rw-r--r--tools/perf/perf.h1
-rw-r--r--tools/perf/ui/browsers/annotate.c25
-rw-r--r--tools/perf/util/auxtrace.c15
-rw-r--r--tools/perf/util/record.c8
-rw-r--r--tools/perf/util/trigger.h9
-rw-r--r--tools/testing/selftests/powerpc/mm/subpage_prot.c14
-rw-r--r--tools/testing/selftests/powerpc/tm/Makefile2
-rw-r--r--tools/testing/selftests/powerpc/tm/tm-trap.c2
-rwxr-xr-xtools/testing/selftests/vm/run_vmtests25
-rw-r--r--tools/testing/selftests/x86/entry_from_vm86.c32
-rw-r--r--tools/testing/selftests/x86/test_vsyscall.c11
19 files changed, 140 insertions, 53 deletions
diff --git a/tools/arch/x86/include/asm/cpufeatures.h b/tools/arch/x86/include/asm/cpufeatures.h
index 0dfe4d3f74e2..f41079da38c5 100644
--- a/tools/arch/x86/include/asm/cpufeatures.h
+++ b/tools/arch/x86/include/asm/cpufeatures.h
@@ -213,6 +213,7 @@
213#define X86_FEATURE_SEV ( 7*32+20) /* AMD Secure Encrypted Virtualization */ 213#define X86_FEATURE_SEV ( 7*32+20) /* AMD Secure Encrypted Virtualization */
214 214
215#define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */ 215#define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */
216#define X86_FEATURE_USE_IBRS_FW ( 7*32+22) /* "" Use IBRS during runtime firmware calls */
216 217
217/* Virtualization flags: Linux defined, word 8 */ 218/* Virtualization flags: Linux defined, word 8 */
218#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */ 219#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 0b482c0070e0..465995281dcd 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -55,6 +55,10 @@
55 55
56#include "main.h" 56#include "main.h"
57 57
58#ifndef BPF_FS_MAGIC
59#define BPF_FS_MAGIC 0xcafe4a11
60#endif
61
58void p_err(const char *fmt, ...) 62void p_err(const char *fmt, ...)
59{ 63{
60 va_list ap; 64 va_list ap;
diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h
index 0fb5ef939732..7b26d4b0b052 100644
--- a/tools/include/uapi/linux/kvm.h
+++ b/tools/include/uapi/linux/kvm.h
@@ -761,6 +761,7 @@ struct kvm_ppc_resize_hpt {
761#define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07 761#define KVM_TRACE_PAUSE __KVM_DEPRECATED_MAIN_0x07
762#define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08 762#define KVM_TRACE_DISABLE __KVM_DEPRECATED_MAIN_0x08
763#define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2) 763#define KVM_GET_EMULATED_CPUID _IOWR(KVMIO, 0x09, struct kvm_cpuid2)
764#define KVM_GET_MSR_FEATURE_INDEX_LIST _IOWR(KVMIO, 0x0a, struct kvm_msr_list)
764 765
765/* 766/*
766 * Extension capability list. 767 * Extension capability list.
@@ -934,6 +935,7 @@ struct kvm_ppc_resize_hpt {
934#define KVM_CAP_S390_AIS_MIGRATION 150 935#define KVM_CAP_S390_AIS_MIGRATION 150
935#define KVM_CAP_PPC_GET_CPU_CHAR 151 936#define KVM_CAP_PPC_GET_CPU_CHAR 151
936#define KVM_CAP_S390_BPB 152 937#define KVM_CAP_S390_BPB 152
938#define KVM_CAP_GET_MSR_FEATURES 153
937 939
938#ifdef KVM_CAP_IRQ_ROUTING 940#ifdef KVM_CAP_IRQ_ROUTING
939 941
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 46c1d239cc1b..92b6a2c21631 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1116,42 +1116,29 @@ static int read_unwind_hints(struct objtool_file *file)
1116 1116
1117static int read_retpoline_hints(struct objtool_file *file) 1117static int read_retpoline_hints(struct objtool_file *file)
1118{ 1118{
1119 struct section *sec, *relasec; 1119 struct section *sec;
1120 struct instruction *insn; 1120 struct instruction *insn;
1121 struct rela *rela; 1121 struct rela *rela;
1122 int i;
1123 1122
1124 sec = find_section_by_name(file->elf, ".discard.retpoline_safe"); 1123 sec = find_section_by_name(file->elf, ".rela.discard.retpoline_safe");
1125 if (!sec) 1124 if (!sec)
1126 return 0; 1125 return 0;
1127 1126
1128 relasec = sec->rela; 1127 list_for_each_entry(rela, &sec->rela_list, list) {
1129 if (!relasec) { 1128 if (rela->sym->type != STT_SECTION) {
1130 WARN("missing .rela.discard.retpoline_safe section"); 1129 WARN("unexpected relocation symbol type in %s", sec->name);
1131 return -1;
1132 }
1133
1134 if (sec->len % sizeof(unsigned long)) {
1135 WARN("retpoline_safe size mismatch: %d %ld", sec->len, sizeof(unsigned long));
1136 return -1;
1137 }
1138
1139 for (i = 0; i < sec->len / sizeof(unsigned long); i++) {
1140 rela = find_rela_by_dest(sec, i * sizeof(unsigned long));
1141 if (!rela) {
1142 WARN("can't find rela for retpoline_safe[%d]", i);
1143 return -1; 1130 return -1;
1144 } 1131 }
1145 1132
1146 insn = find_insn(file, rela->sym->sec, rela->addend); 1133 insn = find_insn(file, rela->sym->sec, rela->addend);
1147 if (!insn) { 1134 if (!insn) {
1148 WARN("can't find insn for retpoline_safe[%d]", i); 1135 WARN("bad .discard.retpoline_safe entry");
1149 return -1; 1136 return -1;
1150 } 1137 }
1151 1138
1152 if (insn->type != INSN_JUMP_DYNAMIC && 1139 if (insn->type != INSN_JUMP_DYNAMIC &&
1153 insn->type != INSN_CALL_DYNAMIC) { 1140 insn->type != INSN_CALL_DYNAMIC) {
1154 WARN_FUNC("retpoline_safe hint not a indirect jump/call", 1141 WARN_FUNC("retpoline_safe hint not an indirect jump/call",
1155 insn->sec, insn->offset); 1142 insn->sec, insn->offset);
1156 return -1; 1143 return -1;
1157 } 1144 }
diff --git a/tools/perf/Documentation/perf-kallsyms.txt b/tools/perf/Documentation/perf-kallsyms.txt
index 954ea9e21236..cf9f4040ea5c 100644
--- a/tools/perf/Documentation/perf-kallsyms.txt
+++ b/tools/perf/Documentation/perf-kallsyms.txt
@@ -8,7 +8,7 @@ perf-kallsyms - Searches running kernel for symbols
8SYNOPSIS 8SYNOPSIS
9-------- 9--------
10[verse] 10[verse]
11'perf kallsyms <options> symbol_name[,symbol_name...]' 11'perf kallsyms' [<options>] symbol_name[,symbol_name...]
12 12
13DESCRIPTION 13DESCRIPTION
14----------- 14-----------
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index bf4ca749d1ac..a217623fec2e 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -881,6 +881,15 @@ static int __cmd_record(struct record *rec, int argc, const char **argv)
881 } 881 }
882 } 882 }
883 883
884 /*
885 * If we have just single event and are sending data
886 * through pipe, we need to force the ids allocation,
887 * because we synthesize event name through the pipe
888 * and need the id for that.
889 */
890 if (data->is_pipe && rec->evlist->nr_entries == 1)
891 rec->opts.sample_id = true;
892
884 if (record__open(rec) != 0) { 893 if (record__open(rec) != 0) {
885 err = -1; 894 err = -1;
886 goto out_child; 895 goto out_child;
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 98bf9d32f222..54a4c152edb3 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -917,7 +917,7 @@ static void print_metric_csv(void *ctx,
917 char buf[64], *vals, *ends; 917 char buf[64], *vals, *ends;
918 918
919 if (unit == NULL || fmt == NULL) { 919 if (unit == NULL || fmt == NULL) {
920 fprintf(out, "%s%s%s%s", csv_sep, csv_sep, csv_sep, csv_sep); 920 fprintf(out, "%s%s", csv_sep, csv_sep);
921 return; 921 return;
922 } 922 }
923 snprintf(buf, sizeof(buf), fmt, val); 923 snprintf(buf, sizeof(buf), fmt, val);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index b7c823ba8374..35ac016fcb98 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -991,7 +991,7 @@ static int perf_top_overwrite_fallback(struct perf_top *top,
991 evlist__for_each_entry(evlist, counter) 991 evlist__for_each_entry(evlist, counter)
992 counter->attr.write_backward = false; 992 counter->attr.write_backward = false;
993 opts->overwrite = false; 993 opts->overwrite = false;
994 ui__warning("fall back to non-overwrite mode\n"); 994 pr_debug2("fall back to non-overwrite mode\n");
995 return 1; 995 return 1;
996} 996}
997 997
diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index cfe46236a5e5..57b9b342d533 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -61,6 +61,7 @@ struct record_opts {
61 bool tail_synthesize; 61 bool tail_synthesize;
62 bool overwrite; 62 bool overwrite;
63 bool ignore_missing_thread; 63 bool ignore_missing_thread;
64 bool sample_id;
64 unsigned int freq; 65 unsigned int freq;
65 unsigned int mmap_pages; 66 unsigned int mmap_pages;
66 unsigned int auxtrace_mmap_pages; 67 unsigned int auxtrace_mmap_pages;
diff --git a/tools/perf/ui/browsers/annotate.c b/tools/perf/ui/browsers/annotate.c
index 286427975112..fbf927cf775d 100644
--- a/tools/perf/ui/browsers/annotate.c
+++ b/tools/perf/ui/browsers/annotate.c
@@ -327,7 +327,32 @@ static void annotate_browser__draw_current_jump(struct ui_browser *browser)
327 if (!disasm_line__is_valid_jump(cursor, sym)) 327 if (!disasm_line__is_valid_jump(cursor, sym))
328 return; 328 return;
329 329
330 /*
331 * This first was seen with a gcc function, _cpp_lex_token, that
332 * has the usual jumps:
333 *
334 * │1159e6c: ↓ jne 115aa32 <_cpp_lex_token@@Base+0xf92>
335 *
336 * I.e. jumps to a label inside that function (_cpp_lex_token), and
337 * those works, but also this kind:
338 *
339 * │1159e8b: ↓ jne c469be <cpp_named_operator2name@@Base+0xa72>
340 *
341 * I.e. jumps to another function, outside _cpp_lex_token, which
342 * are not being correctly handled generating as a side effect references
343 * to ab->offset[] entries that are set to NULL, so to make this code
344 * more robust, check that here.
345 *
346 * A proper fix for will be put in place, looking at the function
347 * name right after the '<' token and probably treating this like a
348 * 'call' instruction.
349 */
330 target = ab->offsets[cursor->ops.target.offset]; 350 target = ab->offsets[cursor->ops.target.offset];
351 if (target == NULL) {
352 ui_helpline__printf("WARN: jump target inconsistency, press 'o', ab->offsets[%#x] = NULL\n",
353 cursor->ops.target.offset);
354 return;
355 }
331 356
332 bcursor = browser_line(&cursor->al); 357 bcursor = browser_line(&cursor->al);
333 btarget = browser_line(target); 358 btarget = browser_line(target);
diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c
index 9faf3b5367db..6470ea2aa25e 100644
--- a/tools/perf/util/auxtrace.c
+++ b/tools/perf/util/auxtrace.c
@@ -60,6 +60,12 @@
60#include "sane_ctype.h" 60#include "sane_ctype.h"
61#include "symbol/kallsyms.h" 61#include "symbol/kallsyms.h"
62 62
63static bool auxtrace__dont_decode(struct perf_session *session)
64{
65 return !session->itrace_synth_opts ||
66 session->itrace_synth_opts->dont_decode;
67}
68
63int auxtrace_mmap__mmap(struct auxtrace_mmap *mm, 69int auxtrace_mmap__mmap(struct auxtrace_mmap *mm,
64 struct auxtrace_mmap_params *mp, 70 struct auxtrace_mmap_params *mp,
65 void *userpg, int fd) 71 void *userpg, int fd)
@@ -762,6 +768,9 @@ int auxtrace_queues__process_index(struct auxtrace_queues *queues,
762 size_t i; 768 size_t i;
763 int err; 769 int err;
764 770
771 if (auxtrace__dont_decode(session))
772 return 0;
773
765 list_for_each_entry(auxtrace_index, &session->auxtrace_index, list) { 774 list_for_each_entry(auxtrace_index, &session->auxtrace_index, list) {
766 for (i = 0; i < auxtrace_index->nr; i++) { 775 for (i = 0; i < auxtrace_index->nr; i++) {
767 ent = &auxtrace_index->entries[i]; 776 ent = &auxtrace_index->entries[i];
@@ -892,12 +901,6 @@ out_free:
892 return err; 901 return err;
893} 902}
894 903
895static bool auxtrace__dont_decode(struct perf_session *session)
896{
897 return !session->itrace_synth_opts ||
898 session->itrace_synth_opts->dont_decode;
899}
900
901int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused, 904int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
902 union perf_event *event, 905 union perf_event *event,
903 struct perf_session *session) 906 struct perf_session *session)
diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c
index 1e97937b03a9..6f09e4962dad 100644
--- a/tools/perf/util/record.c
+++ b/tools/perf/util/record.c
@@ -137,6 +137,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts,
137 struct perf_evsel *evsel; 137 struct perf_evsel *evsel;
138 bool use_sample_identifier = false; 138 bool use_sample_identifier = false;
139 bool use_comm_exec; 139 bool use_comm_exec;
140 bool sample_id = opts->sample_id;
140 141
141 /* 142 /*
142 * Set the evsel leader links before we configure attributes, 143 * Set the evsel leader links before we configure attributes,
@@ -163,8 +164,7 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts,
163 * match the id. 164 * match the id.
164 */ 165 */
165 use_sample_identifier = perf_can_sample_identifier(); 166 use_sample_identifier = perf_can_sample_identifier();
166 evlist__for_each_entry(evlist, evsel) 167 sample_id = true;
167 perf_evsel__set_sample_id(evsel, use_sample_identifier);
168 } else if (evlist->nr_entries > 1) { 168 } else if (evlist->nr_entries > 1) {
169 struct perf_evsel *first = perf_evlist__first(evlist); 169 struct perf_evsel *first = perf_evlist__first(evlist);
170 170
@@ -174,6 +174,10 @@ void perf_evlist__config(struct perf_evlist *evlist, struct record_opts *opts,
174 use_sample_identifier = perf_can_sample_identifier(); 174 use_sample_identifier = perf_can_sample_identifier();
175 break; 175 break;
176 } 176 }
177 sample_id = true;
178 }
179
180 if (sample_id) {
177 evlist__for_each_entry(evlist, evsel) 181 evlist__for_each_entry(evlist, evsel)
178 perf_evsel__set_sample_id(evsel, use_sample_identifier); 182 perf_evsel__set_sample_id(evsel, use_sample_identifier);
179 } 183 }
diff --git a/tools/perf/util/trigger.h b/tools/perf/util/trigger.h
index 370138e7e35c..88223bc7c82b 100644
--- a/tools/perf/util/trigger.h
+++ b/tools/perf/util/trigger.h
@@ -12,7 +12,7 @@
12 * States and transits: 12 * States and transits:
13 * 13 *
14 * 14 *
15 * OFF--(on)--> READY --(hit)--> HIT 15 * OFF--> ON --> READY --(hit)--> HIT
16 * ^ | 16 * ^ |
17 * | (ready) 17 * | (ready)
18 * | | 18 * | |
@@ -27,8 +27,9 @@ struct trigger {
27 volatile enum { 27 volatile enum {
28 TRIGGER_ERROR = -2, 28 TRIGGER_ERROR = -2,
29 TRIGGER_OFF = -1, 29 TRIGGER_OFF = -1,
30 TRIGGER_READY = 0, 30 TRIGGER_ON = 0,
31 TRIGGER_HIT = 1, 31 TRIGGER_READY = 1,
32 TRIGGER_HIT = 2,
32 } state; 33 } state;
33 const char *name; 34 const char *name;
34}; 35};
@@ -50,7 +51,7 @@ static inline bool trigger_is_error(struct trigger *t)
50static inline void trigger_on(struct trigger *t) 51static inline void trigger_on(struct trigger *t)
51{ 52{
52 TRIGGER_WARN_ONCE(t, TRIGGER_OFF); 53 TRIGGER_WARN_ONCE(t, TRIGGER_OFF);
53 t->state = TRIGGER_READY; 54 t->state = TRIGGER_ON;
54} 55}
55 56
56static inline void trigger_ready(struct trigger *t) 57static inline void trigger_ready(struct trigger *t)
diff --git a/tools/testing/selftests/powerpc/mm/subpage_prot.c b/tools/testing/selftests/powerpc/mm/subpage_prot.c
index 35ade7406dcd..3ae77ba93208 100644
--- a/tools/testing/selftests/powerpc/mm/subpage_prot.c
+++ b/tools/testing/selftests/powerpc/mm/subpage_prot.c
@@ -135,6 +135,16 @@ static int run_test(void *addr, unsigned long size)
135 return 0; 135 return 0;
136} 136}
137 137
138static int syscall_available(void)
139{
140 int rc;
141
142 errno = 0;
143 rc = syscall(__NR_subpage_prot, 0, 0, 0);
144
145 return rc == 0 || (errno != ENOENT && errno != ENOSYS);
146}
147
138int test_anon(void) 148int test_anon(void)
139{ 149{
140 unsigned long align; 150 unsigned long align;
@@ -145,6 +155,8 @@ int test_anon(void)
145 void *mallocblock; 155 void *mallocblock;
146 unsigned long mallocsize; 156 unsigned long mallocsize;
147 157
158 SKIP_IF(!syscall_available());
159
148 if (getpagesize() != 0x10000) { 160 if (getpagesize() != 0x10000) {
149 fprintf(stderr, "Kernel page size must be 64K!\n"); 161 fprintf(stderr, "Kernel page size must be 64K!\n");
150 return 1; 162 return 1;
@@ -180,6 +192,8 @@ int test_file(void)
180 off_t filesize; 192 off_t filesize;
181 int fd; 193 int fd;
182 194
195 SKIP_IF(!syscall_available());
196
183 fd = open(file_name, O_RDWR); 197 fd = open(file_name, O_RDWR);
184 if (fd == -1) { 198 if (fd == -1) {
185 perror("failed to open file"); 199 perror("failed to open file");
diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
index a23453943ad2..5c72ff978f27 100644
--- a/tools/testing/selftests/powerpc/tm/Makefile
+++ b/tools/testing/selftests/powerpc/tm/Makefile
@@ -16,7 +16,7 @@ $(OUTPUT)/tm-syscall: tm-syscall-asm.S
16$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include 16$(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include
17$(OUTPUT)/tm-tmspr: CFLAGS += -pthread 17$(OUTPUT)/tm-tmspr: CFLAGS += -pthread
18$(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64 18$(OUTPUT)/tm-vmx-unavail: CFLAGS += -pthread -m64
19$(OUTPUT)/tm-resched-dscr: ../pmu/lib.o 19$(OUTPUT)/tm-resched-dscr: ../pmu/lib.c
20$(OUTPUT)/tm-unavailable: CFLAGS += -O0 -pthread -m64 -Wno-error=uninitialized -mvsx 20$(OUTPUT)/tm-unavailable: CFLAGS += -O0 -pthread -m64 -Wno-error=uninitialized -mvsx
21$(OUTPUT)/tm-trap: CFLAGS += -O0 -pthread -m64 21$(OUTPUT)/tm-trap: CFLAGS += -O0 -pthread -m64
22 22
diff --git a/tools/testing/selftests/powerpc/tm/tm-trap.c b/tools/testing/selftests/powerpc/tm/tm-trap.c
index 5d92c23ee6cb..179d592f0073 100644
--- a/tools/testing/selftests/powerpc/tm/tm-trap.c
+++ b/tools/testing/selftests/powerpc/tm/tm-trap.c
@@ -255,6 +255,8 @@ int tm_trap_test(void)
255 255
256 struct sigaction trap_sa; 256 struct sigaction trap_sa;
257 257
258 SKIP_IF(!have_htm());
259
258 trap_sa.sa_flags = SA_SIGINFO; 260 trap_sa.sa_flags = SA_SIGINFO;
259 trap_sa.sa_sigaction = trap_signal_handler; 261 trap_sa.sa_sigaction = trap_signal_handler;
260 sigaction(SIGTRAP, &trap_sa, NULL); 262 sigaction(SIGTRAP, &trap_sa, NULL);
diff --git a/tools/testing/selftests/vm/run_vmtests b/tools/testing/selftests/vm/run_vmtests
index d2561895a021..22d564673830 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -2,25 +2,33 @@
2# SPDX-License-Identifier: GPL-2.0 2# SPDX-License-Identifier: GPL-2.0
3#please run as root 3#please run as root
4 4
5#we need 256M, below is the size in kB
6needmem=262144
7mnt=./huge 5mnt=./huge
8exitcode=0 6exitcode=0
9 7
10#get pagesize and freepages from /proc/meminfo 8#get huge pagesize and freepages from /proc/meminfo
11while read name size unit; do 9while read name size unit; do
12 if [ "$name" = "HugePages_Free:" ]; then 10 if [ "$name" = "HugePages_Free:" ]; then
13 freepgs=$size 11 freepgs=$size
14 fi 12 fi
15 if [ "$name" = "Hugepagesize:" ]; then 13 if [ "$name" = "Hugepagesize:" ]; then
16 pgsize=$size 14 hpgsize_KB=$size
17 fi 15 fi
18done < /proc/meminfo 16done < /proc/meminfo
19 17
18# Simple hugetlbfs tests have a hardcoded minimum requirement of
19# huge pages totaling 256MB (262144KB) in size. The userfaultfd
20# hugetlb test requires a minimum of 2 * nr_cpus huge pages. Take
21# both of these requirements into account and attempt to increase
22# number of huge pages available.
23nr_cpus=$(nproc)
24hpgsize_MB=$((hpgsize_KB / 1024))
25half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128))
26needmem_KB=$((half_ufd_size_MB * 2 * 1024))
27
20#set proper nr_hugepages 28#set proper nr_hugepages
21if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then 29if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
22 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages` 30 nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
23 needpgs=`expr $needmem / $pgsize` 31 needpgs=$((needmem_KB / hpgsize_KB))
24 tries=2 32 tries=2
25 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do 33 while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
26 lackpgs=$(( $needpgs - $freepgs )) 34 lackpgs=$(( $needpgs - $freepgs ))
@@ -107,8 +115,9 @@ fi
107echo "---------------------------" 115echo "---------------------------"
108echo "running userfaultfd_hugetlb" 116echo "running userfaultfd_hugetlb"
109echo "---------------------------" 117echo "---------------------------"
110# 256MB total huge pages == 128MB src and 128MB dst 118# Test requires source and destination huge pages. Size of source
111./userfaultfd hugetlb 128 32 $mnt/ufd_test_file 119# (half_ufd_size_MB) is passed as argument to test.
120./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file
112if [ $? -ne 0 ]; then 121if [ $? -ne 0 ]; then
113 echo "[FAIL]" 122 echo "[FAIL]"
114 exitcode=1 123 exitcode=1
diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c
index 361466a2eaef..ade443a88421 100644
--- a/tools/testing/selftests/x86/entry_from_vm86.c
+++ b/tools/testing/selftests/x86/entry_from_vm86.c
@@ -95,6 +95,10 @@ asm (
95 "int3\n\t" 95 "int3\n\t"
96 "vmcode_int80:\n\t" 96 "vmcode_int80:\n\t"
97 "int $0x80\n\t" 97 "int $0x80\n\t"
98 "vmcode_popf_hlt:\n\t"
99 "push %ax\n\t"
100 "popf\n\t"
101 "hlt\n\t"
98 "vmcode_umip:\n\t" 102 "vmcode_umip:\n\t"
99 /* addressing via displacements */ 103 /* addressing via displacements */
100 "smsw (2052)\n\t" 104 "smsw (2052)\n\t"
@@ -124,8 +128,8 @@ asm (
124 128
125extern unsigned char vmcode[], end_vmcode[]; 129extern unsigned char vmcode[], end_vmcode[];
126extern unsigned char vmcode_bound[], vmcode_sysenter[], vmcode_syscall[], 130extern unsigned char vmcode_bound[], vmcode_sysenter[], vmcode_syscall[],
127 vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_umip[], 131 vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_popf_hlt[],
128 vmcode_umip_str[], vmcode_umip_sldt[]; 132 vmcode_umip[], vmcode_umip_str[], vmcode_umip_sldt[];
129 133
130/* Returns false if the test was skipped. */ 134/* Returns false if the test was skipped. */
131static bool do_test(struct vm86plus_struct *v86, unsigned long eip, 135static bool do_test(struct vm86plus_struct *v86, unsigned long eip,
@@ -175,7 +179,7 @@ static bool do_test(struct vm86plus_struct *v86, unsigned long eip,
175 (VM86_TYPE(ret) == rettype && VM86_ARG(ret) == retarg)) { 179 (VM86_TYPE(ret) == rettype && VM86_ARG(ret) == retarg)) {
176 printf("[OK]\tReturned correctly\n"); 180 printf("[OK]\tReturned correctly\n");
177 } else { 181 } else {
178 printf("[FAIL]\tIncorrect return reason\n"); 182 printf("[FAIL]\tIncorrect return reason (started at eip = 0x%lx, ended at eip = 0x%lx)\n", eip, v86->regs.eip);
179 nerrs++; 183 nerrs++;
180 } 184 }
181 185
@@ -264,6 +268,9 @@ int main(void)
264 v86.regs.ds = load_addr / 16; 268 v86.regs.ds = load_addr / 16;
265 v86.regs.es = load_addr / 16; 269 v86.regs.es = load_addr / 16;
266 270
271 /* Use the end of the page as our stack. */
272 v86.regs.esp = 4096;
273
267 assert((v86.regs.cs & 3) == 0); /* Looks like RPL = 0 */ 274 assert((v86.regs.cs & 3) == 0); /* Looks like RPL = 0 */
268 275
269 /* #BR -- should deliver SIG??? */ 276 /* #BR -- should deliver SIG??? */
@@ -295,6 +302,23 @@ int main(void)
295 v86.regs.eflags &= ~X86_EFLAGS_IF; 302 v86.regs.eflags &= ~X86_EFLAGS_IF;
296 do_test(&v86, vmcode_sti - vmcode, VM86_STI, 0, "STI with VIP set"); 303 do_test(&v86, vmcode_sti - vmcode, VM86_STI, 0, "STI with VIP set");
297 304
305 /* POPF with VIP set but IF clear: should not trap */
306 v86.regs.eflags = X86_EFLAGS_VIP;
307 v86.regs.eax = 0;
308 do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP set and IF clear");
309
310 /* POPF with VIP set and IF set: should trap */
311 v86.regs.eflags = X86_EFLAGS_VIP;
312 v86.regs.eax = X86_EFLAGS_IF;
313 do_test(&v86, vmcode_popf_hlt - vmcode, VM86_STI, 0, "POPF with VIP and IF set");
314
315 /* POPF with VIP clear and IF set: should not trap */
316 v86.regs.eflags = 0;
317 v86.regs.eax = X86_EFLAGS_IF;
318 do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP clear and IF set");
319
320 v86.regs.eflags = 0;
321
298 /* INT3 -- should cause #BP */ 322 /* INT3 -- should cause #BP */
299 do_test(&v86, vmcode_int3 - vmcode, VM86_TRAP, 3, "INT3"); 323 do_test(&v86, vmcode_int3 - vmcode, VM86_TRAP, 3, "INT3");
300 324
@@ -318,7 +342,7 @@ int main(void)
318 clearhandler(SIGSEGV); 342 clearhandler(SIGSEGV);
319 343
320 /* Make sure nothing explodes if we fork. */ 344 /* Make sure nothing explodes if we fork. */
321 if (fork() > 0) 345 if (fork() == 0)
322 return 0; 346 return 0;
323 347
324 return (nerrs == 0 ? 0 : 1); 348 return (nerrs == 0 ? 0 : 1);
diff --git a/tools/testing/selftests/x86/test_vsyscall.c b/tools/testing/selftests/x86/test_vsyscall.c
index be81621446f0..0b4f1cc2291c 100644
--- a/tools/testing/selftests/x86/test_vsyscall.c
+++ b/tools/testing/selftests/x86/test_vsyscall.c
@@ -450,7 +450,7 @@ static void sigtrap(int sig, siginfo_t *info, void *ctx_void)
450 num_vsyscall_traps++; 450 num_vsyscall_traps++;
451} 451}
452 452
453static int test_native_vsyscall(void) 453static int test_emulation(void)
454{ 454{
455 time_t tmp; 455 time_t tmp;
456 bool is_native; 456 bool is_native;
@@ -458,7 +458,7 @@ static int test_native_vsyscall(void)
458 if (!vtime) 458 if (!vtime)
459 return 0; 459 return 0;
460 460
461 printf("[RUN]\tchecking for native vsyscall\n"); 461 printf("[RUN]\tchecking that vsyscalls are emulated\n");
462 sethandler(SIGTRAP, sigtrap, 0); 462 sethandler(SIGTRAP, sigtrap, 0);
463 set_eflags(get_eflags() | X86_EFLAGS_TF); 463 set_eflags(get_eflags() | X86_EFLAGS_TF);
464 vtime(&tmp); 464 vtime(&tmp);
@@ -474,11 +474,12 @@ static int test_native_vsyscall(void)
474 */ 474 */
475 is_native = (num_vsyscall_traps > 1); 475 is_native = (num_vsyscall_traps > 1);
476 476
477 printf("\tvsyscalls are %s (%d instructions in vsyscall page)\n", 477 printf("[%s]\tvsyscalls are %s (%d instructions in vsyscall page)\n",
478 (is_native ? "FAIL" : "OK"),
478 (is_native ? "native" : "emulated"), 479 (is_native ? "native" : "emulated"),
479 (int)num_vsyscall_traps); 480 (int)num_vsyscall_traps);
480 481
481 return 0; 482 return is_native;
482} 483}
483#endif 484#endif
484 485
@@ -498,7 +499,7 @@ int main(int argc, char **argv)
498 nerrs += test_vsys_r(); 499 nerrs += test_vsys_r();
499 500
500#ifdef __x86_64__ 501#ifdef __x86_64__
501 nerrs += test_native_vsyscall(); 502 nerrs += test_emulation();
502#endif 503#endif
503 504
504 return nerrs ? 1 : 0; 505 return nerrs ? 1 : 0;