From: OpenOCD-Gerrit <ope...@us...> - 2022-11-15 21:33:39
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 69391878535ec584a472475ee9767b6beaaa138c (commit) from 1d04ef3e55843f9880b7bbab32f564d2018a4b93 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 69391878535ec584a472475ee9767b6beaaa138c Author: Tomas Vanek <va...@fb...> Date: Tue Oct 18 22:00:18 2022 +0200 target/armv7m: prevent saving and restoring non existent regs armv7m_start_algorithm() saves register values to arch_info->context. armv7m_wait_algorithm() restores register values from arch_info->context. Exclude registers with flag exist = false from both loops. While on it refactor the register restore: introduce 'struct reg' pointer and dereference it instead of numerous accesses by a full path from armv7m pointer. Change-Id: I1600084db84809ee13bcf8e7828b79f8c9ff9077 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/7276 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/armv7m.c b/src/target/armv7m.c index d9d01923a..d28702dd7 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -529,6 +529,9 @@ int armv7m_start_algorithm(struct target *target, /* Store all non-debug execution registers to armv7m_algorithm_info context */ for (unsigned i = 0; i < armv7m->arm.core_cache->num_regs; i++) { struct reg *reg = &armv7m->arm.core_cache->reg_list[i]; + if (!reg->exist) + continue; + if (!reg->valid) armv7m_get_core_reg(reg); @@ -688,16 +691,19 @@ int armv7m_wait_algorithm(struct target *target, } for (int i = armv7m->arm.core_cache->num_regs - 1; i >= 0; i--) { + struct reg *reg = &armv7m->arm.core_cache->reg_list[i]; + if (!reg->exist) + continue; + uint32_t regvalue; - regvalue = buf_get_u32(armv7m->arm.core_cache->reg_list[i].value, 0, 32); + regvalue = buf_get_u32(reg->value, 0, 32); if (regvalue != armv7m_algorithm_info->context[i]) { LOG_DEBUG("restoring register %s with value 0x%8.8" PRIx32, - armv7m->arm.core_cache->reg_list[i].name, - armv7m_algorithm_info->context[i]); - buf_set_u32(armv7m->arm.core_cache->reg_list[i].value, + reg->name, armv7m_algorithm_info->context[i]); + buf_set_u32(reg->value, 0, 32, armv7m_algorithm_info->context[i]); - armv7m->arm.core_cache->reg_list[i].valid = true; - armv7m->arm.core_cache->reg_list[i].dirty = true; + reg->valid = true; + reg->dirty = true; } } ----------------------------------------------------------------------- Summary of changes: src/target/armv7m.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) hooks/post-receive -- Main OpenOCD repository |