aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Leach <mike.leach@linaro.org>2020-09-11 09:32:12 +0100
committerMike Leach <mike.leach@linaro.org>2021-01-08 17:05:25 +0000
commit04f2511a862e1a605618d6b20e8965f885e2b90a (patch)
tree264550238cc2e5d73b1d9590c169acadf73cec91
parent8d5a02ac2cadb14c57afcd2d35248f57a3e88026 (diff)
downloadOpenCSD-04f2511a862e1a605618d6b20e8965f885e2b90a.tar.gz
opencsd: Handle WFIT, WFET instructions as branches
When WFI/WFE are traced as branch instructions in ETMv4, the new WFIT and WFET instructions from v8.7A and later are traced in the same manner. Option feature for arch v8.6A. Signed-off-by: Mike Leach <mike.leach@linaro.org>
-rw-r--r--decoder/include/i_dec/trc_idec_arminst.h2
-rw-r--r--decoder/source/i_dec/trc_i_decode.cpp10
-rw-r--r--decoder/source/i_dec/trc_idec_arminst.cpp10
3 files changed, 13 insertions, 9 deletions
diff --git a/decoder/include/i_dec/trc_idec_arminst.h b/decoder/include/i_dec/trc_idec_arminst.h
index f5f2454..4960df7 100644
--- a/decoder/include/i_dec/trc_idec_arminst.h
+++ b/decoder/include/i_dec/trc_idec_arminst.h
@@ -121,7 +121,7 @@ arm_barrier_t inst_A64_barrier(uint32_t inst);
int inst_ARM_wfiwfe(uint32_t inst);
int inst_Thumb_wfiwfe(uint32_t inst);
-int inst_A64_wfiwfe(uint32_t inst);
+int inst_A64_wfiwfe(uint32_t inst, struct decode_info *info);
/*
Test whether an instruction is definitely undefined, e.g. because
diff --git a/decoder/source/i_dec/trc_i_decode.cpp b/decoder/source/i_dec/trc_i_decode.cpp
index 2cf7f88..635b6c5 100644
--- a/decoder/source/i_dec/trc_i_decode.cpp
+++ b/decoder/source/i_dec/trc_i_decode.cpp
@@ -136,14 +136,12 @@ ocsd_err_t TrcIDecode::DecodeA64(ocsd_instr_info *instr_info, struct decode_info
if(inst_A64_is_indirect_branch_link(instr_info->opcode, &instr_info->is_link, info))
{
instr_info->type = OCSD_INSTR_BR_INDIRECT;
-// instr_info->is_link = inst_A64_is_branch_and_link(instr_info->opcode);
}
else if(inst_A64_is_direct_branch_link(instr_info->opcode, &instr_info->is_link, info))
{
inst_A64_branch_destination(instr_info->instr_addr,instr_info->opcode,&branchAddr);
instr_info->type = OCSD_INSTR_BR;
instr_info->branch_addr = (ocsd_vaddr_t)branchAddr;
-// instr_info->is_link = inst_A64_is_branch_and_link(instr_info->opcode);
}
else if((barrier = inst_A64_barrier(instr_info->opcode)) != ARM_BARRIER_NONE)
{
@@ -160,12 +158,10 @@ ocsd_err_t TrcIDecode::DecodeA64(ocsd_instr_info *instr_info, struct decode_info
break;
}
}
- else if (instr_info->wfi_wfe_branch)
+ else if (instr_info->wfi_wfe_branch &&
+ inst_A64_wfiwfe(instr_info->opcode, info))
{
- if (inst_A64_wfiwfe(instr_info->opcode))
- {
- instr_info->type = OCSD_INSTR_WFI_WFE;
- }
+ instr_info->type = OCSD_INSTR_WFI_WFE;
}
instr_info->is_conditional = inst_A64_is_conditional(instr_info->opcode);
diff --git a/decoder/source/i_dec/trc_idec_arminst.cpp b/decoder/source/i_dec/trc_idec_arminst.cpp
index 00c0722..c83f6d1 100644
--- a/decoder/source/i_dec/trc_idec_arminst.cpp
+++ b/decoder/source/i_dec/trc_idec_arminst.cpp
@@ -258,11 +258,19 @@ int inst_A64_is_direct_branch_link(uint32_t inst, uint8_t *is_link, struct decod
return is_direct_branch;
}
-int inst_A64_wfiwfe(uint32_t inst)
+int inst_A64_wfiwfe(uint32_t inst, struct decode_info *info)
{
/* WFI, WFE may be traced as branches in etm 4.3++ */
if ((inst & 0xffffffdf) == 0xd503205f)
return 1;
+
+ /* new feature introduced post v8.3 */
+ if (OCSD_IS_ARCH_MINVER(info->arch_version, ARCH_AA64))
+ {
+ /* WFIT / WFET for later archs */
+ if ((inst & 0xffffffc0) == 0xd5031000)
+ return 1;
+ }
return 0;
}