blob: 7e9d30d567b0ab21265b669f1f343018d10de080 [file] [log] [blame]
Heiko Carstensb0c632d2008-03-25 18:47:20 +01001/*
2 * sie64a.S - low level sie call
3 *
Carsten Ottecd3b70f2010-05-17 10:00:04 +02004 * Copyright IBM Corp. 2008,2010
Heiko Carstensb0c632d2008-03-25 18:47:20 +01005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License (version 2 only)
8 * as published by the Free Software Foundation.
9 *
10 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
Carsten Ottecd3b70f2010-05-17 10:00:04 +020011 * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Heiko Carstensb0c632d2008-03-25 18:47:20 +010012 */
13
14#include <linux/errno.h>
15#include <asm/asm-offsets.h>
Carsten Ottecd3b70f2010-05-17 10:00:04 +020016#include <asm/setup.h>
17#include <asm/asm-offsets.h>
18#include <asm/ptrace.h>
19#include <asm/thread_info.h>
Heiko Carstensb0c632d2008-03-25 18:47:20 +010020
Carsten Ottecd3b70f2010-05-17 10:00:04 +020021_TIF_EXIT_SIE = (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_MCCK_PENDING)
22
23/*
24 * offsets into stackframe
25 * SP_ = offsets into stack sie64 is called with
26 * SPI_ = offsets into irq stack
27 */
28SP_GREGS = __SF_EMPTY
29SP_HOOK = __SF_EMPTY+8
30SP_GPP = __SF_EMPTY+16
31SPI_PSW = STACK_FRAME_OVERHEAD + __PT_PSW
32
33
34 .macro SPP newpp
Carsten Ottecd3b70f2010-05-17 10:00:04 +020035 tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_SPP
36 jz 0f
37 .insn s,0xb2800000,\newpp
Heiko Carstens2ffbb3f2010-05-26 23:26:21 +0200380:
Carsten Ottecd3b70f2010-05-17 10:00:04 +020039 .endm
40
41sie_irq_handler:
42 SPP __LC_CMF_HPP # set host id
43 larl %r2,sie_inst
44 clg %r2,SPI_PSW+8(0,%r15) # intercepted sie
45 jne 1f
46 xc __LC_SIE_HOOK(8),__LC_SIE_HOOK
47 lg %r2,__LC_THREAD_INFO # pointer thread_info struct
48 tm __TI_flags+7(%r2),_TIF_EXIT_SIE
49 jz 0f
50 larl %r2,sie_exit # work pending, leave sie
51 stg %r2,__LC_RETURN_PSW+8
52 br %r14
530: larl %r2,sie_reenter # re-enter with guest id
54 stg %r2,__LC_RETURN_PSW+8
551: br %r14
Heiko Carstensb0c632d2008-03-25 18:47:20 +010056
57/*
58 * sie64a calling convention:
59 * %r2 pointer to sie control block
60 * %r3 guest register save area
61 */
62 .globl sie64a
63sie64a:
Carsten Ottecd3b70f2010-05-17 10:00:04 +020064 stg %r3,SP_GREGS(%r15) # save guest register save area
65 stmg %r6,%r14,__SF_GPRS(%r15) # save registers on entry
66 lgr %r14,%r2 # pointer to sie control block
67 larl %r5,sie_irq_handler
68 stg %r2,SP_GPP(%r15)
69 stg %r5,SP_HOOK(%r15) # save hook target
70 lmg %r0,%r13,0(%r3) # load guest gprs 0-13
71sie_reenter:
72 mvc __LC_SIE_HOOK(8),SP_HOOK(%r15)
73 SPP SP_GPP(%r15) # set guest id
Heiko Carstensb0c632d2008-03-25 18:47:20 +010074sie_inst:
75 sie 0(%r14)
Carsten Ottecd3b70f2010-05-17 10:00:04 +020076 xc __LC_SIE_HOOK(8),__LC_SIE_HOOK
77 SPP __LC_CMF_HPP # set host id
78sie_exit:
79 lg %r14,SP_GREGS(%r15)
80 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
Heiko Carstensb0c632d2008-03-25 18:47:20 +010081 lghi %r2,0
Carsten Ottecd3b70f2010-05-17 10:00:04 +020082 lmg %r6,%r14,__SF_GPRS(%r15)
Heiko Carstensb0c632d2008-03-25 18:47:20 +010083 br %r14
84
85sie_err:
Carsten Ottecd3b70f2010-05-17 10:00:04 +020086 xc __LC_SIE_HOOK(8),__LC_SIE_HOOK
87 SPP __LC_CMF_HPP # set host id
88 lg %r14,SP_GREGS(%r15)
89 stmg %r0,%r13,0(%r14) # save guest gprs 0-13
Heiko Carstensb0c632d2008-03-25 18:47:20 +010090 lghi %r2,-EFAULT
Carsten Ottecd3b70f2010-05-17 10:00:04 +020091 lmg %r6,%r14,__SF_GPRS(%r15)
Heiko Carstensb0c632d2008-03-25 18:47:20 +010092 br %r14
93
94 .section __ex_table,"a"
95 .quad sie_inst,sie_err
96 .previous