]> git.sur5r.net Git - openocd/commitdiff
armv7a: read ttbcr and ttb0/1 at every entry in debug state
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 12 Jul 2018 14:15:45 +0000 (16:15 +0200)
committerMatthias Welwarsky <matthias@welwarsky.de>
Sun, 22 Jul 2018 08:09:06 +0000 (09:09 +0100)
Commit bfc5c764df145f68835543119865eabe462e19c2 avoids reading
ttbcr and ttb0/1 at every virt2phys translation by caching them,
and it updates the cached values in armv7a_arch_state().
But the purpose of any (*arch_state)() method, thus including
armv7a_arch_state(), is to only print out and inform the user
about some architecture specific status.
Moreover, to reduce the verbosity during a GDB session, the
method (*arch_state)() is not executed anymore at debug state
entry (check use of target->verbose_halt_msg in src/openocd.c),
thus the state of translation table gets out-of-sync triggering
Error: Address translation failure
or even using a wrong address in the memory R/W operation.

In addition, the commit above breaks the case of armv7r by
calling armv7a_read_ttbcr() unconditionally.

Fixed by moving in cortex_a_post_debug_entry() the call to
armv7a_read_ttbcr() on armv7a case only.
Remove the call to armv7a_read_ttbcr() in armv7a_identify_cache()
since it is (conditionally) called only in the same procedure
cortex_a_post_debug_entry().

Fixes: bfc5c764df14 ("armv7a: cache ttbcr and ttb0/1 on debug
state entry")
Change-Id: Ifc20eca190111832e339a01b7f85d28c1547c8ba
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/4601
Tested-by: jenkins
Reviewed-by: Matthias Welwarsky <matthias@welwarsky.de>
src/target/armv7a.c
src/target/armv7a.h
src/target/cortex_a.c

index fab7363105c33c9f19a92d733c80eca87d9da1ae..eecfa70976af0ed0ff3ca50788965701c6af0796 100644 (file)
@@ -124,7 +124,7 @@ done:
        return retval;
 }
 
-static int armv7a_read_ttbcr(struct target *target)
+int armv7a_read_ttbcr(struct target *target)
 {
        struct armv7a_common *armv7a = target_to_armv7a(target);
        struct arm_dpm *dpm = armv7a->arm.dpm;
@@ -554,9 +554,6 @@ int armv7a_identify_cache(struct target *target)
        struct armv7a_cache_common *cache =
                &(armv7a->armv7a_mmu.armv7a_cache);
 
-       if (!armv7a->is_armv7r)
-               armv7a_read_ttbcr(target);
-
        retval = dpm->prepare(dpm);
        if (retval != ERROR_OK)
                goto done;
@@ -729,8 +726,6 @@ int armv7a_arch_state(struct target *target)
 
        arm_arch_state(target);
 
-       armv7a_read_ttbcr(target);
-
        if (armv7a->is_armv7r) {
                LOG_USER("D-Cache: %s, I-Cache: %s",
                        state[armv7a->armv7a_mmu.armv7a_cache.d_u_cache_enabled],
index 33f6f5dbea15c75aa23a110e7b9e8d5689db6e7d..57779c61ad8aec822bdb9dda6ddef19d87e55025 100644 (file)
@@ -194,6 +194,7 @@ int armv7a_mmu_translate_va(struct target *target,  uint32_t va, uint32_t *val);
 
 int armv7a_handle_cache_info_command(struct command_context *cmd_ctx,
                struct armv7a_cache_common *armv7a_cache);
+int armv7a_read_ttbcr(struct target *target);
 
 extern const struct command_registration armv7a_command_handlers[];
 
index 8985051ee8bbf5fee7088ccb10742abd7eb7bcaa..21ce4fae83ee9bc8e7c444a891bffcfc3e2df566 100644 (file)
@@ -1297,6 +1297,9 @@ static int cortex_a_post_debug_entry(struct target *target)
        LOG_DEBUG("cp15_control_reg: %8.8" PRIx32, cortex_a->cp15_control_reg);
        cortex_a->cp15_control_reg_curr = cortex_a->cp15_control_reg;
 
+       if (!armv7a->is_armv7r)
+               armv7a_read_ttbcr(target);
+
        if (armv7a->armv7a_mmu.armv7a_cache.info == -1)
                armv7a_identify_cache(target);