Skip to content

Commit

Permalink
openocd: src/target: Correctly handle CCSIDR_EL1.Associativity=0
Browse files Browse the repository at this point in the history
Associativity=0 means that only one CMO is needed for all ways.
It could also mean that the cache is 1-way, but this is less likely.

Currently Associativity=0 causes us to hang in the while loop in
decode_cache_reg. Fix it by skipping the loop in this case. We can let
way_shift be set to the arbitrary value of 0 because in the case where
Associativity=0 we only ever shift 0 by it before ORing it into the
CMO operand.

Change-Id: I7c1de68d33f6b3ed627cbb1e2401d43185e4c1e3
Signed-off-by: Peter Collingbourne <[email protected]>
Reviewed-on: https://review.openocd.org/c/openocd/+/7916
Tested-by: jenkins
Reviewed-by: Antonio Borneo <[email protected]>
  • Loading branch information
pcc authored and borneoa committed Nov 18, 2023
1 parent 851d1ad commit ee96a95
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/target/armv8_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ static struct armv8_cachesize decode_cache_reg(uint32_t cache_reg)
size.index = (cache_reg >> 13) & 0x7fff;
size.way = ((cache_reg >> 3) & 0x3ff);

while (((size.way << i) & 0x80000000) == 0)
i++;
if (size.way != 0)
while (((size.way << i) & 0x80000000) == 0)
i++;
size.way_shift = i;

return size;
Expand Down

0 comments on commit ee96a95

Please sign in to comment.