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); \
42 std r3,STK_PARM(r3)(r1); \
43 std r4,STK_PARM(r4)(r1); \
44 std r5,STK_PARM(r5)(r1); \
45 std r6,STK_PARM(r6)(r1); \
46 std r7,STK_PARM(r7)(r1); \
47 std r8,STK_PARM(r8)(r1); \
48 std r9,STK_PARM(r9)(r1); \
49 std r10,STK_PARM(r10)(r1); \
51 addi r4,r1,STK_PARM(FIRST_REG); \
52 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
53 bl .__trace_hcall_entry; \
54 addi r1,r1,STACK_FRAME_OVERHEAD; \
56 ld r3,STK_PARM(r3)(r1); \
57 ld r4,STK_PARM(r4)(r1); \
58 ld r5,STK_PARM(r5)(r1); \
59 ld r6,STK_PARM(r6)(r1); \
60 ld r7,STK_PARM(r7)(r1); \
61 ld r8,STK_PARM(r8)(r1); \
62 ld r9,STK_PARM(r9)(r1); \
63 ld r10,STK_PARM(r10)(r1); \
68 * postcall is performed immediately before function return which
69 * allows liberal use of volatile registers. We branch around this
70 * in early init (eg when populating the MMU hashtable) by using an
71 * unconditional cpu feature.
73 #define __HCALL_INST_POSTCALL \
76 END_FTR_SECTION(0, 1); \
77 ld r12,hcall_tracepoint_refcount@toc(r2); \
81 ld r6,STK_PARM(r3)(r1); \
82 std r3,STK_PARM(r3)(r1); \
86 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
87 bl .__trace_hcall_exit; \
88 addi r1,r1,STACK_FRAME_OVERHEAD; \
90 ld r3,STK_PARM(r3)(r1); \
94 #define HCALL_INST_POSTCALL_NORETS \
98 #define HCALL_INST_POSTCALL(BUFREG) \
100 __HCALL_INST_POSTCALL
103 #define HCALL_INST_PRECALL(FIRST_ARG)
104 #define HCALL_INST_POSTCALL_NORETS
105 #define HCALL_INST_POSTCALL(BUFREG)
110 _GLOBAL(plpar_hcall_norets)
116 HCALL_INST_PRECALL(r4)
118 HVSC /* invoke the hypervisor */
120 HCALL_INST_POSTCALL_NORETS
124 blr /* return r3 = status */
132 HCALL_INST_PRECALL(r5)
134 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
143 HVSC /* invoke the hypervisor */
145 ld r12,STK_PARM(r4)(r1)
151 HCALL_INST_POSTCALL(r12)
156 blr /* return r3 = status */
159 * plpar_hcall_raw can be called in real mode. kexec/kdump need some
160 * hypervisor calls to be executed in real mode. So plpar_hcall_raw
161 * does not access the per cpu hypervisor call statistics variables,
162 * since these variables may not be present in the RMO region.
164 _GLOBAL(plpar_hcall_raw)
170 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
179 HVSC /* invoke the hypervisor */
181 ld r12,STK_PARM(r4)(r1)
190 blr /* return r3 = status */
192 _GLOBAL(plpar_hcall9)
198 HCALL_INST_PRECALL(r5)
200 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
208 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
209 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
210 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
212 HVSC /* invoke the hypervisor */
215 ld r12,STK_PARM(r4)(r1)
226 HCALL_INST_POSTCALL(r12)
231 blr /* return r3 = status */
233 /* See plpar_hcall_raw to see why this is needed */
234 _GLOBAL(plpar_hcall9_raw)
240 std r4,STK_PARM(r4)(r1) /* Save ret buffer */
248 ld r10,STK_PARM(r11)(r1) /* put arg7 in R10 */
249 ld r11,STK_PARM(r12)(r1) /* put arg8 in R11 */
250 ld r12,STK_PARM(r13)(r1) /* put arg9 in R12 */
252 HVSC /* invoke the hypervisor */
255 ld r12,STK_PARM(r4)(r1)
269 blr /* return r3 = status */