Commit 4c761d80 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf intel-pt: Fix intel_pt_fup_event() assumptions about setting state type

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: a472e65f ("perf intel-pt: Add decoder support for ptwrite and power event packets")
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org # v5.15+
Link: https://lore.kernel.org/r/20211210162303.2288710-4-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent ad106a26
...@@ -1205,61 +1205,55 @@ static int intel_pt_walk_insn(struct intel_pt_decoder *decoder, ...@@ -1205,61 +1205,55 @@ static int intel_pt_walk_insn(struct intel_pt_decoder *decoder,
static bool intel_pt_fup_event(struct intel_pt_decoder *decoder) static bool intel_pt_fup_event(struct intel_pt_decoder *decoder)
{ {
enum intel_pt_sample_type type = decoder->state.type;
bool ret = false; bool ret = false;
decoder->state.type &= ~INTEL_PT_BRANCH;
if (decoder->set_fup_tx_flags) { if (decoder->set_fup_tx_flags) {
decoder->set_fup_tx_flags = false; decoder->set_fup_tx_flags = false;
decoder->tx_flags = decoder->fup_tx_flags; 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) if (decoder->fup_tx_flags & INTEL_PT_ABORT_TX)
decoder->state.type |= INTEL_PT_BRANCH; decoder->state.type |= INTEL_PT_BRANCH;
decoder->state.from_ip = decoder->ip;
decoder->state.to_ip = 0;
decoder->state.flags = decoder->fup_tx_flags; decoder->state.flags = decoder->fup_tx_flags;
return true; ret = true;
} }
if (decoder->set_fup_ptw) { if (decoder->set_fup_ptw) {
decoder->set_fup_ptw = false; 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.flags |= INTEL_PT_FUP_IP;
decoder->state.from_ip = decoder->ip;
decoder->state.to_ip = 0;
decoder->state.ptw_payload = decoder->fup_ptw_payload; decoder->state.ptw_payload = decoder->fup_ptw_payload;
return true; ret = true;
} }
if (decoder->set_fup_mwait) { if (decoder->set_fup_mwait) {
decoder->set_fup_mwait = false; decoder->set_fup_mwait = false;
decoder->state.type = INTEL_PT_MWAIT_OP; decoder->state.type |= INTEL_PT_MWAIT_OP;
decoder->state.from_ip = decoder->ip;
decoder->state.to_ip = 0;
decoder->state.mwait_payload = decoder->fup_mwait_payload; decoder->state.mwait_payload = decoder->fup_mwait_payload;
ret = true; ret = true;
} }
if (decoder->set_fup_pwre) { if (decoder->set_fup_pwre) {
decoder->set_fup_pwre = false; decoder->set_fup_pwre = false;
decoder->state.type |= INTEL_PT_PWR_ENTRY; 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; decoder->state.pwre_payload = decoder->fup_pwre_payload;
ret = true; ret = true;
} }
if (decoder->set_fup_exstop) { if (decoder->set_fup_exstop) {
decoder->set_fup_exstop = false; decoder->set_fup_exstop = false;
decoder->state.type |= INTEL_PT_EX_STOP; decoder->state.type |= INTEL_PT_EX_STOP;
decoder->state.type &= ~INTEL_PT_BRANCH;
decoder->state.flags |= INTEL_PT_FUP_IP; decoder->state.flags |= INTEL_PT_FUP_IP;
decoder->state.from_ip = decoder->ip;
decoder->state.to_ip = 0;
ret = true; ret = true;
} }
if (decoder->set_fup_bep) { if (decoder->set_fup_bep) {
decoder->set_fup_bep = false; decoder->set_fup_bep = false;
decoder->state.type |= INTEL_PT_BLK_ITEMS; 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.from_ip = decoder->ip;
decoder->state.to_ip = 0; decoder->state.to_ip = 0;
ret = true; } else {
decoder->state.type = type;
} }
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment