~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise-security

« back to all changes in this revision

Viewing changes to arch/powerpc/kvm/book3s_interrupts.S

  • Committer: Package Import Robot
  • Author(s): Paolo Pisati, Paolo Pisati
  • Date: 2011-12-06 15:56:07 UTC
  • Revision ID: package-import@ubuntu.com-20111206155607-pcf44kv5fmhk564f
Tags: 3.2.0-1401.1
[ Paolo Pisati ]

* Rebased on top of Ubuntu-3.2.0-3.8
* Tilt-tracking @ ef2487af4bb15bdd0689631774b5a5e3a59f74e2
* Delete debian.ti-omap4/control, it shoudln't be tracked
* Fix architecture spelling (s/armel/armhf/)
* [Config] Update configs following 3.2 import
* [Config] Fix compilation: disable CODA and ARCH_OMAP3
* [Config] Fix compilation: disable Ethernet Faraday
* Update series to precise

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#define ULONG_SIZE              8
30
30
#define FUNC(name)              GLUE(.,name)
31
31
 
32
 
#define GET_SHADOW_VCPU(reg)    \
33
 
        addi    reg, r13, PACA_KVM_SVCPU
34
 
 
35
 
#define DISABLE_INTERRUPTS      \
36
 
        mfmsr   r0;             \
37
 
        rldicl  r0,r0,48,1;     \
38
 
        rotldi  r0,r0,16;       \
39
 
        mtmsrd  r0,1;           \
40
 
 
41
32
#elif defined(CONFIG_PPC_BOOK3S_32)
42
33
 
43
34
#define ULONG_SIZE              4
44
35
#define FUNC(name)              name
45
36
 
46
 
#define GET_SHADOW_VCPU(reg)    \
47
 
        lwz     reg, (THREAD + THREAD_KVM_SVCPU)(r2)
48
 
 
49
 
#define DISABLE_INTERRUPTS      \
50
 
        mfmsr   r0;             \
51
 
        rlwinm  r0,r0,0,17,15;  \
52
 
        mtmsr   r0;             \
53
 
 
54
37
#endif /* CONFIG_PPC_BOOK3S_XX */
55
38
 
56
39
 
85
68
 *  r3: kvm_run pointer
86
69
 *  r4: vcpu pointer
87
70
 */
88
 
_GLOBAL(__kvmppc_vcpu_entry)
 
71
_GLOBAL(__kvmppc_vcpu_run)
89
72
 
90
73
kvm_start_entry:
91
74
        /* Write correct stack frame */
107
90
        /* Load non-volatile guest state from the vcpu */
108
91
        VCPU_LOAD_NVGPRS(r4)
109
92
 
110
 
        GET_SHADOW_VCPU(r5)
111
 
 
112
 
        /* Save R1/R2 in the PACA */
113
 
        PPC_STL r1, SVCPU_HOST_R1(r5)
114
 
        PPC_STL r2, SVCPU_HOST_R2(r5)
115
 
 
116
 
        /* XXX swap in/out on load? */
117
 
        PPC_LL  r3, VCPU_HIGHMEM_HANDLER(r4)
118
 
        PPC_STL r3, SVCPU_VMHANDLER(r5)
119
 
 
120
93
kvm_start_lightweight:
121
94
 
122
 
        PPC_LL  r10, VCPU_SHADOW_MSR(r4)        /* r10 = vcpu->arch.shadow_msr */
123
 
 
124
 
        DISABLE_INTERRUPTS
125
 
 
126
95
#ifdef CONFIG_PPC_BOOK3S_64
127
 
        /* Some guests may need to have dcbz set to 32 byte length.
128
 
         *
129
 
         * Usually we ensure that by patching the guest's instructions
130
 
         * to trap on dcbz and emulate it in the hypervisor.
131
 
         *
132
 
         * If we can, we should tell the CPU to use 32 byte dcbz though,
133
 
         * because that's a lot faster.
134
 
         */
135
 
 
136
96
        PPC_LL  r3, VCPU_HFLAGS(r4)
137
 
        rldicl. r3, r3, 0, 63           /* CR = ((r3 & 1) == 0) */
138
 
        beq     no_dcbz32_on
139
 
 
140
 
        mfspr   r3,SPRN_HID5
141
 
        ori     r3, r3, 0x80            /* XXX HID5_dcbz32 = 0x80 */
142
 
        mtspr   SPRN_HID5,r3
143
 
 
144
 
no_dcbz32_on:
145
 
 
 
97
        rldicl  r3, r3, 0, 63           /* r3 &= 1 */
 
98
        stb     r3, HSTATE_RESTORE_HID5(r13)
146
99
#endif /* CONFIG_PPC_BOOK3S_64 */
147
100
 
148
 
        PPC_LL  r6, VCPU_RMCALL(r4)
149
 
        mtctr   r6
150
 
 
151
 
        PPC_LL  r3, VCPU_TRAMPOLINE_ENTER(r4)
152
 
        LOAD_REG_IMMEDIATE(r4, MSR_KERNEL & ~(MSR_IR | MSR_DR))
 
101
        PPC_LL  r4, VCPU_SHADOW_MSR(r4) /* get shadow_msr */
153
102
 
154
103
        /* Jump to segment patching handler and into our guest */
155
 
        bctr
 
104
        bl      FUNC(kvmppc_entry_trampoline)
 
105
        nop
156
106
 
157
107
/*
158
108
 * This is the handler in module memory. It gets jumped at from the
177
127
        /* R7 = vcpu */
178
128
        PPC_LL  r7, GPR4(r1)
179
129
 
180
 
#ifdef CONFIG_PPC_BOOK3S_64
181
 
 
182
 
        PPC_LL  r5, VCPU_HFLAGS(r7)
183
 
        rldicl. r5, r5, 0, 63           /* CR = ((r5 & 1) == 0) */
184
 
        beq     no_dcbz32_off
185
 
 
186
 
        li      r4, 0
187
 
        mfspr   r5,SPRN_HID5
188
 
        rldimi  r5,r4,6,56
189
 
        mtspr   SPRN_HID5,r5
190
 
 
191
 
no_dcbz32_off:
192
 
 
193
 
#endif /* CONFIG_PPC_BOOK3S_64 */
194
 
 
195
130
        PPC_STL r14, VCPU_GPR(r14)(r7)
196
131
        PPC_STL r15, VCPU_GPR(r15)(r7)
197
132
        PPC_STL r16, VCPU_GPR(r16)(r7)
211
146
        PPC_STL r30, VCPU_GPR(r30)(r7)
212
147
        PPC_STL r31, VCPU_GPR(r31)(r7)
213
148
 
214
 
        /* Restore host msr -> SRR1 */
215
 
        PPC_LL  r6, VCPU_HOST_MSR(r7)
216
 
 
217
 
        /*
218
 
         * For some interrupts, we need to call the real Linux
219
 
         * handler, so it can do work for us. This has to happen
220
 
         * as if the interrupt arrived from the kernel though,
221
 
         * so let's fake it here where most state is restored.
222
 
         *
223
 
         * Call Linux for hardware interrupts/decrementer
224
 
         * r3 = address of interrupt handler (exit reason)
225
 
         */
226
 
 
227
 
        cmpwi   r12, BOOK3S_INTERRUPT_EXTERNAL
228
 
        beq     call_linux_handler
229
 
        cmpwi   r12, BOOK3S_INTERRUPT_DECREMENTER
230
 
        beq     call_linux_handler
231
 
        cmpwi   r12, BOOK3S_INTERRUPT_PERFMON
232
 
        beq     call_linux_handler
233
 
 
234
 
        /* Back to EE=1 */
235
 
        mtmsr   r6
236
 
        sync
237
 
        b       kvm_return_point
238
 
 
239
 
call_linux_handler:
240
 
 
241
 
        /*
242
 
         * If we land here we need to jump back to the handler we
243
 
         * came from.
244
 
         *
245
 
         * We have a page that we can access from real mode, so let's
246
 
         * jump back to that and use it as a trampoline to get back into the
247
 
         * interrupt handler!
248
 
         *
249
 
         * R3 still contains the exit code,
250
 
         * R5 VCPU_HOST_RETIP and
251
 
         * R6 VCPU_HOST_MSR
252
 
         */
253
 
 
254
 
        /* Restore host IP -> SRR0 */
255
 
        PPC_LL  r5, VCPU_HOST_RETIP(r7)
256
 
 
257
 
        /* XXX Better move to a safe function?
258
 
         *     What if we get an HTAB flush in between mtsrr0 and mtsrr1? */
259
 
 
260
 
        mtlr    r12
261
 
 
262
 
        PPC_LL  r4, VCPU_TRAMPOLINE_LOWMEM(r7)
263
 
        mtsrr0  r4
264
 
        LOAD_REG_IMMEDIATE(r3, MSR_KERNEL & ~(MSR_IR | MSR_DR))
265
 
        mtsrr1  r3
266
 
 
267
 
        RFI
268
 
 
269
 
.global kvm_return_point
270
 
kvm_return_point:
271
 
 
272
 
        /* Jump back to lightweight entry if we're supposed to */
273
 
        /* go back into the guest */
274
 
 
275
149
        /* Pass the exit number as 3rd argument to kvmppc_handle_exit */
276
150
        mr      r5, r12
277
151