Hello David,
Is it possible to use L1FINV0[CCMD] to force CWAY to 0 for a 4KB stack? I was thinking about something like:
stack_cache_0:
mfpir r3
se_cmpi r3,0
se_bne stack_cache_1 /* this part is Core 0 only */
/* assuming a 4KB stack */
e_li r4,3 # will set L1FINV0[CWAY] = 0 and L1FINV0[CCMD] = 3
e_lis r5,__CPU0_STACK_SIZE@h
e_or2i r5,__CPU0_STACK_SIZE@l
se_srwi r5,5 # Shift the contents of R3 right by 5 bits (stack_size/32 = 128)
se_mtctr r5
e_lis r3,_cpu0_stack_end@h
e_or2i r3,_cpu0_stack_end@l
mtl1finv0 r4
lock_cache_loop_cpu0_way0:
dcbz r0,r3 # Establish address in cache for 32 bytes and zero
dcbtls 0,r0,r3 # Lock the address into the cache
se_addi r3,32 # Increment to start of next cache line (+32 bytes)
e_bdnz lock_cache_loop_cpu0_way0 # Decrement the counter (CTR), branch if nonzero
But I don't know how to be sure my stack is where I think it is.
Thanks!