powerpc: Fix branch patching code for ABIv2

The MMU hashtable and SLB branch patching code uses function
pointers for the update sites. This creates a difference between
ABIv1 and ABIv2 because we don't have function descriptors on
ABIv2.

Get rid of the function pointer and just point at the update
sites directly. This works on both ABIs.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Fix kernel thread creation on ABIv2

Change how we setup registers for ret_from_kernel_thread. In
ABIv1, instead of passing a function descriptor in, dereference
it and pass the target in directly.

This makes it easier to support ABIv2 where we need the target
address in r12.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Fix ABIv2 issues with stack offsets in assembly code

Fix STK_PARAM and use it instead of hardcoding ABIv1 offsets.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Fix ABIv2 issuse with hcall macros

Our current macros assume the parameter save area is
always available.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Fix unsafe accesses to parameter area in ELFv2

Some of the assembler files in lib/ make use of the fact that in the
ELFv1 ABI, the caller guarantees to provide stack space to save the
parameter registers r3 ... r10.  This guarantee is no longer present
in ELFv2 for functions that have no variable argument list and no
more than 8 arguments.

Change the affected routines to temporarily store registers in the
red zone and/or the top of their own stack frame (in the space
provided to save r31 .. r29, which is actually not used in these
routines).

In opal_query_takeover, simply always allocate a stack frame;
the routine is not performance critical.

Signed-off-by: Ulrich Weigand <ulrich.weigand@de.ibm.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: dodgy hack to work around ABIv2 __hash_page_4K and __hash_page_64K issues

Declare them as vararg functions so we get a stack frame large enough
to use STK_PARAM()

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc/tm: Use STK_PARAM

Get rid of the tm specific STACK_PARAM and use STK_PARAM

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc/tm: Fix GOT save offset for ABIv2

The r2 TOC/GOT save offset is 40 on ABIv1 and 24 on ABIv2.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc/tracing: TRACE_WITH_FRAME_BUFFER creates invalid stack frames

TRACE_WITH_FRAME_BUFFER creates 32 byte stack frames. On ppc64
ABIv1 this is too small and a callee could corrupt the stack by
writing to the parameter save area (starting at offset 48).

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Build little endian ppc64 kernel with ABIv2

Build the little endian ppc64 kernel with ABIv2 if the toolchain
supports it. We can identify an ABIv2 capable toolchain by the
-mabi=elfv2 compiler flag.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Fix SMP issues with ppc64le ABIv2

There is no need to put a function descriptor in
__secondary_hold_spinloop. Use ppc_function_entry to get the
instruction address and put it in __secondary_hold_spinloop instead.

Also fix an issue where we assumed cur_cpu_spec held a function
descriptor.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Fix ABIv2 issue with dereference_function_descriptor

Don't try and dereference a function descriptor on ABIv2.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Add ABIv2 global and local entry to _GLOBAL

Modules might call exported assembly functions, and if they
in tern call out to C then we have to ensure r2 is setup.

Signed-off-by: Anton Blanchard <anton@samba.org>