This is an automated email from Gerrit. "Tomas Vanek <van...@fbl.cz>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/7240
-- gerrit commit 94e1597dc1d6666314434f8cd97bd98a512427db Author: Tomas Vanek <van...@fbl.cz> Date: Sun Oct 2 09:30:50 2022 +0200 target/armv7m: prevent storing invalid register armv7m_start_algorithm() stored all non-debug execution registers from register cache without checking validity. Check if the register cache is valid. Try to read from CPU if not valid. Issue a warning if register read fails. Change-Id: I365f86d65243230cf521b13909575e5986a87a50 Signed-off-by: Tomas Vanek <van...@fbl.cz> diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 2db2ce2dd5..6f6a170b70 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -528,11 +528,14 @@ 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->valid) + armv7m_get_core_reg(reg); - armv7m_algorithm_info->context[i] = buf_get_u32( - armv7m->arm.core_cache->reg_list[i].value, - 0, - 32); + if (!reg->valid) + LOG_TARGET_WARNING(target, "Storing invalid register %s", reg->name); + + armv7m_algorithm_info->context[i] = buf_get_u32(reg->value, 0, 32); } for (int i = 0; i < num_mem_params; i++) { --