]> git.sur5r.net Git - openocd/commitdiff
aarch64: fix armv8_set_core_reg when destination is cpsr
authorMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Fri, 16 Sep 2016 13:36:09 +0000 (15:36 +0200)
committerMatthias Welwarsky <matthias.welwarsky@sysgo.com>
Fri, 10 Feb 2017 13:01:39 +0000 (14:01 +0100)
When armv8_set_core_reg is used to set the value of
the CPSR, also update the internal architecture state.

Change-Id: I5f6a2be6fde8d91ec3352d8ba23c4aa90eb02977
Signed-off-by: Matthias Welwarsky <matthias.welwarsky@sysgo.com>
src/target/armv8.c

index 176c7adfde1d3439fd6b28da4e84ae784b8266a3..ad06796315bc1ed64f379b98af883467bd2f7640 100644 (file)
@@ -845,14 +845,20 @@ static int armv8_set_core_reg(struct reg *reg, uint8_t *buf)
 {
        struct arm_reg *armv8_reg = reg->arch_info;
        struct target *target = armv8_reg->target;
+       struct arm *arm = target_to_arm(target);
        uint64_t value = buf_get_u64(buf, 0, 64);
 
        if (target->state != TARGET_HALTED)
                return ERROR_TARGET_NOT_HALTED;
 
-       buf_set_u64(reg->value, 0, 64, value);
+       if (reg == arm->cpsr) {
+               armv8_set_cpsr(arm, (uint32_t)value);
+       } else {
+               buf_set_u64(reg->value, 0, 64, value);
+               reg->valid = 1;
+       }
+
        reg->dirty = 1;
-       reg->valid = 1;
 
        return ERROR_OK;
 }