This is a note to let you know that I've just added the patch titled perf intel-pt: Fix intel_pt_fup_event() assumptions about setting state type to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: perf-intel-pt-fix-intel_pt_fup_event-assumptions-about-setting-state-type.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Wed Dec 15 02:59:52 PM CET 2021 From: Adrian Hunter <adrian.hunter@xxxxxxxxx> Date: Mon, 13 Dec 2021 17:45:44 +0200 Subject: perf intel-pt: Fix intel_pt_fup_event() assumptions about setting state type To: stable@xxxxxxxxxxxxxxx Message-ID: <20211213154548.122728-5-adrian.hunter@xxxxxxxxx> From: Adrian Hunter <adrian.hunter@xxxxxxxxx> commit 4c761d805bb2d2ead1b9baaba75496152b394c80 upstream. intel_pt_fup_event() assumes it can overwrite the state type if there has been an FUP event, but this is an unnecessary and unexpected constraint on callers. Fix by touching only the state type flags that are affected by an FUP event. Fixes: a472e65fc490a ("perf intel-pt: Add decoder support for ptwrite and power event packets") Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: stable@xxxxxxxxxxxxxxx # v5.15+ Link: https://lore.kernel.org/r/20211210162303.2288710-4-adrian.hunter@xxxxxxxxx Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> [Adrian: Backport to v5.10] Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 32 ++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c @@ -1114,61 +1114,55 @@ out_no_progress: static bool intel_pt_fup_event(struct intel_pt_decoder *decoder) { + enum intel_pt_sample_type type = decoder->state.type; bool ret = false; + decoder->state.type &= ~INTEL_PT_BRANCH; + if (decoder->set_fup_tx_flags) { decoder->set_fup_tx_flags = false; decoder->tx_flags = decoder->fup_tx_flags; - decoder->state.type = INTEL_PT_TRANSACTION; + decoder->state.type |= INTEL_PT_TRANSACTION; if (decoder->fup_tx_flags & INTEL_PT_ABORT_TX) decoder->state.type |= INTEL_PT_BRANCH; - decoder->state.from_ip = decoder->ip; - decoder->state.to_ip = 0; decoder->state.flags = decoder->fup_tx_flags; - return true; + ret = true; } if (decoder->set_fup_ptw) { decoder->set_fup_ptw = false; - decoder->state.type = INTEL_PT_PTW; + decoder->state.type |= INTEL_PT_PTW; decoder->state.flags |= INTEL_PT_FUP_IP; - decoder->state.from_ip = decoder->ip; - decoder->state.to_ip = 0; decoder->state.ptw_payload = decoder->fup_ptw_payload; - return true; + ret = true; } if (decoder->set_fup_mwait) { decoder->set_fup_mwait = false; - decoder->state.type = INTEL_PT_MWAIT_OP; - decoder->state.from_ip = decoder->ip; - decoder->state.to_ip = 0; + decoder->state.type |= INTEL_PT_MWAIT_OP; decoder->state.mwait_payload = decoder->fup_mwait_payload; ret = true; } if (decoder->set_fup_pwre) { decoder->set_fup_pwre = false; decoder->state.type |= INTEL_PT_PWR_ENTRY; - decoder->state.type &= ~INTEL_PT_BRANCH; - decoder->state.from_ip = decoder->ip; - decoder->state.to_ip = 0; decoder->state.pwre_payload = decoder->fup_pwre_payload; ret = true; } if (decoder->set_fup_exstop) { decoder->set_fup_exstop = false; decoder->state.type |= INTEL_PT_EX_STOP; - decoder->state.type &= ~INTEL_PT_BRANCH; decoder->state.flags |= INTEL_PT_FUP_IP; - decoder->state.from_ip = decoder->ip; - decoder->state.to_ip = 0; ret = true; } if (decoder->set_fup_bep) { decoder->set_fup_bep = false; decoder->state.type |= INTEL_PT_BLK_ITEMS; - decoder->state.type &= ~INTEL_PT_BRANCH; + ret = true; + } + if (ret) { decoder->state.from_ip = decoder->ip; decoder->state.to_ip = 0; - ret = true; + } else { + decoder->state.type = type; } return ret; } Patches currently in stable-queue which might be from adrian.hunter@xxxxxxxxx are queue-5.10/perf-intel-pt-fix-some-pge-packet-generation-enable-control-flow-packets-usage.patch queue-5.10/perf-intel-pt-fix-intel_pt_fup_event-assumptions-about-setting-state-type.patch queue-5.10/perf-intel-pt-fix-next-err-value-walking-trace.patch queue-5.10/perf-intel-pt-fix-error-timestamp-setting-on-the-decoder-error-path.patch queue-5.10/perf-intel-pt-fix-state-setting-when-receiving-overflow-ovf-packet.patch queue-5.10/perf-intel-pt-fix-sync-state-when-a-psb-synchronization-packet-is-found.patch queue-5.10/perf-inject-fix-itrace-space-allowed-for-new-attributes.patch queue-5.10/perf-intel-pt-fix-missing-instruction-events-with-q-option.patch