From 21e1ebdc8e548f0db5fe5e2f90fb1cfc49cc53b0 Mon Sep 17 00:00:00 2001 From: Tarek BOCHKATI Date: Sun, 14 Feb 2021 12:39:33 +0100 Subject: [PATCH] armv8_dpm: do not read/write non-existent registers Change-Id: I0f3fffa8cf1746569f6acce0233e9544d3862f51 Signed-off-by: Tarek BOCHKATI Reviewed-on: http://openocd.zylin.com/6062 Tested-by: jenkins Reviewed-by: Antonio Borneo --- src/target/armv8_dpm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/target/armv8_dpm.c b/src/target/armv8_dpm.c index 6ef8c33de..b36ef835c 100644 --- a/src/target/armv8_dpm.c +++ b/src/target/armv8_dpm.c @@ -782,7 +782,7 @@ int armv8_dpm_read_current_registers(struct arm_dpm *dpm) struct arm_reg *arm_reg; r = armv8_reg_current(arm, i); - if (r->valid) + if (!r->exist || r->valid) continue; /* Skip reading FP-SIMD registers */ @@ -922,6 +922,9 @@ int armv8_dpm_write_dirty_registers(struct arm_dpm *dpm, bool bpwp) for (unsigned i = 1; i < cache->num_regs; i++) { struct arm_reg *r; + /* skip non-existent */ + if (!cache->reg_list[i].exist) + continue; /* skip PC and CPSR */ if (i == ARMV8_PC || i == ARMV8_xPSR) continue; @@ -1047,7 +1050,7 @@ static int armv8_dpm_full_context(struct target *target) for (unsigned i = 0; i < cache->num_regs; i++) { struct arm_reg *r; - if (cache->reg_list[i].valid) + if (!cache->reg_list[i].exist || cache->reg_list[i].valid) continue; r = cache->reg_list[i].arch_info;