2005-04-16 22:20:36 +00: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-06 23:23:12 +00:00
|
|
|
#include <asm/asm-offsets.h>
|
2010-11-18 15:06:17 +00:00
|
|
|
#include <asm/ptrace.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-26 18:50:29 +00:00
|
|
|
#ifdef CONFIG_TRACEPOINTS
|
|
|
|
|
|
|
|
.section ".toc","aw"
|
|
|
|
|
|
|
|
.globl hcall_tracepoint_refcount
|
|
|
|
hcall_tracepoint_refcount:
|
|
|
|
.llong 0
|
|
|
|
|
|
|
|
.section ".text"
|
|
|
|
|
2006-09-06 23:23:12 +00:00
|
|
|
/*
|
2012-06-25 13:33:14 +00:00
|
|
|
* precall must preserve all registers. use unused STK_PARAM()
|
2009-10-26 18:50:29 +00:00
|
|
|
* areas to save snapshots and opcode. We branch around this
|
|
|
|
* in early init (eg when populating the MMU hashtable) by using an
|
|
|
|
* unconditional cpu feature.
|
2006-09-06 23:23:12 +00:00
|
|
|
*/
|
2009-10-26 18:51:09 +00:00
|
|
|
#define HCALL_INST_PRECALL(FIRST_REG) \
|
2006-09-06 23:23:12 +00:00
|
|
|
BEGIN_FTR_SECTION; \
|
2009-10-26 18:50:29 +00:00
|
|
|
b 1f; \
|
|
|
|
END_FTR_SECTION(0, 1); \
|
|
|
|
ld r12,hcall_tracepoint_refcount@toc(r2); \
|
2012-01-07 17:54:52 +00:00
|
|
|
std r12,32(r1); \
|
2009-10-26 18:50:29 +00:00
|
|
|
cmpdi r12,0; \
|
|
|
|
beq+ 1f; \
|
|
|
|
mflr r0; \
|
2012-06-25 13:33:14 +00: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-26 18:50:29 +00:00
|
|
|
std r0,16(r1); \
|
2012-06-25 13:33:14 +00:00
|
|
|
addi r4,r1,STK_PARAM(FIRST_REG); \
|
2009-10-26 18:50:29 +00:00
|
|
|
stdu r1,-STACK_FRAME_OVERHEAD(r1); \
|
|
|
|
bl .__trace_hcall_entry; \
|
|
|
|
addi r1,r1,STACK_FRAME_OVERHEAD; \
|
|
|
|
ld r0,16(r1); \
|
2012-06-25 13:33:14 +00:00
|
|
|
ld r3,STK_PARAM(R3)(r1); \
|
|
|
|
ld r4,STK_PARAM(R4)(r1); \
|
|
|
|
ld r5,STK_PARAM(R5)(r1); \
|
|
|
|
ld r6,STK_PARAM(R6)(r1); \
|
|
|
|
ld r7,STK_PARAM(R7)(r1); \
|
|
|
|
ld r8,STK_PARAM(R8)(r1); \
|
|
|
|
ld r9,STK_PARAM(R9)(r1); \
|
|
|
|
ld r10,STK_PARAM(R10)(r1); \
|
2009-10-26 18:50:29 +00:00
|
|
|
mtlr r0; \
|
|
|
|
1:
|
|
|
|
|
2006-09-06 23:23:12 +00:00
|
|
|
/*
|
|
|
|
* postcall is performed immediately before function return which
|
2007-03-20 19:29:54 +00:00
|
|
|
* allows liberal use of volatile registers. We branch around this
|
|
|
|
* in early init (eg when populating the MMU hashtable) by using an
|
|
|
|
* unconditional cpu feature.
|
2006-09-06 23:23:12 +00:00
|
|
|
*/
|
2009-10-26 18:51:09 +00:00
|
|
|
#define __HCALL_INST_POSTCALL \
|
2007-03-20 19:29:54 +00:00
|
|
|
BEGIN_FTR_SECTION; \
|
|
|
|
b 1f; \
|
|
|
|
END_FTR_SECTION(0, 1); \
|
2012-01-07 17:54:52 +00:00
|
|
|
ld r12,32(r1); \
|
2009-10-26 18:50:29 +00:00
|
|
|
cmpdi r12,0; \
|
|
|
|
beq+ 1f; \
|
|
|
|
mflr r0; \
|
2012-06-25 13:33:14 +00:00
|
|
|
ld r6,STK_PARAM(R3)(r1); \
|
|
|
|
std r3,STK_PARAM(R3)(r1); \
|
2009-10-26 18:50:29 +00:00
|
|
|
mr r4,r3; \
|
|
|
|
mr r3,r6; \
|
|
|
|
std r0,16(r1); \
|
|
|
|
stdu r1,-STACK_FRAME_OVERHEAD(r1); \
|
|
|
|
bl .__trace_hcall_exit; \
|
|
|
|
addi r1,r1,STACK_FRAME_OVERHEAD; \
|
|
|
|
ld r0,16(r1); \
|
2012-06-25 13:33:14 +00:00
|
|
|
ld r3,STK_PARAM(R3)(r1); \
|
2009-10-26 18:50:29 +00:00
|
|
|
mtlr r0; \
|
2006-09-06 23:23:12 +00:00
|
|
|
1:
|
2009-10-26 18:51:09 +00:00
|
|
|
|
|
|
|
#define HCALL_INST_POSTCALL_NORETS \
|
|
|
|
li r5,0; \
|
|
|
|
__HCALL_INST_POSTCALL
|
|
|
|
|
|
|
|
#define HCALL_INST_POSTCALL(BUFREG) \
|
|
|
|
mr r5,BUFREG; \
|
|
|
|
__HCALL_INST_POSTCALL
|
|
|
|
|
2006-09-06 23:23:12 +00:00
|
|
|
#else
|
2009-10-26 18:51:09 +00:00
|
|
|
#define HCALL_INST_PRECALL(FIRST_ARG)
|
|
|
|
#define HCALL_INST_POSTCALL_NORETS
|
|
|
|
#define HCALL_INST_POSTCALL(BUFREG)
|
2006-09-06 23:23:12 +00:00
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
.text
|
|
|
|
|
|
|
|
_GLOBAL(plpar_hcall_norets)
|
2005-05-01 15:58:46 +00:00
|
|
|
HMT_MEDIUM
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2012-06-25 13:33:10 +00:00
|
|
|
HCALL_INST_PRECALL(R4)
|
2006-09-06 23:23:12 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
2009-10-26 18:51:09 +00:00
|
|
|
HCALL_INST_POSTCALL_NORETS
|
2006-09-06 23:23:12 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
blr /* return r3 = status */
|
|
|
|
|
2006-07-18 22:01:28 +00:00
|
|
|
_GLOBAL(plpar_hcall)
|
2005-05-01 15:58:46 +00:00
|
|
|
HMT_MEDIUM
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2012-06-25 13:33:10 +00:00
|
|
|
HCALL_INST_PRECALL(R5)
|
2006-09-06 23:23:12 +00:00
|
|
|
|
2012-06-25 13:33:14 +00:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-07-18 22:01:28 +00:00
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
2012-06-25 13:33:14 +00:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2006-07-18 22:01:28 +00:00
|
|
|
std r4, 0(r12)
|
|
|
|
std r5, 8(r12)
|
|
|
|
std r6, 16(r12)
|
|
|
|
std r7, 24(r12)
|
2006-03-30 20:47:14 +00:00
|
|
|
|
2009-10-26 18:51:09 +00:00
|
|
|
HCALL_INST_POSTCALL(r12)
|
2006-09-06 23:23:12 +00:00
|
|
|
|
2006-03-30 20:47:14 +00:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
|
|
|
blr /* return r3 = status */
|
|
|
|
|
2007-03-21 05:51:32 +00: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 13:33:14 +00:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2007-03-21 05:51:32 +00: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 13:33:14 +00:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2007-03-21 05:51:32 +00: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 */
|
|
|
|
|
2006-07-18 22:01:28 +00:00
|
|
|
_GLOBAL(plpar_hcall9)
|
2006-03-30 20:47:14 +00:00
|
|
|
HMT_MEDIUM
|
|
|
|
|
|
|
|
mfcr r0
|
|
|
|
stw r0,8(r1)
|
|
|
|
|
2012-06-25 13:33:10 +00:00
|
|
|
HCALL_INST_PRECALL(R5)
|
2006-09-06 23:23:12 +00:00
|
|
|
|
2012-06-25 13:33:14 +00:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2006-07-18 22:01:28 +00:00
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2012-06-25 13:33:14 +00: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-30 20:47:14 +00:00
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
2007-01-08 15:37:16 +00:00
|
|
|
mr r0,r12
|
2012-06-25 13:33:14 +00:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2006-07-18 22:01:28 +00: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 15:37:16 +00:00
|
|
|
std r0, 64(r12)
|
2006-03-30 20:47:14 +00:00
|
|
|
|
2009-10-26 18:51:09 +00:00
|
|
|
HCALL_INST_POSTCALL(r12)
|
2006-09-06 23:23:12 +00:00
|
|
|
|
2006-03-30 20:47:14 +00:00
|
|
|
lwz r0,8(r1)
|
|
|
|
mtcrf 0xff,r0
|
|
|
|
|
|
|
|
blr /* return r3 = status */
|
2010-05-10 20:28:26 +00: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 13:33:14 +00:00
|
|
|
std r4,STK_PARAM(R4)(r1) /* Save ret buffer */
|
2010-05-10 20:28:26 +00:00
|
|
|
|
|
|
|
mr r4,r5
|
|
|
|
mr r5,r6
|
|
|
|
mr r6,r7
|
|
|
|
mr r7,r8
|
|
|
|
mr r8,r9
|
|
|
|
mr r9,r10
|
2012-06-25 13:33:14 +00: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-10 20:28:26 +00:00
|
|
|
|
|
|
|
HVSC /* invoke the hypervisor */
|
|
|
|
|
|
|
|
mr r0,r12
|
2012-06-25 13:33:14 +00:00
|
|
|
ld r12,STK_PARAM(R4)(r1)
|
2010-05-10 20:28:26 +00: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 */
|