Skip to content

Commit

Permalink
aarch64: Use 64-bit reads/writes to access SCTLR_EL1
Browse files Browse the repository at this point in the history
We were previously inadvertently clearing the top 32 bits of SCTLR_EL1
during read_memory/write_memory as a result of using 32-bit operations
to access the register and because the fields used to temporarily
store the register were 32-bit. Fix it.

Change-Id: I657d7f949e1f7ab6bf90609e3f91cae09cade31a
Signed-off-by: Peter Collingbourne <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7939
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
pcc authored and borneoa committed Nov 18, 2023
1 parent ee96a95 commit 393da81
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/target/aarch64.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static int aarch64_restore_system_control_reg(struct target *target)
if (target_mode != ARM_MODE_ANY)
armv8_dpm_modeswitch(&armv8->dpm, target_mode);

retval = armv8->dpm.instr_write_data_r0(&armv8->dpm, instr, aarch64->system_control_reg);
retval = armv8->dpm.instr_write_data_r0_64(&armv8->dpm, instr, aarch64->system_control_reg);
if (retval != ERROR_OK)
return retval;

Expand Down Expand Up @@ -182,7 +182,7 @@ static int aarch64_mmu_modify(struct target *target, int enable)
if (target_mode != ARM_MODE_ANY)
armv8_dpm_modeswitch(&armv8->dpm, target_mode);

retval = armv8->dpm.instr_write_data_r0(&armv8->dpm, instr,
retval = armv8->dpm.instr_write_data_r0_64(&armv8->dpm, instr,
aarch64->system_control_reg_curr);

if (target_mode != ARM_MODE_ANY)
Expand Down Expand Up @@ -1055,14 +1055,14 @@ static int aarch64_post_debug_entry(struct target *target)
if (target_mode != ARM_MODE_ANY)
armv8_dpm_modeswitch(&armv8->dpm, target_mode);

retval = armv8->dpm.instr_read_data_r0(&armv8->dpm, instr, &aarch64->system_control_reg);
retval = armv8->dpm.instr_read_data_r0_64(&armv8->dpm, instr, &aarch64->system_control_reg);
if (retval != ERROR_OK)
return retval;

if (target_mode != ARM_MODE_ANY)
armv8_dpm_modeswitch(&armv8->dpm, ARM_MODE_ANY);

LOG_DEBUG("System_register: %8.8" PRIx32, aarch64->system_control_reg);
LOG_DEBUG("System_register: %8.8" PRIx64, aarch64->system_control_reg);
aarch64->system_control_reg_curr = aarch64->system_control_reg;

if (armv8->armv8_mmu.armv8_cache.info == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/target/aarch64.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ struct aarch64_common {
struct armv8_common armv8_common;

/* Context information */
uint32_t system_control_reg;
uint32_t system_control_reg_curr;
uint64_t system_control_reg;
uint64_t system_control_reg_curr;

/* Breakpoint register pairs */
int brp_num_context;
Expand Down

0 comments on commit 393da81

Please sign in to comment.