Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 1 | /* |
| 2 | * sie64a.S - low level sie call |
| 3 | * |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 4 | * Copyright IBM Corp. 2008,2010 |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 5 | * |
| 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 Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 11 | * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/errno.h> |
| 15 | #include <asm/asm-offsets.h> |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 16 | #include <asm/setup.h> |
| 17 | #include <asm/asm-offsets.h> |
| 18 | #include <asm/ptrace.h> |
| 19 | #include <asm/thread_info.h> |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 20 | |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 21 | _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 | */ |
| 28 | SP_GREGS = __SF_EMPTY |
| 29 | SP_HOOK = __SF_EMPTY+8 |
| 30 | SP_GPP = __SF_EMPTY+16 |
| 31 | SPI_PSW = STACK_FRAME_OVERHEAD + __PT_PSW |
| 32 | |
| 33 | |
| 34 | .macro SPP newpp |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 35 | tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_SPP |
| 36 | jz 0f |
| 37 | .insn s,0xb2800000,\newpp |
Heiko Carstens | 2ffbb3f | 2010-05-26 23:26:21 +0200 | [diff] [blame] | 38 | 0: |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 39 | .endm |
| 40 | |
| 41 | sie_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 |
| 53 | 0: larl %r2,sie_reenter # re-enter with guest id |
| 54 | stg %r2,__LC_RETURN_PSW+8 |
| 55 | 1: br %r14 |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 56 | |
| 57 | /* |
| 58 | * sie64a calling convention: |
| 59 | * %r2 pointer to sie control block |
| 60 | * %r3 guest register save area |
| 61 | */ |
| 62 | .globl sie64a |
| 63 | sie64a: |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 64 | 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 |
| 71 | sie_reenter: |
| 72 | mvc __LC_SIE_HOOK(8),SP_HOOK(%r15) |
| 73 | SPP SP_GPP(%r15) # set guest id |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 74 | sie_inst: |
| 75 | sie 0(%r14) |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 76 | xc __LC_SIE_HOOK(8),__LC_SIE_HOOK |
| 77 | SPP __LC_CMF_HPP # set host id |
| 78 | sie_exit: |
| 79 | lg %r14,SP_GREGS(%r15) |
| 80 | stmg %r0,%r13,0(%r14) # save guest gprs 0-13 |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 81 | lghi %r2,0 |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 82 | lmg %r6,%r14,__SF_GPRS(%r15) |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 83 | br %r14 |
| 84 | |
| 85 | sie_err: |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 86 | 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 Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 90 | lghi %r2,-EFAULT |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame] | 91 | lmg %r6,%r14,__SF_GPRS(%r15) |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 92 | br %r14 |
| 93 | |
| 94 | .section __ex_table,"a" |
| 95 | .quad sie_inst,sie_err |
| 96 | .previous |