Skip to content

Commit 77c281d

Browse files
committed
cortex_m: handle armv8m cores without security extension
Cores armv8m, e.g. Cortex-M33, can be instantiated without the optional Security Extension. In this case, the secure registers are not present and when GDB try accessing them it triggers a set of errors. For armv8m cores without security extension, don't provide to GDB the description of the secure registers. Change-Id: I254478a4cf883e85b786df3f62c726b2f40d88d9 Signed-off-by: Antonio Borneo <[email protected]> Reported-by: Torbjörn SVENSSON <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/7402 Tested-by: jenkins Reviewed-by: Tomas Vanek <[email protected]>
1 parent c913e4d commit 77c281d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/target/cortex_m.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,22 @@ static void cortex_m_dwt_free(struct target *target)
22702270
cm->dwt_cache = NULL;
22712271
}
22722272

2273+
static bool cortex_m_has_tz(struct target *target)
2274+
{
2275+
struct armv7m_common *armv7m = target_to_armv7m(target);
2276+
uint32_t dauthstatus;
2277+
2278+
if (armv7m->arm.arch != ARM_ARCH_V8M)
2279+
return false;
2280+
2281+
int retval = target_read_u32(target, DAUTHSTATUS, &dauthstatus);
2282+
if (retval != ERROR_OK) {
2283+
LOG_WARNING("Error reading DAUTHSTATUS register");
2284+
return false;
2285+
}
2286+
return (dauthstatus & DAUTHSTATUS_SID_MASK) != 0;
2287+
}
2288+
22732289
#define MVFR0 0xe000ef40
22742290
#define MVFR1 0xe000ef44
22752291

@@ -2398,7 +2414,7 @@ int cortex_m_examine(struct target *target)
23982414
for (size_t idx = ARMV7M_FPU_FIRST_REG; idx <= ARMV7M_FPU_LAST_REG; idx++)
23992415
armv7m->arm.core_cache->reg_list[idx].exist = false;
24002416

2401-
if (armv7m->arm.arch != ARM_ARCH_V8M)
2417+
if (!cortex_m_has_tz(target))
24022418
for (size_t idx = ARMV8M_FIRST_REG; idx <= ARMV8M_LAST_REG; idx++)
24032419
armv7m->arm.core_cache->reg_list[idx].exist = false;
24042420

src/target/cortex_m.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ struct cortex_m_part_info {
6868
#define DCB_DEMCR 0xE000EDFC
6969
#define DCB_DSCSR 0xE000EE08
7070

71+
#define DAUTHSTATUS 0xE000EFB8
72+
#define DAUTHSTATUS_SID_MASK 0x00000030
73+
7174
#define DCRSR_WNR BIT(16)
7275

7376
#define DWT_CTRL 0xE0001000

0 commit comments

Comments
 (0)