coroutine/ppc64le: fix conditional registers got clobbered unexpectedly

Now we also save the special cr registers during the fiber switching
This commit is contained in:
liushuyu 2025-01-08 12:06:05 -07:00 committed by Nobuyoshi Nakada
parent 073c4e1cc7
commit d8a21592b4
Notes: git 2025-01-09 15:07:41 +00:00
2 changed files with 13 additions and 3 deletions

View File

@ -7,7 +7,7 @@
.type PREFIXED_SYMBOL(coroutine_transfer), @function
PREFIXED_SYMBOL(coroutine_transfer):
# Make space on the stack for caller registers
addi 1,1,-152
addi 1,1,-160
# Save caller registers
std 14,0(1)
@ -33,6 +33,10 @@ PREFIXED_SYMBOL(coroutine_transfer):
mflr 0
std 0,144(1)
# Save caller special register
mfcr 0
std 0, 152(1)
# Save stack pointer to first argument
std 1,0(3)
@ -63,8 +67,14 @@ PREFIXED_SYMBOL(coroutine_transfer):
ld 0,144(1)
mtlr 0
# Load special registers
ld 0,152(1)
# Restore cr register cr2, cr3 and cr4 (field index 3,4,5)
# (field index is 1-based, field 1 = cr0) using a mask (32|16|8 = 56)
mtcrf 56,0
# Pop stack frame
addi 1,1,152
addi 1,1,160
# Jump to return address
blr

View File

@ -12,7 +12,7 @@
enum {
COROUTINE_REGISTERS =
19 /* 18 general purpose registers (r14-r31) and 1 return address */
20 /* 18 general purpose registers (r14-r31), 1 special register (cr) and 1 return address */
+ 4 /* space for fiber_entry() to store the link register */
};