From: Greg Kroah-Hartman Date: Thu, 21 Mar 2019 10:24:14 +0000 (+0100) Subject: 4.9-stable patches X-Git-Tag: v3.18.137~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fd9f5f6f1515680bf94a361117620188a1b7c243;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: md-fix-failed-allocation-of-md_register_thread.patch perf-auxtrace-define-auxtrace-record-alignment.patch perf-intel-pt-fix-cyc-timestamp-calculation-after-ovf.patch perf-intel-pt-fix-divide-by-zero-when-tsc-is-not-available.patch perf-intel-pt-fix-overlap-calculation-for-padding.patch --- diff --git a/queue-4.9/md-fix-failed-allocation-of-md_register_thread.patch b/queue-4.9/md-fix-failed-allocation-of-md_register_thread.patch new file mode 100644 index 00000000000..fbaeef4b0fd --- /dev/null +++ b/queue-4.9/md-fix-failed-allocation-of-md_register_thread.patch @@ -0,0 +1,49 @@ +From e406f12dde1a8375d77ea02d91f313fb1a9c6aec Mon Sep 17 00:00:00 2001 +From: Aditya Pakki +Date: Mon, 4 Mar 2019 16:48:54 -0600 +Subject: md: Fix failed allocation of md_register_thread + +From: Aditya Pakki + +commit e406f12dde1a8375d77ea02d91f313fb1a9c6aec upstream. + +mddev->sync_thread can be set to NULL on kzalloc failure downstream. +The patch checks for such a scenario and frees allocated resources. + +Committer node: + +Added similar fix to raid5.c, as suggested by Guoqing. + +Cc: stable@vger.kernel.org # v3.16+ +Acked-by: Guoqing Jiang +Signed-off-by: Aditya Pakki +Signed-off-by: Song Liu +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/md/raid10.c | 2 ++ + drivers/md/raid5.c | 2 ++ + 2 files changed, 4 insertions(+) + +--- a/drivers/md/raid10.c ++++ b/drivers/md/raid10.c +@@ -3798,6 +3798,8 @@ static int raid10_run(struct mddev *mdde + set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); + mddev->sync_thread = md_register_thread(md_do_sync, mddev, + "reshape"); ++ if (!mddev->sync_thread) ++ goto out_free_conf; + } + + return 0; +--- a/drivers/md/raid5.c ++++ b/drivers/md/raid5.c +@@ -6977,6 +6977,8 @@ static int raid5_run(struct mddev *mddev + set_bit(MD_RECOVERY_RUNNING, &mddev->recovery); + mddev->sync_thread = md_register_thread(md_do_sync, mddev, + "reshape"); ++ if (!mddev->sync_thread) ++ goto abort; + } + + /* Ok, everything is just fine now */ diff --git a/queue-4.9/perf-auxtrace-define-auxtrace-record-alignment.patch b/queue-4.9/perf-auxtrace-define-auxtrace-record-alignment.patch new file mode 100644 index 00000000000..247e584c71e --- /dev/null +++ b/queue-4.9/perf-auxtrace-define-auxtrace-record-alignment.patch @@ -0,0 +1,52 @@ +From c3fcadf0bb765faf45d6d562246e1d08885466df Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Wed, 6 Feb 2019 12:39:43 +0200 +Subject: perf auxtrace: Define auxtrace record alignment + +From: Adrian Hunter + +commit c3fcadf0bb765faf45d6d562246e1d08885466df upstream. + +Define auxtrace record alignment so that it can be referenced elsewhere. + +Note this is preparation for patch "perf intel-pt: Fix overlap calculation +for padding" + +Signed-off-by: Adrian Hunter +Cc: Jiri Olsa +Cc: stable@vger.kernel.org +Link: http://lkml.kernel.org/r/20190206103947.15750-2-adrian.hunter@intel.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/util/auxtrace.c | 4 ++-- + tools/perf/util/auxtrace.h | 3 +++ + 2 files changed, 5 insertions(+), 2 deletions(-) + +--- a/tools/perf/util/auxtrace.c ++++ b/tools/perf/util/auxtrace.c +@@ -1244,9 +1244,9 @@ static int __auxtrace_mmap__read(struct + } + + /* padding must be written by fn() e.g. record__process_auxtrace() */ +- padding = size & 7; ++ padding = size & (PERF_AUXTRACE_RECORD_ALIGNMENT - 1); + if (padding) +- padding = 8 - padding; ++ padding = PERF_AUXTRACE_RECORD_ALIGNMENT - padding; + + memset(&ev, 0, sizeof(ev)); + ev.auxtrace.header.type = PERF_RECORD_AUXTRACE; +--- a/tools/perf/util/auxtrace.h ++++ b/tools/perf/util/auxtrace.h +@@ -37,6 +37,9 @@ struct record_opts; + struct auxtrace_info_event; + struct events_stats; + ++/* Auxtrace records must have the same alignment as perf event records */ ++#define PERF_AUXTRACE_RECORD_ALIGNMENT 8 ++ + enum auxtrace_type { + PERF_AUXTRACE_UNKNOWN, + PERF_AUXTRACE_INTEL_PT, diff --git a/queue-4.9/perf-intel-pt-fix-cyc-timestamp-calculation-after-ovf.patch b/queue-4.9/perf-intel-pt-fix-cyc-timestamp-calculation-after-ovf.patch new file mode 100644 index 00000000000..c060d42d118 --- /dev/null +++ b/queue-4.9/perf-intel-pt-fix-cyc-timestamp-calculation-after-ovf.patch @@ -0,0 +1,36 @@ +From 03997612904866abe7cdcc992784ef65cb3a4b81 Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Wed, 6 Feb 2019 12:39:45 +0200 +Subject: perf intel-pt: Fix CYC timestamp calculation after OVF + +From: Adrian Hunter + +commit 03997612904866abe7cdcc992784ef65cb3a4b81 upstream. + +CYC packet timestamp calculation depends upon CBR which was being +cleared upon overflow (OVF). That can cause errors due to failing to +synchronize with sideband events. Even if a CBR change has been lost, +the old CBR is still a better estimate than zero. So remove the clearing +of CBR. + +Signed-off-by: Adrian Hunter +Cc: Jiri Olsa +Cc: stable@vger.kernel.org +Link: http://lkml.kernel.org/r/20190206103947.15750-4-adrian.hunter@intel.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 1 - + 1 file changed, 1 deletion(-) + +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +@@ -1311,7 +1311,6 @@ static int intel_pt_overflow(struct inte + { + intel_pt_log("ERROR: Buffer overflow\n"); + intel_pt_clear_tx_flags(decoder); +- decoder->cbr = 0; + decoder->timestamp_insn_cnt = 0; + decoder->pkt_state = INTEL_PT_STATE_ERR_RESYNC; + decoder->overflow = true; diff --git a/queue-4.9/perf-intel-pt-fix-divide-by-zero-when-tsc-is-not-available.patch b/queue-4.9/perf-intel-pt-fix-divide-by-zero-when-tsc-is-not-available.patch new file mode 100644 index 00000000000..4329ba5ea89 --- /dev/null +++ b/queue-4.9/perf-intel-pt-fix-divide-by-zero-when-tsc-is-not-available.patch @@ -0,0 +1,36 @@ +From 076333870c2f5bdd9b6d31e7ca1909cf0c84cbfa Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Fri, 1 Mar 2019 12:35:36 +0200 +Subject: perf intel-pt: Fix divide by zero when TSC is not available + +From: Adrian Hunter + +commit 076333870c2f5bdd9b6d31e7ca1909cf0c84cbfa upstream. + +When TSC is not available, "timeless" decoding is used but a divide by +zero occurs if perf_time_to_tsc() is called. + +Ensure the divisor is not zero. + +Signed-off-by: Adrian Hunter +Cc: Jiri Olsa +Cc: stable@vger.kernel.org # v4.9+ +Link: https://lkml.kernel.org/n/tip-1i4j0wqoc8vlbkcizqqxpsf4@git.kernel.org +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/util/intel-pt.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/tools/perf/util/intel-pt.c ++++ b/tools/perf/util/intel-pt.c +@@ -2259,6 +2259,8 @@ int intel_pt_process_auxtrace_info(union + } + + pt->timeless_decoding = intel_pt_timeless_decoding(pt); ++ if (pt->timeless_decoding && !pt->tc.time_mult) ++ pt->tc.time_mult = 1; + pt->have_tsc = intel_pt_have_tsc(pt); + pt->sampling_mode = false; + pt->est_tsc = !pt->timeless_decoding; diff --git a/queue-4.9/perf-intel-pt-fix-overlap-calculation-for-padding.patch b/queue-4.9/perf-intel-pt-fix-overlap-calculation-for-padding.patch new file mode 100644 index 00000000000..211a68ed303 --- /dev/null +++ b/queue-4.9/perf-intel-pt-fix-overlap-calculation-for-padding.patch @@ -0,0 +1,90 @@ +From 5a99d99e3310a565b0cf63f785b347be9ee0da45 Mon Sep 17 00:00:00 2001 +From: Adrian Hunter +Date: Wed, 6 Feb 2019 12:39:44 +0200 +Subject: perf intel-pt: Fix overlap calculation for padding + +From: Adrian Hunter + +commit 5a99d99e3310a565b0cf63f785b347be9ee0da45 upstream. + +Auxtrace records might have up to 7 bytes of padding appended. Adjust +the overlap accordingly. + +Signed-off-by: Adrian Hunter +Cc: Jiri Olsa +Cc: stable@vger.kernel.org +Link: http://lkml.kernel.org/r/20190206103947.15750-3-adrian.hunter@intel.com +Signed-off-by: Arnaldo Carvalho de Melo +Signed-off-by: Greg Kroah-Hartman + +--- + tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 36 ++++++++++++++++++-- + 1 file changed, 34 insertions(+), 2 deletions(-) + +--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c ++++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +@@ -26,6 +26,7 @@ + + #include "../cache.h" + #include "../util.h" ++#include "../auxtrace.h" + + #include "intel-pt-insn-decoder.h" + #include "intel-pt-pkt-decoder.h" +@@ -2350,6 +2351,34 @@ static int intel_pt_tsc_cmp(uint64_t tsc + } + } + ++#define MAX_PADDING (PERF_AUXTRACE_RECORD_ALIGNMENT - 1) ++ ++/** ++ * adj_for_padding - adjust overlap to account for padding. ++ * @buf_b: second buffer ++ * @buf_a: first buffer ++ * @len_a: size of first buffer ++ * ++ * @buf_a might have up to 7 bytes of padding appended. Adjust the overlap ++ * accordingly. ++ * ++ * Return: A pointer into @buf_b from where non-overlapped data starts ++ */ ++static unsigned char *adj_for_padding(unsigned char *buf_b, ++ unsigned char *buf_a, size_t len_a) ++{ ++ unsigned char *p = buf_b - MAX_PADDING; ++ unsigned char *q = buf_a + len_a - MAX_PADDING; ++ int i; ++ ++ for (i = MAX_PADDING; i; i--, p++, q++) { ++ if (*p != *q) ++ break; ++ } ++ ++ return p; ++} ++ + /** + * intel_pt_find_overlap_tsc - determine start of non-overlapped trace data + * using TSC. +@@ -2400,8 +2429,11 @@ static unsigned char *intel_pt_find_over + + /* Same TSC, so buffers are consecutive */ + if (!cmp && rem_b >= rem_a) { ++ unsigned char *start; ++ + *consecutive = true; +- return buf_b + len_b - (rem_b - rem_a); ++ start = buf_b + len_b - (rem_b - rem_a); ++ return adj_for_padding(start, buf_a, len_a); + } + if (cmp < 0) + return buf_b; /* tsc_a < tsc_b => no overlap */ +@@ -2464,7 +2496,7 @@ unsigned char *intel_pt_find_overlap(uns + found = memmem(buf_a, len_a, buf_b, len_a); + if (found) { + *consecutive = true; +- return buf_b + len_a; ++ return adj_for_padding(buf_b + len_a, buf_a, len_a); + } + + /* Try again at next PSB in buffer 'a' */ diff --git a/queue-4.9/series b/queue-4.9/series index 3722c05a3cf..0f802a7bcae 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -105,3 +105,8 @@ nfsd-fix-memory-corruption-caused-by-readdir.patch nfsd-fix-wrong-check-in-write_v4_end_grace.patch pm-wakeup-rework-wakeup-source-timer-cancellation.patch bcache-never-writeback-a-discard-operation.patch +perf-intel-pt-fix-cyc-timestamp-calculation-after-ovf.patch +perf-auxtrace-define-auxtrace-record-alignment.patch +perf-intel-pt-fix-overlap-calculation-for-padding.patch +perf-intel-pt-fix-divide-by-zero-when-tsc-is-not-available.patch +md-fix-failed-allocation-of-md_register_thread.patch