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 <asm/hvcall.h>
11 #include <asm/processor.h>
12 #include <asm/ppc_asm.h>
13 #include <asm/asm-offsets.h>
14 #include <asm/ptrace.h>
16 #define STK_PARM(i) (48 + ((i)-3)*8)
18 #ifdef CONFIG_TRACEPOINTS
22 .globl hcall_tracepoint_refcount
23 hcall_tracepoint_refcount:
29 * precall must preserve all registers. use unused STK_PARM()
30 * areas to save snapshots and opcode. We branch around this
31 * in early init (eg when populating the MMU hashtable) by using an
32 * unconditional cpu feature.
34 #define HCALL_INST_PRECALL(FIRST_REG) \
37 END_FTR_SECTION(0, 1); \
38 ld r12,hcall_tracepoint_refcount@toc(r2); \
43 std r3,STK_PARM(r3)(r1); \
44 std r4,STK_PARM(r4)(r1); \
45 std r5,STK_PARM(r5)(r1); \
46 std r6,STK_PARM(r6)(r1); \
47 std r7,STK_PARM(r7)(r1); \
48 std r8,STK_PARM(r8)(r1); \
49 std r9,STK_PARM(r9)(r1); \
50 std r10,STK_PARM(r10)(r1); \
52 addi r4,r1,STK_PARM(FIRST_REG); \
53 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
54 bl .__trace_hcall_entry; \
55 addi r1,r1,STACK_FRAME_OVERHEAD; \
57 ld r3,STK_PARM(r3)(r1); \
58 ld r4,STK_PARM(r4)(r1); \
59 ld r5,STK_PARM(r5)(r1); \
60 ld r6,STK_PARM(r6)(r1); \
61 ld r7,STK_PARM(r7)(r1); \
62 ld r8,STK_PARM(r8)(r1); \
63 ld r9,STK_PARM(r9)(r1); \
64 ld r10,STK_PARM(r10)(r1); \
69 * postcall is performed immediately before function return which
70 * allows liberal use of volatile registers. We branch around this
71 * in early init (eg when populating the MMU hashtable) by using an
72 * unconditional cpu feature.
74 #define __HCALL_INST_POSTCALL \
77 END_FTR_SECTION(0, 1); \
82 ld r6,STK_PARM(r3)(r1); \
83 std r3,STK_PARM(r3)(r1); \
87 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
88 bl .__trace_hcall_exit; \
89 addi r1,r1,STACK_FRAME_OVERHEAD; \
91 ld r3,STK_PARM(r3)(r1); \
95 #define HCALL_INST_POSTCALL_NORETS \
99 #define HCALL_INST_POSTCALL(BUFREG) \
101 __HCALL_INST_POSTCALL
104 #define HCALL_INST_PRECALL(FIRST_ARG)
105 #define HCALL_INST_POSTCALL_NORETS
106 #define HCALL_INST_POSTCALL(BUFREG)
111 _GLOBAL(plpar_hcall_norets)
117 HCALL_INST_PRECALL(r4)
119 HVSC /* invoke the hypervisor */
121 HCALL_INST_POSTCALL_NORETS
125 blr /* return r3 = status */
133 HCALL_INST_PRECALL(r5)
135 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
144 HVSC /* invoke the hypervisor */
146 ld r12,STK_PARM(r4)(r1)
152 HCALL_INST_POSTCALL(r12)
157 blr /* return r3 = status */
160 * plpar_hcall_raw can be called in real mode. kexec/kdump need some
161 * hypervisor calls to be executed in real mode. So plpar_hcall_raw
162 * does not access the per cpu hypervisor call statistics variables,
163 * since these variables may not be present in the RMO region.
165 _GLOBAL(plpar_hcall_raw)
171 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
180 HVSC /* invoke the hypervisor */
182 ld r12,STK_PARM(r4)(r1)
191 blr /* return r3 = status */
193 _GLOBAL(plpar_hcall9)
199 HCALL_INST_PRECALL(r5)
201 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
209 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
210 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
211 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
213 HVSC /* invoke the hypervisor */
216 ld r12,STK_PARM(r4)(r1)
227 HCALL_INST_POSTCALL(r12)
232 blr /* return r3 = status */
234 /* See plpar_hcall_raw to see why this is needed */
235 _GLOBAL(plpar_hcall9_raw)
241 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
249 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
250 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
251 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
253 HVSC /* invoke the hypervisor */
256 ld r12,STK_PARM(r4)(r1)
270 blr /* return r3 = status */