Skip to content

Commit 4643b05

Browse files
committed
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar. * 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86: Handle failures of parsing immediate operands in the instruction decoder perf archive: Correct cutting of symbolic link perf tools: Ignore auto-generated bison/flex files perf tools: Fix parsers' rules to dependencies perf tools: fix NO_GTK2 Makefile config error perf session: Skip event correctly for unknown id/machine
2 parents cdd5983 + 6c7b8e8 commit 4643b05

File tree

5 files changed

+51
-32
lines changed

5 files changed

+51
-32
lines changed

arch/x86/lib/insn.c

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,8 @@ void insn_get_displacement(struct insn *insn)
379379
return;
380380
}
381381

382-
/* Decode moffset16/32/64 */
383-
static void __get_moffset(struct insn *insn)
382+
/* Decode moffset16/32/64. Return 0 if failed */
383+
static int __get_moffset(struct insn *insn)
384384
{
385385
switch (insn->addr_bytes) {
386386
case 2:
@@ -397,15 +397,19 @@ static void __get_moffset(struct insn *insn)
397397
insn->moffset2.value = get_next(int, insn);
398398
insn->moffset2.nbytes = 4;
399399
break;
400+
default: /* opnd_bytes must be modified manually */
401+
goto err_out;
400402
}
401403
insn->moffset1.got = insn->moffset2.got = 1;
402404

405+
return 1;
406+
403407
err_out:
404-
return;
408+
return 0;
405409
}
406410

407-
/* Decode imm v32(Iz) */
408-
static void __get_immv32(struct insn *insn)
411+
/* Decode imm v32(Iz). Return 0 if failed */
412+
static int __get_immv32(struct insn *insn)
409413
{
410414
switch (insn->opnd_bytes) {
411415
case 2:
@@ -417,14 +421,18 @@ static void __get_immv32(struct insn *insn)
417421
insn->immediate.value = get_next(int, insn);
418422
insn->immediate.nbytes = 4;
419423
break;
424+
default: /* opnd_bytes must be modified manually */
425+
goto err_out;
420426
}
421427

428+
return 1;
429+
422430
err_out:
423-
return;
431+
return 0;
424432
}
425433

426-
/* Decode imm v64(Iv/Ov) */
427-
static void __get_immv(struct insn *insn)
434+
/* Decode imm v64(Iv/Ov), Return 0 if failed */
435+
static int __get_immv(struct insn *insn)
428436
{
429437
switch (insn->opnd_bytes) {
430438
case 2:
@@ -441,15 +449,18 @@ static void __get_immv(struct insn *insn)
441449
insn->immediate2.value = get_next(int, insn);
442450
insn->immediate2.nbytes = 4;
443451
break;
452+
default: /* opnd_bytes must be modified manually */
453+
goto err_out;
444454
}
445455
insn->immediate1.got = insn->immediate2.got = 1;
446456

457+
return 1;
447458
err_out:
448-
return;
459+
return 0;
449460
}
450461

451462
/* Decode ptr16:16/32(Ap) */
452-
static void __get_immptr(struct insn *insn)
463+
static int __get_immptr(struct insn *insn)
453464
{
454465
switch (insn->opnd_bytes) {
455466
case 2:
@@ -462,14 +473,17 @@ static void __get_immptr(struct insn *insn)
462473
break;
463474
case 8:
464475
/* ptr16:64 is not exist (no segment) */
465-
return;
476+
return 0;
477+
default: /* opnd_bytes must be modified manually */
478+
goto err_out;
466479
}
467480
insn->immediate2.value = get_next(unsigned short, insn);
468481
insn->immediate2.nbytes = 2;
469482
insn->immediate1.got = insn->immediate2.got = 1;
470483

484+
return 1;
471485
err_out:
472-
return;
486+
return 0;
473487
}
474488

475489
/**
@@ -489,7 +503,8 @@ void insn_get_immediate(struct insn *insn)
489503
insn_get_displacement(insn);
490504

491505
if (inat_has_moffset(insn->attr)) {
492-
__get_moffset(insn);
506+
if (!__get_moffset(insn))
507+
goto err_out;
493508
goto done;
494509
}
495510

@@ -517,16 +532,20 @@ void insn_get_immediate(struct insn *insn)
517532
insn->immediate2.nbytes = 4;
518533
break;
519534
case INAT_IMM_PTR:
520-
__get_immptr(insn);
535+
if (!__get_immptr(insn))
536+
goto err_out;
521537
break;
522538
case INAT_IMM_VWORD32:
523-
__get_immv32(insn);
539+
if (!__get_immv32(insn))
540+
goto err_out;
524541
break;
525542
case INAT_IMM_VWORD:
526-
__get_immv(insn);
543+
if (!__get_immv(insn))
544+
goto err_out;
527545
break;
528546
default:
529-
break;
547+
/* Here, insn must have an immediate, but failed */
548+
goto err_out;
530549
}
531550
if (inat_has_second_immediate(insn->attr)) {
532551
insn->immediate2.value = get_next(char, insn);

tools/perf/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ TAGS
1919
cscope*
2020
config.mak
2121
config.mak.autogen
22+
*-bison.*
23+
*-flex.*

tools/perf/Makefile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -237,21 +237,20 @@ export PERL_PATH
237237
FLEX = $(CROSS_COMPILE)flex
238238
BISON= $(CROSS_COMPILE)bison
239239

240-
event-parser:
241-
$(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o $(OUTPUT)util/parse-events-bison.c
240+
$(OUTPUT)util/parse-events-flex.c: util/parse-events.l
242241
$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/parse-events-flex.h -t util/parse-events.l > $(OUTPUT)util/parse-events-flex.c
243242

244-
$(OUTPUT)util/parse-events-flex.c: event-parser
245-
$(OUTPUT)util/parse-events-bison.c: event-parser
243+
$(OUTPUT)util/parse-events-bison.c: util/parse-events.y
244+
$(QUIET_BISON)$(BISON) -v util/parse-events.y -d -o $(OUTPUT)util/parse-events-bison.c
246245

247-
pmu-parser:
248-
$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
246+
$(OUTPUT)util/pmu-flex.c: util/pmu.l
249247
$(QUIET_FLEX)$(FLEX) --header-file=$(OUTPUT)util/pmu-flex.h -t util/pmu.l > $(OUTPUT)util/pmu-flex.c
250248

251-
$(OUTPUT)util/pmu-flex.c: pmu-parser
252-
$(OUTPUT)util/pmu-bison.c: pmu-parser
249+
$(OUTPUT)util/pmu-bison.c: util/pmu.y
250+
$(QUIET_BISON)$(BISON) -v util/pmu.y -d -o $(OUTPUT)util/pmu-bison.c
253251

254-
$(OUTPUT)util/parse-events.o: event-parser pmu-parser
252+
$(OUTPUT)util/parse-events.o: $(OUTPUT)util/parse-events-flex.c $(OUTPUT)util/parse-events-bison.c
253+
$(OUTPUT)util/pmu.o: $(OUTPUT)util/pmu-flex.c $(OUTPUT)util/pmu-bison.c
255254

256255
LIB_FILE=$(OUTPUT)libperf.a
257256

@@ -527,7 +526,7 @@ else
527526
endif
528527

529528
ifdef NO_GTK2
530-
BASIC_CFLAGS += -DNO_GTK2
529+
BASIC_CFLAGS += -DNO_GTK2_SUPPORT
531530
else
532531
FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0)
533532
ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y)
@@ -852,8 +851,6 @@ help:
852851
@echo ' html - make html documentation'
853852
@echo ' info - make GNU info documentation (access with info <foo>)'
854853
@echo ' pdf - make pdf documentation'
855-
@echo ' event-parser - make event parser code'
856-
@echo ' pmu-parser - make pmu format parser code'
857854
@echo ' TAGS - use etags to make tag information for source browsing'
858855
@echo ' tags - use ctags to make tag information for source browsing'
859856
@echo ' cscope - use cscope to make interactive browsing database'

tools/perf/perf-archive.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ if [ ! -s $BUILDIDS ] ; then
2929
fi
3030

3131
MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
32+
PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
3233

3334
cut -d ' ' -f 1 $BUILDIDS | \
3435
while read build_id ; do
3536
linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
3637
filename=$(readlink -f $linkname)
3738
echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
38-
echo ${filename#$PERF_BUILDID_DIR} >> $MANIFEST
39+
echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
3940
done
4041

4142
tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST

tools/perf/util/session.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,11 +876,11 @@ static int perf_session_deliver_event(struct perf_session *session,
876876
dump_sample(session, event, sample);
877877
if (evsel == NULL) {
878878
++session->hists.stats.nr_unknown_id;
879-
return -1;
879+
return 0;
880880
}
881881
if (machine == NULL) {
882882
++session->hists.stats.nr_unprocessable_samples;
883-
return -1;
883+
return 0;
884884
}
885885
return tool->sample(tool, event, sample, evsel, machine);
886886
case PERF_RECORD_MMAP:

0 commit comments

Comments
 (0)