From 59f5e016be82a033e8586a5b790a90c97b87b5bc Mon Sep 17 00:00:00 2001 From: Harish Subramanian Date: Fri, 13 Sep 2024 18:06:42 +0530 Subject: [PATCH] Addressing fix for: Clickhouse crash issue on power pc build --- libs/context/src/asm/jump_ppc64_sysv_elf_gas.S | 13 +++++++++++-- libs/context/src/asm/ontop_ppc64_sysv_elf_gas.S | 12 ++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S b/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S index 28907db32b..f3b7a230b7 100644 --- a/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S +++ b/libs/context/src/asm/jump_ppc64_sysv_elf_gas.S @@ -97,7 +97,7 @@ jump_fcontext: # endif #endif # reserve space on stack - subi %r1, %r1, 184 + subi %r1, %r1, 200 #if _CALL_ELF != 2 std %r2, 0(%r1) # save TOC @@ -133,6 +133,10 @@ jump_fcontext: # save LR as PC std %r0, 176(%r1) + # save VS63 + li %r31, 184 + stvx %v31, %r1, %r31 + # store RSP (pointing to context-data) in R6 mr %r6, %r1 @@ -145,6 +149,11 @@ jump_fcontext: ld %r2, 0(%r1) # restore TOC #endif + + # restore VS63 + li %r31, 184 + lvx %v31, %r1, %r31 + ld %r14, 8(%r1) # restore R14 ld %r15, 16(%r1) # restore R15 ld %r16, 24(%r1) # restore R16 @@ -180,7 +189,7 @@ jump_fcontext: mtctr %r12 # adjust stack - addi %r1, %r1, 184 + addi %r1, %r1, 200 #if _CALL_ELF == 2 # copy transfer_t into transfer_fn arg registers diff --git a/libs/context/src/asm/ontop_ppc64_sysv_elf_gas.S b/libs/context/src/asm/ontop_ppc64_sysv_elf_gas.S index cd97f45671..f8954edcf9 100644 --- a/libs/context/src/asm/ontop_ppc64_sysv_elf_gas.S +++ b/libs/context/src/asm/ontop_ppc64_sysv_elf_gas.S @@ -97,7 +97,7 @@ ontop_fcontext: # endif #endif # reserve space on stack - subi %r1, %r1, 184 + subi %r1, %r1, 200 #if _CALL_ELF != 2 std %r2, 0(%r1) # save TOC @@ -133,6 +133,10 @@ ontop_fcontext: # save LR as PC std %r0, 176(%r1) + # save VS63 + li %r31, 184 + stvx %v31, %r1, %r31 + # store RSP (pointing to context-data) in R7 mr %r7, %r1 @@ -144,6 +148,10 @@ ontop_fcontext: mr %r1, %r4 #endif + # restore VS63 + li %r31, 184 + lvx %v31, %r1, %r31 + ld %r14, 8(%r1) # restore R14 ld %r15, 16(%r1) # restore R15 ld %r16, 24(%r1) # restore R16 @@ -203,7 +211,7 @@ return_to_ctx: mtlr %r0 # adjust stack - addi %r1, %r1, 184 + addi %r1, %r1, 200 # jump to context bctr