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 |
| 35 | #ifdef CONFIG_KVM_AWARE_CMF |
| 36 | tm __LC_MACHINE_FLAGS+6,0x20 # MACHINE_FLAG_SPP |
| 37 | jz 0f |
| 38 | .insn s,0xb2800000,\newpp |
| 39 | 0: |
| 40 | #endif |
| 41 | .endm |
| 42 | |
| 43 | sie_irq_handler: |
| 44 | SPP __LC_CMF_HPP # set host id |
| 45 | larl %r2,sie_inst |
| 46 | clg %r2,SPI_PSW+8(0,%r15) # intercepted sie |
| 47 | jne 1f |
| 48 | xc __LC_SIE_HOOK(8),__LC_SIE_HOOK |
| 49 | lg %r2,__LC_THREAD_INFO # pointer thread_info struct |
| 50 | tm __TI_flags+7(%r2),_TIF_EXIT_SIE |
| 51 | jz 0f |
| 52 | larl %r2,sie_exit # work pending, leave sie |
| 53 | stg %r2,__LC_RETURN_PSW+8 |
| 54 | br %r14 |
| 55 | 0: larl %r2,sie_reenter # re-enter with guest id |
| 56 | stg %r2,__LC_RETURN_PSW+8 |
| 57 | 1: br %r14 |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * sie64a calling convention: |
| 61 | * %r2 pointer to sie control block |
| 62 | * %r3 guest register save area |
| 63 | */ |
| 64 | .globl sie64a |
| 65 | sie64a: |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame^] | 66 | stg %r3,SP_GREGS(%r15) # save guest register save area |
| 67 | stmg %r6,%r14,__SF_GPRS(%r15) # save registers on entry |
| 68 | lgr %r14,%r2 # pointer to sie control block |
| 69 | larl %r5,sie_irq_handler |
| 70 | stg %r2,SP_GPP(%r15) |
| 71 | stg %r5,SP_HOOK(%r15) # save hook target |
| 72 | lmg %r0,%r13,0(%r3) # load guest gprs 0-13 |
| 73 | sie_reenter: |
| 74 | mvc __LC_SIE_HOOK(8),SP_HOOK(%r15) |
| 75 | SPP SP_GPP(%r15) # set guest id |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 76 | sie_inst: |
| 77 | sie 0(%r14) |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame^] | 78 | xc __LC_SIE_HOOK(8),__LC_SIE_HOOK |
| 79 | SPP __LC_CMF_HPP # set host id |
| 80 | sie_exit: |
| 81 | lg %r14,SP_GREGS(%r15) |
| 82 | stmg %r0,%r13,0(%r14) # save guest gprs 0-13 |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 83 | lghi %r2,0 |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame^] | 84 | lmg %r6,%r14,__SF_GPRS(%r15) |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 85 | br %r14 |
| 86 | |
| 87 | sie_err: |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame^] | 88 | xc __LC_SIE_HOOK(8),__LC_SIE_HOOK |
| 89 | SPP __LC_CMF_HPP # set host id |
| 90 | lg %r14,SP_GREGS(%r15) |
| 91 | stmg %r0,%r13,0(%r14) # save guest gprs 0-13 |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 92 | lghi %r2,-EFAULT |
Carsten Otte | cd3b70f | 2010-05-17 10:00:04 +0200 | [diff] [blame^] | 93 | lmg %r6,%r14,__SF_GPRS(%r15) |
Heiko Carstens | b0c632d | 2008-03-25 18:47:20 +0100 | [diff] [blame] | 94 | br %r14 |
| 95 | |
| 96 | .section __ex_table,"a" |
| 97 | .quad sie_inst,sie_err |
| 98 | .previous |