powerpc: Remove function descriptors and dot symbols on new ABI

ABIv2 doesn't have function descriptors or dot symbols.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: ABIv2 function calls must place target address in r12

To establish addressability quickly, ABIv2 requires the target
address of the function being called to be in r12. Fix a number of
places in assembly code that we do indirect function calls.

We need to avoid function descriptors on ABIv2 too.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Ignore TOC relocations

The linker fixes up TOC. relocations, so prom_init_check.sh should
ignore them.

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Add ABIv2 support to ppc_function_entry

Skip over the well known global entry point code for ABIv2:

	addis r2,r12,XXXX
	addi  r2,r2,XXXX

Signed-off-by: Anton Blanchard <anton@samba.org>
powerpc: Use ppc_function_entry instead of open coding it

Replace FUNCTION_TEXT with ppc_function_entry which can handle both
ABIv1 and ABIv2.

Signed-off-by: Anton Blanchard <anton@samba.org>
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: modules implement R_PPC64_TOCSAVE relocation.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
powerpc: modules stubs for ELFv2 ABI.

ELFv2 doesn't use function descriptors, in particular the caller doesn't
have to set up r2 prior to calling a function (that's the callee's job now).

We still need stubs, because we still need to save our old r2 value,
and the destination could be more than 24 bits away.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
powerpc: Handle .TOC. symbol for ELFv2 ABI.

For ELFv2, gcc uses a .TOC. symbol where it wants to patch in the toc
pointer (aka r2).  The linker is supposed to resolve this.

Our symbol resolution code is in the arch-independent core, so we need to
hack around this by marking it defined, then updating it when we're first
asked to apply a relocation.

We also modify modpost to avoid complaints about '.TOC.' being undefined.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
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>