Skip to content

Commit

Permalink
target/mips32: pracc write cp0 status register first
Browse files Browse the repository at this point in the history
When user requested a change on cp0 status register,
it may contain changes on EXL/ERL bits, and changes on
these bits could lead to differnt behaviours on writing
to other cp0 registers.

Change-Id: Ic83039988c29c06ee134226b52de943c46d19da2
Signed-off-by: Walter Ji <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7914
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
709924470 authored and borneoa committed Dec 1, 2023
1 parent 7ac389c commit 15038ab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/target/mips32_pracc.c
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,12 @@ int mips32_pracc_write_regs(struct mips32_common *mips32)
};

uint32_t cp0_write_data[] = {
/* status */
c0rs[0],
/* lo */
gprs[32],
/* hi */
gprs[33],
/* status */
c0rs[0],
/* badvaddr */
c0rs[1],
/* cause */
Expand All @@ -856,6 +856,9 @@ int mips32_pracc_write_regs(struct mips32_common *mips32)
c0rs[3],
};

/* Write CP0 Status Register first, changes on EXL or ERL bits
* may lead to different behaviour on writing to other CP0 registers.
*/
for (size_t i = 0; i < ARRAY_SIZE(cp0_write_code); i++) {
/* load CP0 value in $1 */
pracc_add_li32(&ctx, 1, cp0_write_data[i], 0);
Expand Down

0 comments on commit 15038ab

Please sign in to comment.