2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This file contains the generic code to perform a call to the
|
|
|
|
* pSeries LPAR hypervisor.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*/
|
|
|
|
#include <asm/hvcall.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/ppc_asm.h>
|
2006-09-07 07:23:12 +08:00
|
|
|
#include <asm/asm-offsets.h>
|
2010-11-18 23:06:17 +08:00
|
|
|
#include <asm/ptrace.h>
|
2014-07-03 13:52:03 +08:00
|
|
|
#include <asm/jump_label.h>
|
|
|
|
|
|
|
|
.section ".text"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-10-27 02:50:29 +08:00
|
|
|
#ifdef CONFIG_TRACEPOINTS
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
#ifndef CONFIG_JUMP_LABEL
|
2009-10-27 02:50:29 +08:00
|
|
|
.section ".toc","aw"
|
|
|
|
|
|
|
|
.globl hcall_tracepoint_refcount
|
|
|
|
hcall_tracepoint_refcount:
|
|
|
|
.llong 0
|
|
|
|
|
|
|
|
.section ".text"
|
2014-07-03 13:52:03 +08:00
|
|
|
#endif
|
2009-10-27 02:50:29 +08:00
|
|
|
|
2006-09-07 07:23:12 +08:00
|
|
|
/*
|
2012-06-25 21:33:14 +08:00
|
|
|
* precall must preserve all registers. use unused STK_PARAM()
|
2014-07-03 13:52:03 +08:00
|
|
|
* areas to save snapshots and opcode.
|
2006-09-07 07:23:12 +08:00
|
|
|
*/
|
2009-10-27 02:51:09 +08:00
|
|
|
#define HCALL_INST_PRECALL(FIRST_REG) \
|
2009-10-27 02:50:29 +08:00
|
|
|
mflr r0; \
|
2012-06-25 21:33:14 +08:00
|
|
|
std r3,STK_PARAM(R3)(r1); \
|
|
|
|
std r4,STK_PARAM(R4)(r1); \
|
|
|
|
std r5,STK_PARAM(R5)(r1); \
|
|
|
|
std r6,STK_PARAM(R6)(r1); \
|
|
|
|
std r7,STK_PARAM(R7)(r1); \
|
|
|
|
std r8,STK_PARAM(R8)(r1); \
|
|
|
|
std r9,STK_PARAM(R9)(r1); \
|
|
|
|
std r10,STK_PARAM(R10)(r1); \
|
2009-10-27 02:50:29 +08:00
|
|
|
std r0,16(r1); \
|
2012-06-25 21:33:14 +08:00
|
|
|
addi r4,r1,STK_PARAM(FIRST_REG); \
|
2009-10-27 02:50:29 +08:00
|
|
|
stdu r1,-STACK_FRAME_OVERHEAD(r1); \
|
2014-02-04 13:04:35 +08:00
|
|
|
bl __trace_hcall_entry; \
|
2014-07-03 13:52:56 +08:00
|
|
|
ld r3,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
|
|
|
|
ld r4,STACK_FRAME_OVERHEAD+STK_PARAM(R4)(r1); \
|
|
|
|
ld r5,STACK_FRAME_OVERHEAD+STK_PARAM(R5)(r1); \
|
|
|
|
ld r6,STACK_FRAME_OVERHEAD+STK_PARAM(R6)(r1); \
|
|
|
|
ld r7,STACK_FRAME_OVERHEAD+STK_PARAM(R7)(r1); \
|
|
|
|
ld r8,STACK_FRAME_OVERHEAD+STK_PARAM(R8)(r1); \
|
|
|
|
ld r9,STACK_FRAME_OVERHEAD+STK_PARAM(R9)(r1); \
|
|
|
|
ld r10,STACK_FRAME_OVERHEAD+STK_PARAM(R10)(r1)
|
2009-10-27 02:50:29 +08:00
|
|
|
|
2006-09-07 07:23:12 +08:00
|
|
|
/*
|
|
|
|
* postcall is performed immediately before function return which
|
2014-07-03 13:52:03 +08:00
|
|
|
* allows liberal use of volatile registers.
|
2006-09-07 07:23:12 +08:00
|
|
|
*/
|
2009-10-27 02:51:09 +08:00
|
|
|
#define __HCALL_INST_POSTCALL \
|
2014-07-03 13:52:56 +08:00
|
|
|
ld r0,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
|
|
|
|
std r3,STACK_FRAME_OVERHEAD+STK_PARAM(R3)(r1); \
|
2009-10-27 02:50:29 +08:00
|
|
|
mr r4,r3; \
|
2014-07-03 13:52:56 +08:00
|
|
|
mr r3,r0; \
|
2014-02-04 13:04:35 +08:00
|
|
|
bl __trace_hcall_exit; \
|
2014-07-03 13:52:56 +08:00
|
|
|
ld r0,STACK_FRAME_OVERHEAD+16(r1); \
|
2009-10-27 02:50:29 +08:00
|
|
|
addi r1,r1,STACK_FRAME_OVERHEAD; \
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r3,STK_PARAM(R3)(r1); \
|
2014-07-03 13:52:03 +08:00
|
|
|
mtlr r0
|
2009-10-27 02:51:09 +08:00
|
|
|
|
|
|
|
#define HCALL_INST_POSTCALL_NORETS \
|
|
|
|
li r5,0; \
|
|
|
|
__HCALL_INST_POSTCALL
|
|
|
|
|
|
|
|
#define HCALL_INST_POSTCALL(BUFREG) \
|
|
|
|
mr r5,BUFREG; \
|
|
|
|
__HCALL_INST_POSTCALL
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
#ifdef CONFIG_JUMP_LABEL
|
|
|
|
#define HCALL_BRANCH(LABEL) \
|
|
|
|
ARCH_STATIC_BRANCH(LABEL, hcall_tracepoint_key)
|
|
|
|
#else
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We branch around this in early init (eg when populating the MMU
|
|
|
|
* hashtable) by using an unconditional cpu feature.
|
|
|
|
*/
|
|
|
|
#define HCALL_BRANCH(LABEL) \
|
|
|
|
BEGIN_FTR_SECTION; \
|
|
|
|
b 1f; \
|
|
|
|
END_FTR_SECTION(0, 1); \
|
|
|
|
ld r12,hcall_tracepoint_refcount@toc(r2); \
|
|
|
|
std r12,32(r1); \
|
|
|
|
cmpdi r12,0; \
|
|
|
|
bne- LABEL; \
|
|
|
|
1:
|
|
|
|
#endif
|
|
|
|
|
2006-09-07 07:23:12 +08:00
|
|
|
#else
|
2009-10-27 02:51:09 +08:00
|
|
|
#define HCALL_INST_PRECALL(FIRST_ARG)
|
|
|
|
#define HCALL_INST_POSTCALL_NORETS
|
|
|
|
#define HCALL_INST_POSTCALL(BUFREG)
|
2014-07-03 13:52:03 +08:00
|
|
|
#define HCALL_BRANCH(LABEL)
|
2006-09-07 07:23:12 +08:00
|
|
|
#endif
|
|
|
|
|
2014-05-13 18:48:57 +08:00
|
|
|
_GLOBAL_TOC(plpar_hcall_norets)
|
2005-05-01 23:58:46 +08:00
|
|
|
HMT_MEDIUM
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
2014-07-03 13:52:03 +08:00
|
|
|
HCALL_BRANCH(plpar_hcall_norets_trace)
|
2005-04-17 06:20:36 +08:00
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
blr /* return r3 = status */
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
#ifdef CONFIG_TRACEPOINTS
|
|
|
|
plpar_hcall_norets_trace:
|
|
|
|
HCALL_INST_PRECALL(R4)
|
|
|
|
HVSC
|
|
|
|
HCALL_INST_POSTCALL_NORETS
|
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
blr
|
|
|
|
#endif
|
|
|
|
|
2014-05-13 18:48:57 +08:00
|
|
|
_GLOBAL_TOC(plpar_hcall)
|
2005-05-01 23:58:46 +08:00
|
|
|
HMT_MEDIUM
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
HCALL_BRANCH(plpar_hcall_trace)
|
2006-09-07 07:23:12 +08:00
|
|
|
|
2012-06-25 21:33:14 +08:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-07-19 06:01:28 +08:00
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2006-07-19 06:01:28 +08:00
|
|
|
std r4, 0(r12)
|
|
|
|
std r5, 8(r12)
|
|
|
|
std r6, 16(r12)
|
|
|
|
std r7, 24(r12)
|
2006-03-31 04:47:14 +08:00
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
|
|
|
blr /* return r3 = status */
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRACEPOINTS
|
|
|
|
plpar_hcall_trace:
|
|
|
|
HCALL_INST_PRECALL(R5)
|
|
|
|
|
|
|
|
std r4,STK_PARAM(R4)(r1)
|
|
|
|
mr r0,r4
|
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
|
|
|
|
|
|
|
HVSC
|
|
|
|
|
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
|
|
|
std r4,0(r12)
|
|
|
|
std r5,8(r12)
|
|
|
|
std r6,16(r12)
|
|
|
|
std r7,24(r12)
|
|
|
|
|
2009-10-27 02:51:09 +08:00
|
|
|
HCALL_INST_POSTCALL(r12)
|
2006-09-07 07:23:12 +08:00
|
|
|
|
2006-03-31 04:47:14 +08:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
blr
|
|
|
|
#endif
|
2006-03-31 04:47:14 +08:00
|
|
|
|
2007-03-21 13:51:32 +08:00
|
|
|
/*
|
|
|
|
* plpar_hcall_raw can be called in real mode. kexec/kdump need some
|
|
|
|
* hypervisor calls to be executed in real mode. So plpar_hcall_raw
|
|
|
|
* does not access the per cpu hypervisor call statistics variables,
|
|
|
|
* since these variables may not be present in the RMO region.
|
|
|
|
*/
|
|
|
|
_GLOBAL(plpar_hcall_raw)
|
|
|
|
HMT_MEDIUM
|
|
|
|
|
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2012-06-25 21:33:14 +08:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2007-03-21 13:51:32 +08:00
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2007-03-21 13:51:32 +08:00
|
|
|
std r4, 0(r12)
|
|
|
|
std r5, 8(r12)
|
|
|
|
std r6, 16(r12)
|
|
|
|
std r7, 24(r12)
|
|
|
|
|
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
|
|
|
blr /* return r3 = status */
|
|
|
|
|
2014-05-13 18:48:57 +08:00
|
|
|
_GLOBAL_TOC(plpar_hcall9)
|
2006-03-31 04:47:14 +08:00
|
|
|
HMT_MEDIUM
|
|
|
|
|
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
HCALL_BRANCH(plpar_hcall9_trace)
|
2006-09-07 07:23:12 +08:00
|
|
|
|
2012-06-25 21:33:14 +08:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2006-07-19 06:01:28 +08:00
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
|
|
|
|
ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
|
|
|
|
ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
|
2006-03-31 04:47:14 +08:00
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
2007-01-08 23:37:16 +08:00
|
|
|
mr r0,r12
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2006-07-19 06:01:28 +08:00
|
|
|
std r4, 0(r12)
|
|
|
|
std r5, 8(r12)
|
|
|
|
std r6, 16(r12)
|
|
|
|
std r7, 24(r12)
|
|
|
|
std r8, 32(r12)
|
|
|
|
std r9, 40(r12)
|
|
|
|
std r10,48(r12)
|
|
|
|
std r11,56(r12)
|
2007-01-08 23:37:16 +08:00
|
|
|
std r0, 64(r12)
|
2006-03-31 04:47:14 +08:00
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
|
|
|
blr /* return r3 = status */
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRACEPOINTS
|
|
|
|
plpar_hcall9_trace:
|
|
|
|
HCALL_INST_PRECALL(R5)
|
|
|
|
|
|
|
|
std r4,STK_PARAM(R4)(r1)
|
|
|
|
mr r0,r4
|
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2014-07-03 13:52:56 +08:00
|
|
|
ld r10,STACK_FRAME_OVERHEAD+STK_PARAM(R11)(r1)
|
|
|
|
ld r11,STACK_FRAME_OVERHEAD+STK_PARAM(R12)(r1)
|
|
|
|
ld r12,STACK_FRAME_OVERHEAD+STK_PARAM(R13)(r1)
|
2014-07-03 13:52:03 +08:00
|
|
|
|
|
|
|
HVSC
|
|
|
|
|
|
|
|
mr r0,r12
|
2014-07-03 13:52:56 +08:00
|
|
|
ld r12,STACK_FRAME_OVERHEAD+STK_PARAM(R4)(r1)
|
2014-07-03 13:52:03 +08:00
|
|
|
std r4,0(r12)
|
|
|
|
std r5,8(r12)
|
|
|
|
std r6,16(r12)
|
|
|
|
std r7,24(r12)
|
|
|
|
std r8,32(r12)
|
|
|
|
std r9,40(r12)
|
|
|
|
std r10,48(r12)
|
|
|
|
std r11,56(r12)
|
|
|
|
std r0,64(r12)
|
|
|
|
|
2009-10-27 02:51:09 +08:00
|
|
|
HCALL_INST_POSTCALL(r12)
|
2006-09-07 07:23:12 +08:00
|
|
|
|
2006-03-31 04:47:14 +08:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
2014-07-03 13:52:03 +08:00
|
|
|
blr
|
|
|
|
#endif
|
2010-05-11 04:28:26 +08:00
|
|
|
|
|
|
|
/* See plpar_hcall_raw to see why this is needed */
|
|
|
|
_GLOBAL(plpar_hcall9_raw)
|
|
|
|
HMT_MEDIUM
|
|
|
|
|
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2012-06-25 21:33:14 +08:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2010-05-11 04:28:26 +08:00
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r10,STK_PARAM(R11)(r1) /* put arg7 in R10 */
|
|
|
|
ld r11,STK_PARAM(R12)(r1) /* put arg8 in R11 */
|
|
|
|
ld r12,STK_PARAM(R13)(r1) /* put arg9 in R12 */
|
2010-05-11 04:28:26 +08:00
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
|
|
|
mr r0,r12
|
2012-06-25 21:33:14 +08:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2010-05-11 04:28:26 +08:00
|
|
|
std r4, 0(r12)
|
|
|
|
std r5, 8(r12)
|
|
|
|
std r6, 16(r12)
|
|
|
|
std r7, 24(r12)
|
|
|
|
std r8, 32(r12)
|
|
|
|
std r9, 40(r12)
|
|
|
|
std r10,48(r12)
|
|
|
|
std r11,56(r12)
|
|
|
|
std r0, 64(r12)
|
|
|
|
|
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
|
|
|
blr /* return r3 = status */
|