jffs2: update ctime when changing the file's permission by setfacl
[pandora-kernel.git] / arch / powerpc / kvm / book3s_64_rmhandlers.S
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License, version 2, as
4  * published by the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
14  *
15  * Copyright SUSE Linux Products GmbH 2009
16  *
17  * Authors: Alexander Graf <agraf@suse.de>
18  */
19
20 #include <asm/ppc_asm.h>
21 #include <asm/kvm_asm.h>
22 #include <asm/reg.h>
23 #include <asm/page.h>
24 #include <asm/asm-offsets.h>
25 #include <asm/exception-64s.h>
26
27 /*****************************************************************************
28  *                                                                           *
29  *        Real Mode handlers that need to be in low physical memory          *
30  *                                                                           *
31  ****************************************************************************/
32
33
34 .macro INTERRUPT_TRAMPOLINE intno
35
36 .global kvmppc_trampoline_\intno
37 kvmppc_trampoline_\intno:
38
39         mtspr   SPRN_SPRG_SCRATCH0, r13         /* Save r13 */
40
41         /*
42          * First thing to do is to find out if we're coming
43          * from a KVM guest or a Linux process.
44          *
45          * To distinguish, we check a magic byte in the PACA
46          */
47         mfspr   r13, SPRN_SPRG_PACA             /* r13 = PACA */
48         std     r12, PACA_KVM_SCRATCH0(r13)
49         mfcr    r12
50         stw     r12, PACA_KVM_SCRATCH1(r13)
51         lbz     r12, PACA_KVM_IN_GUEST(r13)
52         cmpwi   r12, KVM_GUEST_MODE_NONE
53         bne     ..kvmppc_handler_hasmagic_\intno
54         /* No KVM guest? Then jump back to the Linux handler! */
55         lwz     r12, PACA_KVM_SCRATCH1(r13)
56         mtcr    r12
57         ld      r12, PACA_KVM_SCRATCH0(r13)
58         mfspr   r13, SPRN_SPRG_SCRATCH0         /* r13 = original r13 */
59         b       kvmppc_resume_\intno            /* Get back original handler */
60
61         /* Now we know we're handling a KVM guest */
62 ..kvmppc_handler_hasmagic_\intno:
63
64         /* Should we just skip the faulting instruction? */
65         cmpwi   r12, KVM_GUEST_MODE_SKIP
66         beq     kvmppc_handler_skip_ins
67
68         /* Let's store which interrupt we're handling */
69         li      r12, \intno
70
71         /* Jump into the SLB exit code that goes to the highmem handler */
72         b       kvmppc_handler_trampoline_exit
73
74 .endm
75
76 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_SYSTEM_RESET
77 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_MACHINE_CHECK
78 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_DATA_STORAGE
79 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_DATA_SEGMENT
80 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_INST_STORAGE
81 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_INST_SEGMENT
82 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_EXTERNAL
83 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_ALIGNMENT
84 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_PROGRAM
85 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_FP_UNAVAIL
86 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_DECREMENTER
87 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_SYSCALL
88 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_TRACE
89 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_PERFMON
90 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_ALTIVEC
91 INTERRUPT_TRAMPOLINE    BOOK3S_INTERRUPT_VSX
92
93 /*
94  * Bring us back to the faulting code, but skip the
95  * faulting instruction.
96  *
97  * This is a generic exit path from the interrupt
98  * trampolines above.
99  *
100  * Input Registers:
101  *
102  * R12               = free
103  * R13               = PACA
104  * PACA.KVM.SCRATCH0 = guest R12
105  * PACA.KVM.SCRATCH1 = guest CR
106  * SPRG_SCRATCH0     = guest R13
107  *
108  */
109 kvmppc_handler_skip_ins:
110
111         /* Patch the IP to the next instruction */
112         mfsrr0  r12
113         addi    r12, r12, 4
114         mtsrr0  r12
115
116         /* Clean up all state */
117         lwz     r12, PACA_KVM_SCRATCH1(r13)
118         mtcr    r12
119         ld      r12, PACA_KVM_SCRATCH0(r13)
120         mfspr   r13, SPRN_SPRG_SCRATCH0
121
122         /* And get back into the code */
123         RFI
124
125 /*
126  * This trampoline brings us back to a real mode handler
127  *
128  * Input Registers:
129  *
130  * R5 = SRR0
131  * R6 = SRR1
132  * LR = real-mode IP
133  *
134  */
135 .global kvmppc_handler_lowmem_trampoline
136 kvmppc_handler_lowmem_trampoline:
137
138         mtsrr0  r5
139         mtsrr1  r6
140         blr
141 kvmppc_handler_lowmem_trampoline_end:
142
143 /*
144  * Call a function in real mode
145  *
146  * Input Registers:
147  *
148  * R3 = function
149  * R4 = MSR
150  * R5 = CTR
151  *
152  */
153 _GLOBAL(kvmppc_rmcall)
154         mtmsr   r4              /* Disable relocation, so mtsrr
155                                    doesn't get interrupted */
156         mtctr   r5
157         mtsrr0  r3
158         mtsrr1  r4
159         RFI
160
161 /*
162  * Activate current's external feature (FPU/Altivec/VSX)
163  */
164 #define define_load_up(what)                            \
165                                                         \
166 _GLOBAL(kvmppc_load_up_ ## what);                       \
167         subi    r1, r1, INT_FRAME_SIZE;                 \
168         mflr    r3;                                     \
169         std     r3, _LINK(r1);                          \
170         mfmsr   r4;                                     \
171         std     r31, GPR3(r1);                          \
172         mr      r31, r4;                                \
173         li      r5, MSR_DR;                             \
174         oris    r5, r5, MSR_EE@h;                       \
175         andc    r4, r4, r5;                             \
176         mtmsr   r4;                                     \
177                                                         \
178         bl      .load_up_ ## what;                      \
179                                                         \
180         mtmsr   r31;                                    \
181         ld      r3, _LINK(r1);                          \
182         ld      r31, GPR3(r1);                          \
183         addi    r1, r1, INT_FRAME_SIZE;                 \
184         mtlr    r3;                                     \
185         blr
186
187 define_load_up(fpu)
188 #ifdef CONFIG_ALTIVEC
189 define_load_up(altivec)
190 #endif
191 #ifdef CONFIG_VSX
192 define_load_up(vsx)
193 #endif
194
195 .global kvmppc_trampoline_lowmem
196 kvmppc_trampoline_lowmem:
197         .long kvmppc_handler_lowmem_trampoline - _stext
198
199 .global kvmppc_trampoline_enter
200 kvmppc_trampoline_enter:
201         .long kvmppc_handler_trampoline_enter - _stext
202
203 #include "book3s_64_slb.S"
204