From 8ef0c667f411d10d3c944e2ceda0eb88d2c0e290 Mon Sep 17 00:00:00 2001 From: Brandon Bergren Date: Tue, 26 May 2020 02:27:10 +0000 Subject: [PATCH] [PowerPC] Ensure ppc32 cpu_switch routines set up Secure-PLT. This is a correctness fix needed to enable the ifunc conversion of the pmap in D24993. Since we are making function calls that may need to go through the PLT, ensure r30 is set up correctly. This fixes crashes when booting with D24993 applied. Reviewed by: jhibbits (in IRC) Sponsored by: Tag1 Consulting, Inc. --- sys/powerpc/powerpc/swtch32.S | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/powerpc/powerpc/swtch32.S b/sys/powerpc/powerpc/swtch32.S index 5dd189df057..7950b60dc29 100644 --- a/sys/powerpc/powerpc/swtch32.S +++ b/sys/powerpc/powerpc/swtch32.S @@ -92,6 +92,11 @@ ENTRY(cpu_switch) mflr %r16 /* Save the link register */ stw %r16,PCB_LR(%r6) stw %r1,PCB_SP(%r6) /* Save the stack pointer */ + bl 1f +1: + mflr %r30 /* Prepare for secure-PLT calls */ + addis %r30, %r30, (_GLOBAL_OFFSET_TABLE_-1b)@ha + addi %r30, %r30, (_GLOBAL_OFFSET_TABLE_-1b)@l mr %r14,%r3 /* Copy the old thread ptr... */ mr %r2,%r4 /* and the new thread ptr in curthread */ @@ -129,6 +134,7 @@ cpu_switchin: mflr %r6 addis %r6,%r6,(_GLOBAL_OFFSET_TABLE_-1b)@ha addi %r6,%r6,(_GLOBAL_OFFSET_TABLE_-1b)@l + mr %r30, %r6 /* Prepare for secure-PLT calls */ lwz %r6,blocked_lock@got(%r6) blocked_loop: lwz %r7,TD_LOCK(%r2)