summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-05 02:13:24 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-09-05 02:13:24 -0400
commit9c2edd8b5bcb36ec6c890dd85f8fd13034aaa43e (patch)
tree052b3c229e00462cd0c5773c8b6b9fe314e86f38 /tools
parentaa652b1ccbd0d3a9cd4ecdec6d36935f78c838da (diff)
parentc6935931c1894ff857616ff8549b61236a19148f (diff)
Merge 4.8-rc5 into staging-next
We want the staging fixes in here as well to handle merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/arch/arm64/include/uapi/asm/kvm.h2
-rw-r--r--tools/arch/s390/include/uapi/asm/kvm.h41
-rw-r--r--tools/arch/s390/include/uapi/asm/sie.h1
-rw-r--r--tools/gpio/gpio-event-mon.c2
-rw-r--r--tools/iio/iio_generic_buffer.c2
-rw-r--r--tools/include/linux/string.h6
-rw-r--r--tools/perf/arch/powerpc/util/sym-handling.c2
-rw-r--r--tools/perf/arch/x86/util/intel-pt.c6
-rw-r--r--tools/perf/builtin-mem.c3
-rw-r--r--tools/perf/builtin-script.c13
-rw-r--r--tools/perf/util/evsel.c6
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c44
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c24
-rw-r--r--tools/perf/util/jitdump.c1
-rw-r--r--tools/perf/util/probe-file.c36
-rw-r--r--tools/perf/util/symbol-elf.c3
-rw-r--r--tools/perf/util/unwind-libdw.c2
-rw-r--r--tools/perf/util/unwind-libunwind-local.c2
-rw-r--r--tools/virtio/linux/dma-mapping.h16
-rw-r--r--tools/virtio/linux/kernel.h14
-rw-r--r--tools/virtio/linux/slab.h4
-rw-r--r--tools/virtio/linux/virtio.h6
-rw-r--r--tools/virtio/linux/virtio_config.h13
-rw-r--r--tools/virtio/ringtest/ptr_ring.c1
24 files changed, 201 insertions, 49 deletions
diff --git a/tools/arch/arm64/include/uapi/asm/kvm.h b/tools/arch/arm64/include/uapi/asm/kvm.h
index f209ea151dca..3051f86a9b5f 100644
--- a/tools/arch/arm64/include/uapi/asm/kvm.h
+++ b/tools/arch/arm64/include/uapi/asm/kvm.h
@@ -87,9 +87,11 @@ struct kvm_regs {
87/* Supported VGICv3 address types */ 87/* Supported VGICv3 address types */
88#define KVM_VGIC_V3_ADDR_TYPE_DIST 2 88#define KVM_VGIC_V3_ADDR_TYPE_DIST 2
89#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3 89#define KVM_VGIC_V3_ADDR_TYPE_REDIST 3
90#define KVM_VGIC_ITS_ADDR_TYPE 4
90 91
91#define KVM_VGIC_V3_DIST_SIZE SZ_64K 92#define KVM_VGIC_V3_DIST_SIZE SZ_64K
92#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K) 93#define KVM_VGIC_V3_REDIST_SIZE (2 * SZ_64K)
94#define KVM_VGIC_V3_ITS_SIZE (2 * SZ_64K)
93 95
94#define KVM_ARM_VCPU_POWER_OFF 0 /* CPU is started in OFF state */ 96#define KVM_ARM_VCPU_POWER_OFF 0 /* CPU is started in OFF state */
95#define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */ 97#define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */
diff --git a/tools/arch/s390/include/uapi/asm/kvm.h b/tools/arch/s390/include/uapi/asm/kvm.h
index 3b8e99ef9d58..a2ffec4139ad 100644
--- a/tools/arch/s390/include/uapi/asm/kvm.h
+++ b/tools/arch/s390/include/uapi/asm/kvm.h
@@ -93,6 +93,47 @@ struct kvm_s390_vm_cpu_machine {
93 __u64 fac_list[256]; 93 __u64 fac_list[256];
94}; 94};
95 95
96#define KVM_S390_VM_CPU_PROCESSOR_FEAT 2
97#define KVM_S390_VM_CPU_MACHINE_FEAT 3
98
99#define KVM_S390_VM_CPU_FEAT_NR_BITS 1024
100#define KVM_S390_VM_CPU_FEAT_ESOP 0
101#define KVM_S390_VM_CPU_FEAT_SIEF2 1
102#define KVM_S390_VM_CPU_FEAT_64BSCAO 2
103#define KVM_S390_VM_CPU_FEAT_SIIF 3
104#define KVM_S390_VM_CPU_FEAT_GPERE 4
105#define KVM_S390_VM_CPU_FEAT_GSLS 5
106#define KVM_S390_VM_CPU_FEAT_IB 6
107#define KVM_S390_VM_CPU_FEAT_CEI 7
108#define KVM_S390_VM_CPU_FEAT_IBS 8
109#define KVM_S390_VM_CPU_FEAT_SKEY 9
110#define KVM_S390_VM_CPU_FEAT_CMMA 10
111#define KVM_S390_VM_CPU_FEAT_PFMFI 11
112#define KVM_S390_VM_CPU_FEAT_SIGPIF 12
113struct kvm_s390_vm_cpu_feat {
114 __u64 feat[16];
115};
116
117#define KVM_S390_VM_CPU_PROCESSOR_SUBFUNC 4
118#define KVM_S390_VM_CPU_MACHINE_SUBFUNC 5
119/* for "test bit" instructions MSB 0 bit ordering, for "query" raw blocks */
120struct kvm_s390_vm_cpu_subfunc {
121 __u8 plo[32]; /* always */
122 __u8 ptff[16]; /* with TOD-clock steering */
123 __u8 kmac[16]; /* with MSA */
124 __u8 kmc[16]; /* with MSA */
125 __u8 km[16]; /* with MSA */
126 __u8 kimd[16]; /* with MSA */
127 __u8 klmd[16]; /* with MSA */
128 __u8 pckmo[16]; /* with MSA3 */
129 __u8 kmctr[16]; /* with MSA4 */
130 __u8 kmf[16]; /* with MSA4 */
131 __u8 kmo[16]; /* with MSA4 */
132 __u8 pcc[16]; /* with MSA4 */
133 __u8 ppno[16]; /* with MSA5 */
134 __u8 reserved[1824];
135};
136
96/* kvm attributes for crypto */ 137/* kvm attributes for crypto */
97#define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0 138#define KVM_S390_VM_CRYPTO_ENABLE_AES_KW 0
98#define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1 139#define KVM_S390_VM_CRYPTO_ENABLE_DEA_KW 1
diff --git a/tools/arch/s390/include/uapi/asm/sie.h b/tools/arch/s390/include/uapi/asm/sie.h
index 8fb5d4a6dd25..3ac634368939 100644
--- a/tools/arch/s390/include/uapi/asm/sie.h
+++ b/tools/arch/s390/include/uapi/asm/sie.h
@@ -140,6 +140,7 @@
140 exit_code_ipa0(0xB2, 0x4c, "TAR"), \ 140 exit_code_ipa0(0xB2, 0x4c, "TAR"), \
141 exit_code_ipa0(0xB2, 0x50, "CSP"), \ 141 exit_code_ipa0(0xB2, 0x50, "CSP"), \
142 exit_code_ipa0(0xB2, 0x54, "MVPG"), \ 142 exit_code_ipa0(0xB2, 0x54, "MVPG"), \
143 exit_code_ipa0(0xB2, 0x56, "STHYI"), \
143 exit_code_ipa0(0xB2, 0x58, "BSG"), \ 144 exit_code_ipa0(0xB2, 0x58, "BSG"), \
144 exit_code_ipa0(0xB2, 0x5a, "BSA"), \ 145 exit_code_ipa0(0xB2, 0x5a, "BSA"), \
145 exit_code_ipa0(0xB2, 0x5f, "CHSC"), \ 146 exit_code_ipa0(0xB2, 0x5f, "CHSC"), \
diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c
index 448ed96b3b4f..1c14c2595158 100644
--- a/tools/gpio/gpio-event-mon.c
+++ b/tools/gpio/gpio-event-mon.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * gpio-hammer - example swiss army knife to shake GPIO lines on a system 2 * gpio-event-mon - monitor GPIO line events from userspace
3 * 3 *
4 * Copyright (C) 2016 Linus Walleij 4 * Copyright (C) 2016 Linus Walleij
5 * 5 *
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 0e8a1f7a292d..ae68bf0e2d51 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -348,7 +348,7 @@ int main(int argc, char **argv)
348 int notrigger = 0; 348 int notrigger = 0;
349 char *dummy; 349 char *dummy;
350 350
351 struct iio_channel_info *channels; 351 struct iio_channel_info *channels = NULL;
352 352
353 register_cleanup(); 353 register_cleanup();
354 354
diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h
index b96879477311..f436d2420a18 100644
--- a/tools/include/linux/string.h
+++ b/tools/include/linux/string.h
@@ -8,7 +8,11 @@ void *memdup(const void *src, size_t len);
8 8
9int strtobool(const char *s, bool *res); 9int strtobool(const char *s, bool *res);
10 10
11#ifdef __GLIBC__ 11/*
12 * glibc based builds needs the extern while uClibc doesn't.
13 * However uClibc headers also define __GLIBC__ hence the hack below
14 */
15#if defined(__GLIBC__) && !defined(__UCLIBC__)
12extern size_t strlcpy(char *dest, const char *src, size_t size); 16extern size_t strlcpy(char *dest, const char *src, size_t size);
13#endif 17#endif
14 18
diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index 8d4dc97d80ba..35745a733100 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -97,6 +97,7 @@ void arch__fix_tev_from_maps(struct perf_probe_event *pev,
97 } 97 }
98} 98}
99 99
100#ifdef HAVE_LIBELF_SUPPORT
100void arch__post_process_probe_trace_events(struct perf_probe_event *pev, 101void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
101 int ntevs) 102 int ntevs)
102{ 103{
@@ -118,5 +119,6 @@ void arch__post_process_probe_trace_events(struct perf_probe_event *pev,
118 } 119 }
119 } 120 }
120} 121}
122#endif /* HAVE_LIBELF_SUPPORT */
121 123
122#endif 124#endif
diff --git a/tools/perf/arch/x86/util/intel-pt.c b/tools/perf/arch/x86/util/intel-pt.c
index fb51457ba338..a2412e9d883b 100644
--- a/tools/perf/arch/x86/util/intel-pt.c
+++ b/tools/perf/arch/x86/util/intel-pt.c
@@ -501,7 +501,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
501 struct intel_pt_recording *ptr = 501 struct intel_pt_recording *ptr =
502 container_of(itr, struct intel_pt_recording, itr); 502 container_of(itr, struct intel_pt_recording, itr);
503 struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu; 503 struct perf_pmu *intel_pt_pmu = ptr->intel_pt_pmu;
504 bool have_timing_info; 504 bool have_timing_info, need_immediate = false;
505 struct perf_evsel *evsel, *intel_pt_evsel = NULL; 505 struct perf_evsel *evsel, *intel_pt_evsel = NULL;
506 const struct cpu_map *cpus = evlist->cpus; 506 const struct cpu_map *cpus = evlist->cpus;
507 bool privileged = geteuid() == 0 || perf_event_paranoid() < 0; 507 bool privileged = geteuid() == 0 || perf_event_paranoid() < 0;
@@ -655,6 +655,7 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
655 ptr->have_sched_switch = 3; 655 ptr->have_sched_switch = 3;
656 } else { 656 } else {
657 opts->record_switch_events = true; 657 opts->record_switch_events = true;
658 need_immediate = true;
658 if (cpu_wide) 659 if (cpu_wide)
659 ptr->have_sched_switch = 3; 660 ptr->have_sched_switch = 3;
660 else 661 else
@@ -700,6 +701,9 @@ static int intel_pt_recording_options(struct auxtrace_record *itr,
700 tracking_evsel->attr.freq = 0; 701 tracking_evsel->attr.freq = 0;
701 tracking_evsel->attr.sample_period = 1; 702 tracking_evsel->attr.sample_period = 1;
702 703
704 if (need_immediate)
705 tracking_evsel->immediate = true;
706
703 /* In per-cpu case, always need the time of mmap events etc */ 707 /* In per-cpu case, always need the time of mmap events etc */
704 if (!cpu_map__empty(cpus)) { 708 if (!cpu_map__empty(cpus)) {
705 perf_evsel__set_sample_bit(tracking_evsel, TIME); 709 perf_evsel__set_sample_bit(tracking_evsel, TIME);
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c
index d608a2c9e48c..d1ce29be560e 100644
--- a/tools/perf/builtin-mem.c
+++ b/tools/perf/builtin-mem.c
@@ -88,6 +88,9 @@ static int __cmd_record(int argc, const char **argv, struct perf_mem *mem)
88 if (mem->operation & MEM_OPERATION_LOAD) 88 if (mem->operation & MEM_OPERATION_LOAD)
89 perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true; 89 perf_mem_events[PERF_MEM_EVENTS__LOAD].record = true;
90 90
91 if (mem->operation & MEM_OPERATION_STORE)
92 perf_mem_events[PERF_MEM_EVENTS__STORE].record = true;
93
91 if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record) 94 if (perf_mem_events[PERF_MEM_EVENTS__LOAD].record)
92 rec_argv[i++] = "-W"; 95 rec_argv[i++] = "-W";
93 96
diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
index 9c640a8081c7..c859e59dfe3e 100644
--- a/tools/perf/builtin-script.c
+++ b/tools/perf/builtin-script.c
@@ -371,14 +371,16 @@ static int perf_session__check_output_opt(struct perf_session *session)
371 371
372 if (!no_callchain) { 372 if (!no_callchain) {
373 bool use_callchain = false; 373 bool use_callchain = false;
374 bool not_pipe = false;
374 375
375 evlist__for_each_entry(session->evlist, evsel) { 376 evlist__for_each_entry(session->evlist, evsel) {
377 not_pipe = true;
376 if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) { 378 if (evsel->attr.sample_type & PERF_SAMPLE_CALLCHAIN) {
377 use_callchain = true; 379 use_callchain = true;
378 break; 380 break;
379 } 381 }
380 } 382 }
381 if (!use_callchain) 383 if (not_pipe && !use_callchain)
382 symbol_conf.use_callchain = false; 384 symbol_conf.use_callchain = false;
383 } 385 }
384 386
@@ -1690,8 +1692,13 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
1690 snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path()); 1692 snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
1691 1693
1692 scripts_dir = opendir(scripts_path); 1694 scripts_dir = opendir(scripts_path);
1693 if (!scripts_dir) 1695 if (!scripts_dir) {
1694 return -1; 1696 fprintf(stdout,
1697 "open(%s) failed.\n"
1698 "Check \"PERF_EXEC_PATH\" env to set scripts dir.\n",
1699 scripts_path);
1700 exit(-1);
1701 }
1695 1702
1696 for_each_lang(scripts_path, scripts_dir, lang_dirent) { 1703 for_each_lang(scripts_path, scripts_dir, lang_dirent) {
1697 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path, 1704 snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d9b80ef881cd..21fd573106ed 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -507,17 +507,17 @@ static int __perf_evsel__hw_cache_name(u64 config, char *bf, size_t size)
507 u8 op, result, type = (config >> 0) & 0xff; 507 u8 op, result, type = (config >> 0) & 0xff;
508 const char *err = "unknown-ext-hardware-cache-type"; 508 const char *err = "unknown-ext-hardware-cache-type";
509 509
510 if (type > PERF_COUNT_HW_CACHE_MAX) 510 if (type >= PERF_COUNT_HW_CACHE_MAX)
511 goto out_err; 511 goto out_err;
512 512
513 op = (config >> 8) & 0xff; 513 op = (config >> 8) & 0xff;
514 err = "unknown-ext-hardware-cache-op"; 514 err = "unknown-ext-hardware-cache-op";
515 if (op > PERF_COUNT_HW_CACHE_OP_MAX) 515 if (op >= PERF_COUNT_HW_CACHE_OP_MAX)
516 goto out_err; 516 goto out_err;
517 517
518 result = (config >> 16) & 0xff; 518 result = (config >> 16) & 0xff;
519 err = "unknown-ext-hardware-cache-result"; 519 err = "unknown-ext-hardware-cache-result";
520 if (result > PERF_COUNT_HW_CACHE_RESULT_MAX) 520 if (result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
521 goto out_err; 521 goto out_err;
522 522
523 err = "invalid-cache"; 523 err = "invalid-cache";
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 9c8f15da86ce..8ff6c6a61291 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -123,8 +123,6 @@ struct intel_pt_decoder {
123 bool have_calc_cyc_to_tsc; 123 bool have_calc_cyc_to_tsc;
124 int exec_mode; 124 int exec_mode;
125 unsigned int insn_bytes; 125 unsigned int insn_bytes;
126 uint64_t sign_bit;
127 uint64_t sign_bits;
128 uint64_t period; 126 uint64_t period;
129 enum intel_pt_period_type period_type; 127 enum intel_pt_period_type period_type;
130 uint64_t tot_insn_cnt; 128 uint64_t tot_insn_cnt;
@@ -191,9 +189,6 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
191 decoder->data = params->data; 189 decoder->data = params->data;
192 decoder->return_compression = params->return_compression; 190 decoder->return_compression = params->return_compression;
193 191
194 decoder->sign_bit = (uint64_t)1 << 47;
195 decoder->sign_bits = ~(((uint64_t)1 << 48) - 1);
196
197 decoder->period = params->period; 192 decoder->period = params->period;
198 decoder->period_type = params->period_type; 193 decoder->period_type = params->period_type;
199 194
@@ -362,21 +357,30 @@ int intel_pt__strerror(int code, char *buf, size_t buflen)
362 return 0; 357 return 0;
363} 358}
364 359
365static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder, 360static uint64_t intel_pt_calc_ip(const struct intel_pt_pkt *packet,
366 const struct intel_pt_pkt *packet,
367 uint64_t last_ip) 361 uint64_t last_ip)
368{ 362{
369 uint64_t ip; 363 uint64_t ip;
370 364
371 switch (packet->count) { 365 switch (packet->count) {
372 case 2: 366 case 1:
373 ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) | 367 ip = (last_ip & (uint64_t)0xffffffffffff0000ULL) |
374 packet->payload; 368 packet->payload;
375 break; 369 break;
376 case 4: 370 case 2:
377 ip = (last_ip & (uint64_t)0xffffffff00000000ULL) | 371 ip = (last_ip & (uint64_t)0xffffffff00000000ULL) |
378 packet->payload; 372 packet->payload;
379 break; 373 break;
374 case 3:
375 ip = packet->payload;
376 /* Sign-extend 6-byte ip */
377 if (ip & (uint64_t)0x800000000000ULL)
378 ip |= (uint64_t)0xffff000000000000ULL;
379 break;
380 case 4:
381 ip = (last_ip & (uint64_t)0xffff000000000000ULL) |
382 packet->payload;
383 break;
380 case 6: 384 case 6:
381 ip = packet->payload; 385 ip = packet->payload;
382 break; 386 break;
@@ -384,16 +388,12 @@ static uint64_t intel_pt_calc_ip(struct intel_pt_decoder *decoder,
384 return 0; 388 return 0;
385 } 389 }
386 390
387 if (ip & decoder->sign_bit)
388 return ip | decoder->sign_bits;
389
390 return ip; 391 return ip;
391} 392}
392 393
393static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder) 394static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder)
394{ 395{
395 decoder->last_ip = intel_pt_calc_ip(decoder, &decoder->packet, 396 decoder->last_ip = intel_pt_calc_ip(&decoder->packet, decoder->last_ip);
396 decoder->last_ip);
397} 397}
398 398
399static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder) 399static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder)
@@ -1657,6 +1657,12 @@ next:
1657 } 1657 }
1658} 1658}
1659 1659
1660static inline bool intel_pt_have_ip(struct intel_pt_decoder *decoder)
1661{
1662 return decoder->last_ip || decoder->packet.count == 0 ||
1663 decoder->packet.count == 3 || decoder->packet.count == 6;
1664}
1665
1660/* Walk PSB+ packets to get in sync. */ 1666/* Walk PSB+ packets to get in sync. */
1661static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) 1667static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
1662{ 1668{
@@ -1677,8 +1683,7 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
1677 1683
1678 case INTEL_PT_FUP: 1684 case INTEL_PT_FUP:
1679 decoder->pge = true; 1685 decoder->pge = true;
1680 if (decoder->last_ip || decoder->packet.count == 6 || 1686 if (intel_pt_have_ip(decoder)) {
1681 decoder->packet.count == 0) {
1682 uint64_t current_ip = decoder->ip; 1687 uint64_t current_ip = decoder->ip;
1683 1688
1684 intel_pt_set_ip(decoder); 1689 intel_pt_set_ip(decoder);
@@ -1767,8 +1772,7 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
1767 case INTEL_PT_TIP_PGE: 1772 case INTEL_PT_TIP_PGE:
1768 case INTEL_PT_TIP: 1773 case INTEL_PT_TIP:
1769 decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD; 1774 decoder->pge = decoder->packet.type != INTEL_PT_TIP_PGD;
1770 if (decoder->last_ip || decoder->packet.count == 6 || 1775 if (intel_pt_have_ip(decoder))
1771 decoder->packet.count == 0)
1772 intel_pt_set_ip(decoder); 1776 intel_pt_set_ip(decoder);
1773 if (decoder->ip) 1777 if (decoder->ip)
1774 return 0; 1778 return 0;
@@ -1776,9 +1780,7 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
1776 1780
1777 case INTEL_PT_FUP: 1781 case INTEL_PT_FUP:
1778 if (decoder->overflow) { 1782 if (decoder->overflow) {
1779 if (decoder->last_ip || 1783 if (intel_pt_have_ip(decoder))
1780 decoder->packet.count == 6 ||
1781 decoder->packet.count == 0)
1782 intel_pt_set_ip(decoder); 1784 intel_pt_set_ip(decoder);
1783 if (decoder->ip) 1785 if (decoder->ip)
1784 return 0; 1786 return 0;
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
index b1257c816310..4f7b32020487 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c
@@ -292,36 +292,46 @@ static int intel_pt_get_ip(enum intel_pt_pkt_type type, unsigned int byte,
292 const unsigned char *buf, size_t len, 292 const unsigned char *buf, size_t len,
293 struct intel_pt_pkt *packet) 293 struct intel_pt_pkt *packet)
294{ 294{
295 switch (byte >> 5) { 295 int ip_len;
296
297 packet->count = byte >> 5;
298
299 switch (packet->count) {
296 case 0: 300 case 0:
297 packet->count = 0; 301 ip_len = 0;
298 break; 302 break;
299 case 1: 303 case 1:
300 if (len < 3) 304 if (len < 3)
301 return INTEL_PT_NEED_MORE_BYTES; 305 return INTEL_PT_NEED_MORE_BYTES;
302 packet->count = 2; 306 ip_len = 2;
303 packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1)); 307 packet->payload = le16_to_cpu(*(uint16_t *)(buf + 1));
304 break; 308 break;
305 case 2: 309 case 2:
306 if (len < 5) 310 if (len < 5)
307 return INTEL_PT_NEED_MORE_BYTES; 311 return INTEL_PT_NEED_MORE_BYTES;
308 packet->count = 4; 312 ip_len = 4;
309 packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1)); 313 packet->payload = le32_to_cpu(*(uint32_t *)(buf + 1));
310 break; 314 break;
311 case 3: 315 case 3:
312 case 6: 316 case 4:
313 if (len < 7) 317 if (len < 7)
314 return INTEL_PT_NEED_MORE_BYTES; 318 return INTEL_PT_NEED_MORE_BYTES;
315 packet->count = 6; 319 ip_len = 6;
316 memcpy_le64(&packet->payload, buf + 1, 6); 320 memcpy_le64(&packet->payload, buf + 1, 6);
317 break; 321 break;
322 case 6:
323 if (len < 9)
324 return INTEL_PT_NEED_MORE_BYTES;
325 ip_len = 8;
326 packet->payload = le64_to_cpu(*(uint64_t *)(buf + 1));
327 break;
318 default: 328 default:
319 return INTEL_PT_BAD_PACKET; 329 return INTEL_PT_BAD_PACKET;
320 } 330 }
321 331
322 packet->type = type; 332 packet->type = type;
323 333
324 return packet->count + 1; 334 return ip_len + 1;
325} 335}
326 336
327static int intel_pt_get_mode(const unsigned char *buf, size_t len, 337static int intel_pt_get_mode(const unsigned char *buf, size_t len,
diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
index 9f3305f6b6d5..95f0884aae02 100644
--- a/tools/perf/util/jitdump.c
+++ b/tools/perf/util/jitdump.c
@@ -1,3 +1,4 @@
1#include <sys/sysmacros.h>
1#include <sys/types.h> 2#include <sys/types.h>
2#include <stdio.h> 3#include <stdio.h>
3#include <stdlib.h> 4#include <stdlib.h>
diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c
index 9aed9c332da6..9c3b9ed5b3c3 100644
--- a/tools/perf/util/probe-file.c
+++ b/tools/perf/util/probe-file.c
@@ -133,7 +133,7 @@ int probe_file__open_both(int *kfd, int *ufd, int flag)
133/* Get raw string list of current kprobe_events or uprobe_events */ 133/* Get raw string list of current kprobe_events or uprobe_events */
134struct strlist *probe_file__get_rawlist(int fd) 134struct strlist *probe_file__get_rawlist(int fd)
135{ 135{
136 int ret, idx; 136 int ret, idx, fddup;
137 FILE *fp; 137 FILE *fp;
138 char buf[MAX_CMDLEN]; 138 char buf[MAX_CMDLEN];
139 char *p; 139 char *p;
@@ -143,8 +143,17 @@ struct strlist *probe_file__get_rawlist(int fd)
143 return NULL; 143 return NULL;
144 144
145 sl = strlist__new(NULL, NULL); 145 sl = strlist__new(NULL, NULL);
146 if (sl == NULL)
147 return NULL;
148
149 fddup = dup(fd);
150 if (fddup < 0)
151 goto out_free_sl;
152
153 fp = fdopen(fddup, "r");
154 if (!fp)
155 goto out_close_fddup;
146 156
147 fp = fdopen(dup(fd), "r");
148 while (!feof(fp)) { 157 while (!feof(fp)) {
149 p = fgets(buf, MAX_CMDLEN, fp); 158 p = fgets(buf, MAX_CMDLEN, fp);
150 if (!p) 159 if (!p)
@@ -156,13 +165,21 @@ struct strlist *probe_file__get_rawlist(int fd)
156 ret = strlist__add(sl, buf); 165 ret = strlist__add(sl, buf);
157 if (ret < 0) { 166 if (ret < 0) {
158 pr_debug("strlist__add failed (%d)\n", ret); 167 pr_debug("strlist__add failed (%d)\n", ret);
159 strlist__delete(sl); 168 goto out_close_fp;
160 return NULL;
161 } 169 }
162 } 170 }
163 fclose(fp); 171 fclose(fp);
164 172
165 return sl; 173 return sl;
174
175out_close_fp:
176 fclose(fp);
177 goto out_free_sl;
178out_close_fddup:
179 close(fddup);
180out_free_sl:
181 strlist__delete(sl);
182 return NULL;
166} 183}
167 184
168static struct strlist *__probe_file__get_namelist(int fd, bool include_group) 185static struct strlist *__probe_file__get_namelist(int fd, bool include_group)
@@ -447,12 +464,17 @@ static int probe_cache__load(struct probe_cache *pcache)
447{ 464{
448 struct probe_cache_entry *entry = NULL; 465 struct probe_cache_entry *entry = NULL;
449 char buf[MAX_CMDLEN], *p; 466 char buf[MAX_CMDLEN], *p;
450 int ret = 0; 467 int ret = 0, fddup;
451 FILE *fp; 468 FILE *fp;
452 469
453 fp = fdopen(dup(pcache->fd), "r"); 470 fddup = dup(pcache->fd);
454 if (!fp) 471 if (fddup < 0)
472 return -errno;
473 fp = fdopen(fddup, "r");
474 if (!fp) {
475 close(fddup);
455 return -EINVAL; 476 return -EINVAL;
477 }
456 478
457 while (!feof(fp)) { 479 while (!feof(fp)) {
458 if (!fgets(buf, MAX_CMDLEN, fp)) 480 if (!fgets(buf, MAX_CMDLEN, fp))
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index a34321e9b44d..a811c13a74d6 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -837,7 +837,8 @@ int dso__load_sym(struct dso *dso, struct map *map,
837 sec = syms_ss->symtab; 837 sec = syms_ss->symtab;
838 shdr = syms_ss->symshdr; 838 shdr = syms_ss->symshdr;
839 839
840 if (elf_section_by_name(elf, &ehdr, &tshdr, ".text", NULL)) 840 if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr,
841 ".text", NULL))
841 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset; 842 dso->text_offset = tshdr.sh_addr - tshdr.sh_offset;
842 843
843 if (runtime_ss->opdsec) 844 if (runtime_ss->opdsec)
diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index cf5e250bc78e..783a53fb7a4e 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -66,7 +66,7 @@ static int entry(u64 ip, struct unwind_info *ui)
66 if (__report_module(&al, ip, ui)) 66 if (__report_module(&al, ip, ui))
67 return -1; 67 return -1;
68 68
69 e->ip = ip; 69 e->ip = al.addr;
70 e->map = al.map; 70 e->map = al.map;
71 e->sym = al.sym; 71 e->sym = al.sym;
72 72
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 97c0f8fc5561..20c2e5743903 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -542,7 +542,7 @@ static int entry(u64 ip, struct thread *thread,
542 thread__find_addr_location(thread, PERF_RECORD_MISC_USER, 542 thread__find_addr_location(thread, PERF_RECORD_MISC_USER,
543 MAP__FUNCTION, ip, &al); 543 MAP__FUNCTION, ip, &al);
544 544
545 e.ip = ip; 545 e.ip = al.addr;
546 e.map = al.map; 546 e.map = al.map;
547 e.sym = al.sym; 547 e.sym = al.sym;
548 548
diff --git a/tools/virtio/linux/dma-mapping.h b/tools/virtio/linux/dma-mapping.h
index 4f93af89ae16..18601f6689b9 100644
--- a/tools/virtio/linux/dma-mapping.h
+++ b/tools/virtio/linux/dma-mapping.h
@@ -14,4 +14,20 @@ enum dma_data_direction {
14 DMA_NONE = 3, 14 DMA_NONE = 3,
15}; 15};
16 16
17#define dma_alloc_coherent(d, s, hp, f) ({ \
18 void *__dma_alloc_coherent_p = kmalloc((s), (f)); \
19 *(hp) = (unsigned long)__dma_alloc_coherent_p; \
20 __dma_alloc_coherent_p; \
21})
22
23#define dma_free_coherent(d, s, p, h) kfree(p)
24
25#define dma_map_page(d, p, o, s, dir) (page_to_phys(p) + (o))
26
27#define dma_map_single(d, p, s, dir) (virt_to_phys(p))
28#define dma_mapping_error(...) (0)
29
30#define dma_unmap_single(...) do { } while (0)
31#define dma_unmap_page(...) do { } while (0)
32
17#endif 33#endif
diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 033849948215..d9554fc3f340 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -20,7 +20,9 @@
20 20
21#define PAGE_SIZE getpagesize() 21#define PAGE_SIZE getpagesize()
22#define PAGE_MASK (~(PAGE_SIZE-1)) 22#define PAGE_MASK (~(PAGE_SIZE-1))
23#define PAGE_ALIGN(x) ((x + PAGE_SIZE - 1) & PAGE_MASK)
23 24
25typedef unsigned long long phys_addr_t;
24typedef unsigned long long dma_addr_t; 26typedef unsigned long long dma_addr_t;
25typedef size_t __kernel_size_t; 27typedef size_t __kernel_size_t;
26typedef unsigned int __wsum; 28typedef unsigned int __wsum;
@@ -57,6 +59,11 @@ static inline void *kzalloc(size_t s, gfp_t gfp)
57 return p; 59 return p;
58} 60}
59 61
62static inline void *alloc_pages_exact(size_t s, gfp_t gfp)
63{
64 return kmalloc(s, gfp);
65}
66
60static inline void kfree(void *p) 67static inline void kfree(void *p)
61{ 68{
62 if (p >= __kfree_ignore_start && p < __kfree_ignore_end) 69 if (p >= __kfree_ignore_start && p < __kfree_ignore_end)
@@ -64,6 +71,11 @@ static inline void kfree(void *p)
64 free(p); 71 free(p);
65} 72}
66 73
74static inline void free_pages_exact(void *p, size_t s)
75{
76 kfree(p);
77}
78
67static inline void *krealloc(void *p, size_t s, gfp_t gfp) 79static inline void *krealloc(void *p, size_t s, gfp_t gfp)
68{ 80{
69 return realloc(p, s); 81 return realloc(p, s);
@@ -105,6 +117,8 @@ static inline void free_page(unsigned long addr)
105#define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) 117#define dev_err(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
106#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__) 118#define dev_warn(dev, format, ...) fprintf (stderr, format, ## __VA_ARGS__)
107 119
120#define WARN_ON_ONCE(cond) ((cond) && fprintf (stderr, "WARNING\n"))
121
108#define min(x, y) ({ \ 122#define min(x, y) ({ \
109 typeof(x) _min1 = (x); \ 123 typeof(x) _min1 = (x); \
110 typeof(y) _min2 = (y); \ 124 typeof(y) _min2 = (y); \
diff --git a/tools/virtio/linux/slab.h b/tools/virtio/linux/slab.h
index 81baeac8ae40..7e1c1197d439 100644
--- a/tools/virtio/linux/slab.h
+++ b/tools/virtio/linux/slab.h
@@ -1,2 +1,6 @@
1#ifndef LINUX_SLAB_H 1#ifndef LINUX_SLAB_H
2#define GFP_KERNEL 0
3#define GFP_ATOMIC 0
4#define __GFP_NOWARN 0
5#define __GFP_ZERO 0
2#endif 6#endif
diff --git a/tools/virtio/linux/virtio.h b/tools/virtio/linux/virtio.h
index ee125e714053..9377c8b4ac16 100644
--- a/tools/virtio/linux/virtio.h
+++ b/tools/virtio/linux/virtio.h
@@ -3,8 +3,12 @@
3#include <linux/scatterlist.h> 3#include <linux/scatterlist.h>
4#include <linux/kernel.h> 4#include <linux/kernel.h>
5 5
6struct device {
7 void *parent;
8};
9
6struct virtio_device { 10struct virtio_device {
7 void *dev; 11 struct device dev;
8 u64 features; 12 u64 features;
9}; 13};
10 14
diff --git a/tools/virtio/linux/virtio_config.h b/tools/virtio/linux/virtio_config.h
index 57a6964a1e35..9ba11815e0a1 100644
--- a/tools/virtio/linux/virtio_config.h
+++ b/tools/virtio/linux/virtio_config.h
@@ -40,6 +40,19 @@ static inline void __virtio_clear_bit(struct virtio_device *vdev,
40#define virtio_has_feature(dev, feature) \ 40#define virtio_has_feature(dev, feature) \
41 (__virtio_test_bit((dev), feature)) 41 (__virtio_test_bit((dev), feature))
42 42
43/**
44 * virtio_has_iommu_quirk - determine whether this device has the iommu quirk
45 * @vdev: the device
46 */
47static inline bool virtio_has_iommu_quirk(const struct virtio_device *vdev)
48{
49 /*
50 * Note the reverse polarity of the quirk feature (compared to most
51 * other features), this is for compatibility with legacy systems.
52 */
53 return !virtio_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
54}
55
43static inline bool virtio_is_little_endian(struct virtio_device *vdev) 56static inline bool virtio_is_little_endian(struct virtio_device *vdev)
44{ 57{
45 return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) || 58 return virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||
diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c
index 68e4f9f0da3a..bd2ad1d3b7a9 100644
--- a/tools/virtio/ringtest/ptr_ring.c
+++ b/tools/virtio/ringtest/ptr_ring.c
@@ -13,6 +13,7 @@
13#define cache_line_size() SMP_CACHE_BYTES 13#define cache_line_size() SMP_CACHE_BYTES
14#define ____cacheline_aligned_in_smp __attribute__ ((aligned (SMP_CACHE_BYTES))) 14#define ____cacheline_aligned_in_smp __attribute__ ((aligned (SMP_CACHE_BYTES)))
15#define unlikely(x) (__builtin_expect(!!(x), 0)) 15#define unlikely(x) (__builtin_expect(!!(x), 0))
16#define likely(x) (__builtin_expect(!!(x), 1))
16#define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a)) 17#define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a))
17typedef pthread_spinlock_t spinlock_t; 18typedef pthread_spinlock_t spinlock_t;
18 19