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>
19 #ifdef CONFIG_TRACEPOINTS
21 #ifndef HAVE_JUMP_LABEL
24 .globl hcall_tracepoint_refcount
25 hcall_tracepoint_refcount:
32 * precall must preserve all registers. use unused STK_PARAM()
33 * areas to save snapshots and opcode.
35 #define HCALL_INST_PRECALL(FIRST_REG) \
37 std r3,STK_PARAM(R3)(r1); \
38 std r4,STK_PARAM(R4)(r1); \
39 std r5,STK_PARAM(R5)(r1); \
40 std r6,STK_PARAM(R6)(r1); \
41 std r7,STK_PARAM(R7)(r1); \
42 std r8,STK_PARAM(R8)(r1); \
43 std r9,STK_PARAM(R9)(r1); \
44 std r10,STK_PARAM(R10)(r1); \
46 addi r4,r1,STK_PARAM(FIRST_REG); \
47 stdu r1,-STACK_FRAME_OVERHEAD(r1); \
48 bl __trace_hcall_entry; \
49 ld r3,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
50 ld r4,STACK_FRAME_OVERHEAD+STK_PARAM(R4)(r1); \
51 ld r5,STACK_FRAME_OVERHEAD+STK_PARAM(R5)(r1); \
52 ld r6,STACK_FRAME_OVERHEAD+STK_PARAM(R6)(r1); \
53 ld r7,STACK_FRAME_OVERHEAD+STK_PARAM(R7)(r1); \
54 ld r8,STACK_FRAME_OVERHEAD+STK_PARAM(R8)(r1); \
55 ld r9,STACK_FRAME_OVERHEAD+STK_PARAM(R9)(r1); \
56 ld r10,STACK_FRAME_OVERHEAD+STK_PARAM(R10)(r1)
59 * postcall is performed immediately before function return which
60 * allows liberal use of volatile registers.
62 #define __HCALL_INST_POSTCALL \
63 ld r0,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
64 std r3,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
67 bl __trace_hcall_exit; \
68 ld r0,STACK_FRAME_OVERHEAD+16(r1); \
69 addi r1,r1,STACK_FRAME_OVERHEAD; \
70 ld r3,STK_PARAM(R3)(r1); \
73 #define HCALL_INST_POSTCALL_NORETS \
77 #define HCALL_INST_POSTCALL(BUFREG) \
81 #ifdef HAVE_JUMP_LABEL
82 #define HCALL_BRANCH(LABEL) \
83 ARCH_STATIC_BRANCH(LABEL, hcall_tracepoint_key)
87 * We branch around this in early init (eg when populating the MMU
88 * hashtable) by using an unconditional cpu feature.
90 #define HCALL_BRANCH(LABEL) \
93 END_FTR_SECTION(0, 1); \
94 ld r12,hcall_tracepoint_refcount@toc(r2); \
102 #define HCALL_INST_PRECALL(FIRST_ARG)
103 #define HCALL_INST_POSTCALL_NORETS
104 #define HCALL_INST_POSTCALL(BUFREG)
105 #define HCALL_BRANCH(LABEL)
108 _GLOBAL_TOC(plpar_hcall_norets)
113 HCALL_BRANCH(plpar_hcall_norets_trace)
114 HVSC /* invoke the hypervisor */
118 blr /* return r3 = status */
120 #ifdef CONFIG_TRACEPOINTS
121 plpar_hcall_norets_trace:
122 HCALL_INST_PRECALL(R4)
124 HCALL_INST_POSTCALL_NORETS
130 _GLOBAL_TOC(plpar_hcall)
136 HCALL_BRANCH(plpar_hcall_trace)
138 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
147 HVSC /* invoke the hypervisor */
149 ld r12,STK_PARAM(R4)(r1)
158 blr /* return r3 = status */
160 #ifdef CONFIG_TRACEPOINTS
162 HCALL_INST_PRECALL(R5)
164 std r4,STK_PARAM(R4)(r1)
176 ld r12,STK_PARAM(R4)(r1)
182 HCALL_INST_POSTCALL(r12)
191 * plpar_hcall_raw can be called in real mode. kexec/kdump need some
192 * hypervisor calls to be executed in real mode. So plpar_hcall_raw
193 * does not access the per cpu hypervisor call statistics variables,
194 * since these variables may not be present in the RMO region.
196 _GLOBAL(plpar_hcall_raw)
202 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
211 HVSC /* invoke the hypervisor */
213 ld r12,STK_PARAM(R4)(r1)
222 blr /* return r3 = status */
224 _GLOBAL_TOC(plpar_hcall9)
230 HCALL_BRANCH(plpar_hcall9_trace)
232 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
240 ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
241 ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
242 ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
244 HVSC /* invoke the hypervisor */
247 ld r12,STK_PARAM(R4)(r1)
261 blr /* return r3 = status */
263 #ifdef CONFIG_TRACEPOINTS
265 HCALL_INST_PRECALL(R5)
267 std r4,STK_PARAM(R4)(r1)
276 ld r10,STACK_FRAME_OVERHEAD+STK_PARAM(R11)(r1)
277 ld r11,STACK_FRAME_OVERHEAD+STK_PARAM(R12)(r1)
278 ld r12,STACK_FRAME_OVERHEAD+STK_PARAM(R13)(r1)
283 ld r12,STACK_FRAME_OVERHEAD+STK_PARAM(R4)(r1)
294 HCALL_INST_POSTCALL(r12)
302 /* See plpar_hcall_raw to see why this is needed */
303 _GLOBAL(plpar_hcall9_raw)
309 std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
317 ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
318 ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
319 ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
321 HVSC /* invoke the hypervisor */
324 ld r12,STK_PARAM(R4)(r1)
338 blr /* return r3 = status */