2 * This file contains the generic code to perform a call to the
3 * pSeries LPAR hypervisor.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version
8 * 2 of the License, or (at your option) any later version.
10 #include <linux/jump_label.h>
11 #include <asm/hvcall.h>
12 #include <asm/processor.h>
13 #include <asm/ppc_asm.h>
14 #include <asm/asm-offsets.h>
15 #include <asm/ptrace.h>
16 #include <asm/feature-fixups.h>
20 #ifdef CONFIG_TRACEPOINTS
22 #ifndef CONFIG_JUMP_LABEL
25 .globl hcall_tracepoint_refcount
26 hcall_tracepoint_refcount:
33 * precall must preserve all registers. use unused STK_PARAM()
34 * areas to save snapshots and opcode.
36 #define HCALL_INST_PRECALL(FIRST_REG) \
38 std r3,STK_PARAM(R3)(r1); \
39 std r4,STK_PARAM(R4)(r1); \
40 std r5,STK_PARAM(R5)(r1); \
41 std r6,STK_PARAM(R6)(r1); \
42 std r7,STK_PARAM(R7)(r1); \
43 std r8,STK_PARAM(R8)(r1); \
44 std r9,STK_PARAM(R9)(r1); \
45 std r10,STK_PARAM(R10)(r1); \
47 addi r4,r1,STK_PARAM(FIRST_REG); \
48 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
49 bl __trace_hcall_entry; \
50 ld r3,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
51 ld r4,STACK_FRAME_OVERHEAD+STK_PARAM(R4)(r1); \
52 ld r5,STACK_FRAME_OVERHEAD+STK_PARAM(R5)(r1); \
53 ld r6,STACK_FRAME_OVERHEAD+STK_PARAM(R6)(r1); \
54 ld r7,STACK_FRAME_OVERHEAD+STK_PARAM(R7)(r1); \
55 ld r8,STACK_FRAME_OVERHEAD+STK_PARAM(R8)(r1); \
56 ld r9,STACK_FRAME_OVERHEAD+STK_PARAM(R9)(r1); \
57 ld r10,STACK_FRAME_OVERHEAD+STK_PARAM(R10)(r1)
60 * postcall is performed immediately before function return which
61 * allows liberal use of volatile registers.
63 #define __HCALL_INST_POSTCALL \
64 ld r0,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
65 std r3,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
68 bl __trace_hcall_exit; \
69 ld r0,STACK_FRAME_OVERHEAD+16(r1); \
70 addi r1,r1,STACK_FRAME_OVERHEAD; \
71 ld r3,STK_PARAM(R3)(r1); \
74 #define HCALL_INST_POSTCALL_NORETS \
78 #define HCALL_INST_POSTCALL(BUFREG) \
82 #ifdef CONFIG_JUMP_LABEL
83 #define HCALL_BRANCH(LABEL) \
84 ARCH_STATIC_BRANCH(LABEL, hcall_tracepoint_key)
88 * We branch around this in early init (eg when populating the MMU
89 * hashtable) by using an unconditional cpu feature.
91 #define HCALL_BRANCH(LABEL) \
94 END_FTR_SECTION(0, 1); \
95 ld r12,hcall_tracepoint_refcount@toc(r2); \
103 #define HCALL_INST_PRECALL(FIRST_ARG)
104 #define HCALL_INST_POSTCALL_NORETS
105 #define HCALL_INST_POSTCALL(BUFREG)
106 #define HCALL_BRANCH(LABEL)
109 _GLOBAL_TOC(plpar_hcall_norets)
114 HCALL_BRANCH(plpar_hcall_norets_trace)
115 HVSC /* invoke the hypervisor */
119 blr /* return r3 = status */
121 #ifdef CONFIG_TRACEPOINTS
122 plpar_hcall_norets_trace:
123 HCALL_INST_PRECALL(R4)
125 HCALL_INST_POSTCALL_NORETS
131 _GLOBAL_TOC(plpar_hcall)
137 HCALL_BRANCH(plpar_hcall_trace)
139 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
148 HVSC /* invoke the hypervisor */
150 ld r12,STK_PARAM(R4)(r1)
159 blr /* return r3 = status */
161 #ifdef CONFIG_TRACEPOINTS
163 HCALL_INST_PRECALL(R5)
165 std r4,STK_PARAM(R4)(r1)
177 ld r12,STK_PARAM(R4)(r1)
183 HCALL_INST_POSTCALL(r12)
192 * plpar_hcall_raw can be called in real mode. kexec/kdump need some
193 * hypervisor calls to be executed in real mode. So plpar_hcall_raw
194 * does not access the per cpu hypervisor call statistics variables,
195 * since these variables may not be present in the RMO region.
197 _GLOBAL(plpar_hcall_raw)
203 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
212 HVSC /* invoke the hypervisor */
214 ld r12,STK_PARAM(R4)(r1)
223 blr /* return r3 = status */
225 _GLOBAL_TOC(plpar_hcall9)
231 HCALL_BRANCH(plpar_hcall9_trace)
233 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
241 ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
242 ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
243 ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
245 HVSC /* invoke the hypervisor */
248 ld r12,STK_PARAM(R4)(r1)
262 blr /* return r3 = status */
264 #ifdef CONFIG_TRACEPOINTS
266 HCALL_INST_PRECALL(R5)
268 std r4,STK_PARAM(R4)(r1)
277 ld r10,STACK_FRAME_OVERHEAD+STK_PARAM(R11)(r1)
278 ld r11,STACK_FRAME_OVERHEAD+STK_PARAM(R12)(r1)
279 ld r12,STACK_FRAME_OVERHEAD+STK_PARAM(R13)(r1)
284 ld r12,STACK_FRAME_OVERHEAD+STK_PARAM(R4)(r1)
295 HCALL_INST_POSTCALL(r12)
303 /* See plpar_hcall_raw to see why this is needed */
304 _GLOBAL(plpar_hcall9_raw)
310 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
318 ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
319 ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
320 ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
322 HVSC /* invoke the hypervisor */
325 ld r12,STK_PARAM(R4)(r1)
339 blr /* return r3 = status */