Merge branch 'kvm-updates/3.4' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[linux-3.10.git] / arch / powerpc / kvm / book3s_pr.c
1 /*
2  * Copyright (C) 2009. SUSE Linux Products GmbH. All rights reserved.
3  *
4  * Authors:
5  *    Alexander Graf <agraf@suse.de>
6  *    Kevin Wolf <mail@kevin-wolf.de>
7  *    Paul Mackerras <paulus@samba.org>
8  *
9  * Description:
10  * Functions relating to running KVM on Book 3S processors where
11  * we don't have access to hypervisor mode, and we run the guest
12  * in problem state (user mode).
13  *
14  * This file is derived from arch/powerpc/kvm/44x.c,
15  * by Hollis Blanchard <hollisb@us.ibm.com>.
16  *
17  * This program is free software; you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License, version 2, as
19  * published by the Free Software Foundation.
20  */
21
22 #include <linux/kvm_host.h>
23 #include <linux/export.h>
24 #include <linux/err.h>
25 #include <linux/slab.h>
26
27 #include <asm/reg.h>
28 #include <asm/cputable.h>
29 #include <asm/cacheflush.h>
30 #include <asm/tlbflush.h>
31 #include <asm/uaccess.h>
32 #include <asm/io.h>
33 #include <asm/kvm_ppc.h>
34 #include <asm/kvm_book3s.h>
35 #include <asm/mmu_context.h>
36 #include <linux/gfp.h>
37 #include <linux/sched.h>
38 #include <linux/vmalloc.h>
39 #include <linux/highmem.h>
40
41 #include "trace.h"
42
43 /* #define EXIT_DEBUG */
44 /* #define DEBUG_EXT */
45
46 static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
47                              ulong msr);
48
49 /* Some compatibility defines */
50 #ifdef CONFIG_PPC_BOOK3S_32
51 #define MSR_USER32 MSR_USER
52 #define MSR_USER64 MSR_USER
53 #define HW_PAGE_SIZE PAGE_SIZE
54 #define __hard_irq_disable local_irq_disable
55 #define __hard_irq_enable local_irq_enable
56 #endif
57
58 void kvmppc_core_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
59 {
60 #ifdef CONFIG_PPC_BOOK3S_64
61         struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
62         memcpy(svcpu->slb, to_book3s(vcpu)->slb_shadow, sizeof(svcpu->slb));
63         memcpy(&get_paca()->shadow_vcpu, to_book3s(vcpu)->shadow_vcpu,
64                sizeof(get_paca()->shadow_vcpu));
65         svcpu->slb_max = to_book3s(vcpu)->slb_shadow_max;
66         svcpu_put(svcpu);
67 #endif
68
69 #ifdef CONFIG_PPC_BOOK3S_32
70         current->thread.kvm_shadow_vcpu = to_book3s(vcpu)->shadow_vcpu;
71 #endif
72 }
73
74 void kvmppc_core_vcpu_put(struct kvm_vcpu *vcpu)
75 {
76 #ifdef CONFIG_PPC_BOOK3S_64
77         struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
78         memcpy(to_book3s(vcpu)->slb_shadow, svcpu->slb, sizeof(svcpu->slb));
79         memcpy(to_book3s(vcpu)->shadow_vcpu, &get_paca()->shadow_vcpu,
80                sizeof(get_paca()->shadow_vcpu));
81         to_book3s(vcpu)->slb_shadow_max = svcpu->slb_max;
82         svcpu_put(svcpu);
83 #endif
84
85         kvmppc_giveup_ext(vcpu, MSR_FP);
86         kvmppc_giveup_ext(vcpu, MSR_VEC);
87         kvmppc_giveup_ext(vcpu, MSR_VSX);
88 }
89
90 static void kvmppc_recalc_shadow_msr(struct kvm_vcpu *vcpu)
91 {
92         ulong smsr = vcpu->arch.shared->msr;
93
94         /* Guest MSR values */
95         smsr &= MSR_FE0 | MSR_FE1 | MSR_SF | MSR_SE | MSR_BE | MSR_DE;
96         /* Process MSR values */
97         smsr |= MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_PR | MSR_EE;
98         /* External providers the guest reserved */
99         smsr |= (vcpu->arch.shared->msr & vcpu->arch.guest_owned_ext);
100         /* 64-bit Process MSR values */
101 #ifdef CONFIG_PPC_BOOK3S_64
102         smsr |= MSR_ISF | MSR_HV;
103 #endif
104         vcpu->arch.shadow_msr = smsr;
105 }
106
107 void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 msr)
108 {
109         ulong old_msr = vcpu->arch.shared->msr;
110
111 #ifdef EXIT_DEBUG
112         printk(KERN_INFO "KVM: Set MSR to 0x%llx\n", msr);
113 #endif
114
115         msr &= to_book3s(vcpu)->msr_mask;
116         vcpu->arch.shared->msr = msr;
117         kvmppc_recalc_shadow_msr(vcpu);
118
119         if (msr & MSR_POW) {
120                 if (!vcpu->arch.pending_exceptions) {
121                         kvm_vcpu_block(vcpu);
122                         vcpu->stat.halt_wakeup++;
123
124                         /* Unset POW bit after we woke up */
125                         msr &= ~MSR_POW;
126                         vcpu->arch.shared->msr = msr;
127                 }
128         }
129
130         if ((vcpu->arch.shared->msr & (MSR_PR|MSR_IR|MSR_DR)) !=
131                    (old_msr & (MSR_PR|MSR_IR|MSR_DR))) {
132                 kvmppc_mmu_flush_segments(vcpu);
133                 kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu));
134
135                 /* Preload magic page segment when in kernel mode */
136                 if (!(msr & MSR_PR) && vcpu->arch.magic_page_pa) {
137                         struct kvm_vcpu_arch *a = &vcpu->arch;
138
139                         if (msr & MSR_DR)
140                                 kvmppc_mmu_map_segment(vcpu, a->magic_page_ea);
141                         else
142                                 kvmppc_mmu_map_segment(vcpu, a->magic_page_pa);
143                 }
144         }
145
146         /* Preload FPU if it's enabled */
147         if (vcpu->arch.shared->msr & MSR_FP)
148                 kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP);
149 }
150
151 void kvmppc_set_pvr(struct kvm_vcpu *vcpu, u32 pvr)
152 {
153         u32 host_pvr;
154
155         vcpu->arch.hflags &= ~BOOK3S_HFLAG_SLB;
156         vcpu->arch.pvr = pvr;
157 #ifdef CONFIG_PPC_BOOK3S_64
158         if ((pvr >= 0x330000) && (pvr < 0x70330000)) {
159                 kvmppc_mmu_book3s_64_init(vcpu);
160                 if (!to_book3s(vcpu)->hior_explicit)
161                         to_book3s(vcpu)->hior = 0xfff00000;
162                 to_book3s(vcpu)->msr_mask = 0xffffffffffffffffULL;
163                 vcpu->arch.cpu_type = KVM_CPU_3S_64;
164         } else
165 #endif
166         {
167                 kvmppc_mmu_book3s_32_init(vcpu);
168                 if (!to_book3s(vcpu)->hior_explicit)
169                         to_book3s(vcpu)->hior = 0;
170                 to_book3s(vcpu)->msr_mask = 0xffffffffULL;
171                 vcpu->arch.cpu_type = KVM_CPU_3S_32;
172         }
173
174         kvmppc_sanity_check(vcpu);
175
176         /* If we are in hypervisor level on 970, we can tell the CPU to
177          * treat DCBZ as 32 bytes store */
178         vcpu->arch.hflags &= ~BOOK3S_HFLAG_DCBZ32;
179         if (vcpu->arch.mmu.is_dcbz32(vcpu) && (mfmsr() & MSR_HV) &&
180             !strcmp(cur_cpu_spec->platform, "ppc970"))
181                 vcpu->arch.hflags |= BOOK3S_HFLAG_DCBZ32;
182
183         /* Cell performs badly if MSR_FEx are set. So let's hope nobody
184            really needs them in a VM on Cell and force disable them. */
185         if (!strcmp(cur_cpu_spec->platform, "ppc-cell-be"))
186                 to_book3s(vcpu)->msr_mask &= ~(MSR_FE0 | MSR_FE1);
187
188 #ifdef CONFIG_PPC_BOOK3S_32
189         /* 32 bit Book3S always has 32 byte dcbz */
190         vcpu->arch.hflags |= BOOK3S_HFLAG_DCBZ32;
191 #endif
192
193         /* On some CPUs we can execute paired single operations natively */
194         asm ( "mfpvr %0" : "=r"(host_pvr));
195         switch (host_pvr) {
196         case 0x00080200:        /* lonestar 2.0 */
197         case 0x00088202:        /* lonestar 2.2 */
198         case 0x70000100:        /* gekko 1.0 */
199         case 0x00080100:        /* gekko 2.0 */
200         case 0x00083203:        /* gekko 2.3a */
201         case 0x00083213:        /* gekko 2.3b */
202         case 0x00083204:        /* gekko 2.4 */
203         case 0x00083214:        /* gekko 2.4e (8SE) - retail HW2 */
204         case 0x00087200:        /* broadway */
205                 vcpu->arch.hflags |= BOOK3S_HFLAG_NATIVE_PS;
206                 /* Enable HID2.PSE - in case we need it later */
207                 mtspr(SPRN_HID2_GEKKO, mfspr(SPRN_HID2_GEKKO) | (1 << 29));
208         }
209 }
210
211 /* Book3s_32 CPUs always have 32 bytes cache line size, which Linux assumes. To
212  * make Book3s_32 Linux work on Book3s_64, we have to make sure we trap dcbz to
213  * emulate 32 bytes dcbz length.
214  *
215  * The Book3s_64 inventors also realized this case and implemented a special bit
216  * in the HID5 register, which is a hypervisor ressource. Thus we can't use it.
217  *
218  * My approach here is to patch the dcbz instruction on executing pages.
219  */
220 static void kvmppc_patch_dcbz(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte)
221 {
222         struct page *hpage;
223         u64 hpage_offset;
224         u32 *page;
225         int i;
226
227         hpage = gfn_to_page(vcpu->kvm, pte->raddr >> PAGE_SHIFT);
228         if (is_error_page(hpage)) {
229                 kvm_release_page_clean(hpage);
230                 return;
231         }
232
233         hpage_offset = pte->raddr & ~PAGE_MASK;
234         hpage_offset &= ~0xFFFULL;
235         hpage_offset /= 4;
236
237         get_page(hpage);
238         page = kmap_atomic(hpage);
239
240         /* patch dcbz into reserved instruction, so we trap */
241         for (i=hpage_offset; i < hpage_offset + (HW_PAGE_SIZE / 4); i++)
242                 if ((page[i] & 0xff0007ff) == INS_DCBZ)
243                         page[i] &= 0xfffffff7;
244
245         kunmap_atomic(page);
246         put_page(hpage);
247 }
248
249 static int kvmppc_visible_gfn(struct kvm_vcpu *vcpu, gfn_t gfn)
250 {
251         ulong mp_pa = vcpu->arch.magic_page_pa;
252
253         if (unlikely(mp_pa) &&
254             unlikely((mp_pa & KVM_PAM) >> PAGE_SHIFT == gfn)) {
255                 return 1;
256         }
257
258         return kvm_is_visible_gfn(vcpu->kvm, gfn);
259 }
260
261 int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
262                             ulong eaddr, int vec)
263 {
264         bool data = (vec == BOOK3S_INTERRUPT_DATA_STORAGE);
265         int r = RESUME_GUEST;
266         int relocated;
267         int page_found = 0;
268         struct kvmppc_pte pte;
269         bool is_mmio = false;
270         bool dr = (vcpu->arch.shared->msr & MSR_DR) ? true : false;
271         bool ir = (vcpu->arch.shared->msr & MSR_IR) ? true : false;
272         u64 vsid;
273
274         relocated = data ? dr : ir;
275
276         /* Resolve real address if translation turned on */
277         if (relocated) {
278                 page_found = vcpu->arch.mmu.xlate(vcpu, eaddr, &pte, data);
279         } else {
280                 pte.may_execute = true;
281                 pte.may_read = true;
282                 pte.may_write = true;
283                 pte.raddr = eaddr & KVM_PAM;
284                 pte.eaddr = eaddr;
285                 pte.vpage = eaddr >> 12;
286         }
287
288         switch (vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) {
289         case 0:
290                 pte.vpage |= ((u64)VSID_REAL << (SID_SHIFT - 12));
291                 break;
292         case MSR_DR:
293         case MSR_IR:
294                 vcpu->arch.mmu.esid_to_vsid(vcpu, eaddr >> SID_SHIFT, &vsid);
295
296                 if ((vcpu->arch.shared->msr & (MSR_DR|MSR_IR)) == MSR_DR)
297                         pte.vpage |= ((u64)VSID_REAL_DR << (SID_SHIFT - 12));
298                 else
299                         pte.vpage |= ((u64)VSID_REAL_IR << (SID_SHIFT - 12));
300                 pte.vpage |= vsid;
301
302                 if (vsid == -1)
303                         page_found = -EINVAL;
304                 break;
305         }
306
307         if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
308            (!(vcpu->arch.hflags & BOOK3S_HFLAG_DCBZ32))) {
309                 /*
310                  * If we do the dcbz hack, we have to NX on every execution,
311                  * so we can patch the executing code. This renders our guest
312                  * NX-less.
313                  */
314                 pte.may_execute = !data;
315         }
316
317         if (page_found == -ENOENT) {
318                 /* Page not found in guest PTE entries */
319                 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
320                 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
321                 vcpu->arch.shared->dsisr = svcpu->fault_dsisr;
322                 vcpu->arch.shared->msr |=
323                         (svcpu->shadow_srr1 & 0x00000000f8000000ULL);
324                 svcpu_put(svcpu);
325                 kvmppc_book3s_queue_irqprio(vcpu, vec);
326         } else if (page_found == -EPERM) {
327                 /* Storage protection */
328                 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
329                 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
330                 vcpu->arch.shared->dsisr = svcpu->fault_dsisr & ~DSISR_NOHPTE;
331                 vcpu->arch.shared->dsisr |= DSISR_PROTFAULT;
332                 vcpu->arch.shared->msr |=
333                         svcpu->shadow_srr1 & 0x00000000f8000000ULL;
334                 svcpu_put(svcpu);
335                 kvmppc_book3s_queue_irqprio(vcpu, vec);
336         } else if (page_found == -EINVAL) {
337                 /* Page not found in guest SLB */
338                 vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
339                 kvmppc_book3s_queue_irqprio(vcpu, vec + 0x80);
340         } else if (!is_mmio &&
341                    kvmppc_visible_gfn(vcpu, pte.raddr >> PAGE_SHIFT)) {
342                 /* The guest's PTE is not mapped yet. Map on the host */
343                 kvmppc_mmu_map_page(vcpu, &pte);
344                 if (data)
345                         vcpu->stat.sp_storage++;
346                 else if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
347                         (!(vcpu->arch.hflags & BOOK3S_HFLAG_DCBZ32)))
348                         kvmppc_patch_dcbz(vcpu, &pte);
349         } else {
350                 /* MMIO */
351                 vcpu->stat.mmio_exits++;
352                 vcpu->arch.paddr_accessed = pte.raddr;
353                 r = kvmppc_emulate_mmio(run, vcpu);
354                 if ( r == RESUME_HOST_NV )
355                         r = RESUME_HOST;
356         }
357
358         return r;
359 }
360
361 static inline int get_fpr_index(int i)
362 {
363 #ifdef CONFIG_VSX
364         i *= 2;
365 #endif
366         return i;
367 }
368
369 /* Give up external provider (FPU, Altivec, VSX) */
370 void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr)
371 {
372         struct thread_struct *t = &current->thread;
373         u64 *vcpu_fpr = vcpu->arch.fpr;
374 #ifdef CONFIG_VSX
375         u64 *vcpu_vsx = vcpu->arch.vsr;
376 #endif
377         u64 *thread_fpr = (u64*)t->fpr;
378         int i;
379
380         if (!(vcpu->arch.guest_owned_ext & msr))
381                 return;
382
383 #ifdef DEBUG_EXT
384         printk(KERN_INFO "Giving up ext 0x%lx\n", msr);
385 #endif
386
387         switch (msr) {
388         case MSR_FP:
389                 giveup_fpu(current);
390                 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++)
391                         vcpu_fpr[i] = thread_fpr[get_fpr_index(i)];
392
393                 vcpu->arch.fpscr = t->fpscr.val;
394                 break;
395         case MSR_VEC:
396 #ifdef CONFIG_ALTIVEC
397                 giveup_altivec(current);
398                 memcpy(vcpu->arch.vr, t->vr, sizeof(vcpu->arch.vr));
399                 vcpu->arch.vscr = t->vscr;
400 #endif
401                 break;
402         case MSR_VSX:
403 #ifdef CONFIG_VSX
404                 __giveup_vsx(current);
405                 for (i = 0; i < ARRAY_SIZE(vcpu->arch.vsr); i++)
406                         vcpu_vsx[i] = thread_fpr[get_fpr_index(i) + 1];
407 #endif
408                 break;
409         default:
410                 BUG();
411         }
412
413         vcpu->arch.guest_owned_ext &= ~msr;
414         current->thread.regs->msr &= ~msr;
415         kvmppc_recalc_shadow_msr(vcpu);
416 }
417
418 static int kvmppc_read_inst(struct kvm_vcpu *vcpu)
419 {
420         ulong srr0 = kvmppc_get_pc(vcpu);
421         u32 last_inst = kvmppc_get_last_inst(vcpu);
422         int ret;
423
424         ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &last_inst, false);
425         if (ret == -ENOENT) {
426                 ulong msr = vcpu->arch.shared->msr;
427
428                 msr = kvmppc_set_field(msr, 33, 33, 1);
429                 msr = kvmppc_set_field(msr, 34, 36, 0);
430                 vcpu->arch.shared->msr = kvmppc_set_field(msr, 42, 47, 0);
431                 kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_INST_STORAGE);
432                 return EMULATE_AGAIN;
433         }
434
435         return EMULATE_DONE;
436 }
437
438 static int kvmppc_check_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr)
439 {
440
441         /* Need to do paired single emulation? */
442         if (!(vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE))
443                 return EMULATE_DONE;
444
445         /* Read out the instruction */
446         if (kvmppc_read_inst(vcpu) == EMULATE_DONE)
447                 /* Need to emulate */
448                 return EMULATE_FAIL;
449
450         return EMULATE_AGAIN;
451 }
452
453 /* Handle external providers (FPU, Altivec, VSX) */
454 static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
455                              ulong msr)
456 {
457         struct thread_struct *t = &current->thread;
458         u64 *vcpu_fpr = vcpu->arch.fpr;
459 #ifdef CONFIG_VSX
460         u64 *vcpu_vsx = vcpu->arch.vsr;
461 #endif
462         u64 *thread_fpr = (u64*)t->fpr;
463         int i;
464
465         /* When we have paired singles, we emulate in software */
466         if (vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE)
467                 return RESUME_GUEST;
468
469         if (!(vcpu->arch.shared->msr & msr)) {
470                 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
471                 return RESUME_GUEST;
472         }
473
474         /* We already own the ext */
475         if (vcpu->arch.guest_owned_ext & msr) {
476                 return RESUME_GUEST;
477         }
478
479 #ifdef DEBUG_EXT
480         printk(KERN_INFO "Loading up ext 0x%lx\n", msr);
481 #endif
482
483         current->thread.regs->msr |= msr;
484
485         switch (msr) {
486         case MSR_FP:
487                 for (i = 0; i < ARRAY_SIZE(vcpu->arch.fpr); i++)
488                         thread_fpr[get_fpr_index(i)] = vcpu_fpr[i];
489
490                 t->fpscr.val = vcpu->arch.fpscr;
491                 t->fpexc_mode = 0;
492                 kvmppc_load_up_fpu();
493                 break;
494         case MSR_VEC:
495 #ifdef CONFIG_ALTIVEC
496                 memcpy(t->vr, vcpu->arch.vr, sizeof(vcpu->arch.vr));
497                 t->vscr = vcpu->arch.vscr;
498                 t->vrsave = -1;
499                 kvmppc_load_up_altivec();
500 #endif
501                 break;
502         case MSR_VSX:
503 #ifdef CONFIG_VSX
504                 for (i = 0; i < ARRAY_SIZE(vcpu->arch.vsr); i++)
505                         thread_fpr[get_fpr_index(i) + 1] = vcpu_vsx[i];
506                 kvmppc_load_up_vsx();
507 #endif
508                 break;
509         default:
510                 BUG();
511         }
512
513         vcpu->arch.guest_owned_ext |= msr;
514
515         kvmppc_recalc_shadow_msr(vcpu);
516
517         return RESUME_GUEST;
518 }
519
520 int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
521                        unsigned int exit_nr)
522 {
523         int r = RESUME_HOST;
524
525         vcpu->stat.sum_exits++;
526
527         run->exit_reason = KVM_EXIT_UNKNOWN;
528         run->ready_for_interrupt_injection = 1;
529
530         trace_kvm_book3s_exit(exit_nr, vcpu);
531         preempt_enable();
532         kvm_resched(vcpu);
533         switch (exit_nr) {
534         case BOOK3S_INTERRUPT_INST_STORAGE:
535         {
536                 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
537                 ulong shadow_srr1 = svcpu->shadow_srr1;
538                 vcpu->stat.pf_instruc++;
539
540 #ifdef CONFIG_PPC_BOOK3S_32
541                 /* We set segments as unused segments when invalidating them. So
542                  * treat the respective fault as segment fault. */
543                 if (svcpu->sr[kvmppc_get_pc(vcpu) >> SID_SHIFT] == SR_INVALID) {
544                         kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu));
545                         r = RESUME_GUEST;
546                         svcpu_put(svcpu);
547                         break;
548                 }
549 #endif
550                 svcpu_put(svcpu);
551
552                 /* only care about PTEG not found errors, but leave NX alone */
553                 if (shadow_srr1 & 0x40000000) {
554                         r = kvmppc_handle_pagefault(run, vcpu, kvmppc_get_pc(vcpu), exit_nr);
555                         vcpu->stat.sp_instruc++;
556                 } else if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
557                           (!(vcpu->arch.hflags & BOOK3S_HFLAG_DCBZ32))) {
558                         /*
559                          * XXX If we do the dcbz hack we use the NX bit to flush&patch the page,
560                          *     so we can't use the NX bit inside the guest. Let's cross our fingers,
561                          *     that no guest that needs the dcbz hack does NX.
562                          */
563                         kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL);
564                         r = RESUME_GUEST;
565                 } else {
566                         vcpu->arch.shared->msr |= shadow_srr1 & 0x58000000;
567                         kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
568                         r = RESUME_GUEST;
569                 }
570                 break;
571         }
572         case BOOK3S_INTERRUPT_DATA_STORAGE:
573         {
574                 ulong dar = kvmppc_get_fault_dar(vcpu);
575                 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
576                 u32 fault_dsisr = svcpu->fault_dsisr;
577                 vcpu->stat.pf_storage++;
578
579 #ifdef CONFIG_PPC_BOOK3S_32
580                 /* We set segments as unused segments when invalidating them. So
581                  * treat the respective fault as segment fault. */
582                 if ((svcpu->sr[dar >> SID_SHIFT]) == SR_INVALID) {
583                         kvmppc_mmu_map_segment(vcpu, dar);
584                         r = RESUME_GUEST;
585                         svcpu_put(svcpu);
586                         break;
587                 }
588 #endif
589                 svcpu_put(svcpu);
590
591                 /* The only case we need to handle is missing shadow PTEs */
592                 if (fault_dsisr & DSISR_NOHPTE) {
593                         r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr);
594                 } else {
595                         vcpu->arch.shared->dar = dar;
596                         vcpu->arch.shared->dsisr = fault_dsisr;
597                         kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
598                         r = RESUME_GUEST;
599                 }
600                 break;
601         }
602         case BOOK3S_INTERRUPT_DATA_SEGMENT:
603                 if (kvmppc_mmu_map_segment(vcpu, kvmppc_get_fault_dar(vcpu)) < 0) {
604                         vcpu->arch.shared->dar = kvmppc_get_fault_dar(vcpu);
605                         kvmppc_book3s_queue_irqprio(vcpu,
606                                 BOOK3S_INTERRUPT_DATA_SEGMENT);
607                 }
608                 r = RESUME_GUEST;
609                 break;
610         case BOOK3S_INTERRUPT_INST_SEGMENT:
611                 if (kvmppc_mmu_map_segment(vcpu, kvmppc_get_pc(vcpu)) < 0) {
612                         kvmppc_book3s_queue_irqprio(vcpu,
613                                 BOOK3S_INTERRUPT_INST_SEGMENT);
614                 }
615                 r = RESUME_GUEST;
616                 break;
617         /* We're good on these - the host merely wanted to get our attention */
618         case BOOK3S_INTERRUPT_DECREMENTER:
619                 vcpu->stat.dec_exits++;
620                 r = RESUME_GUEST;
621                 break;
622         case BOOK3S_INTERRUPT_EXTERNAL:
623                 vcpu->stat.ext_intr_exits++;
624                 r = RESUME_GUEST;
625                 break;
626         case BOOK3S_INTERRUPT_PERFMON:
627                 r = RESUME_GUEST;
628                 break;
629         case BOOK3S_INTERRUPT_PROGRAM:
630         {
631                 enum emulation_result er;
632                 struct kvmppc_book3s_shadow_vcpu *svcpu;
633                 ulong flags;
634
635 program_interrupt:
636                 svcpu = svcpu_get(vcpu);
637                 flags = svcpu->shadow_srr1 & 0x1f0000ull;
638                 svcpu_put(svcpu);
639
640                 if (vcpu->arch.shared->msr & MSR_PR) {
641 #ifdef EXIT_DEBUG
642                         printk(KERN_INFO "Userspace triggered 0x700 exception at 0x%lx (0x%x)\n", kvmppc_get_pc(vcpu), kvmppc_get_last_inst(vcpu));
643 #endif
644                         if ((kvmppc_get_last_inst(vcpu) & 0xff0007ff) !=
645                             (INS_DCBZ & 0xfffffff7)) {
646                                 kvmppc_core_queue_program(vcpu, flags);
647                                 r = RESUME_GUEST;
648                                 break;
649                         }
650                 }
651
652                 vcpu->stat.emulated_inst_exits++;
653                 er = kvmppc_emulate_instruction(run, vcpu);
654                 switch (er) {
655                 case EMULATE_DONE:
656                         r = RESUME_GUEST_NV;
657                         break;
658                 case EMULATE_AGAIN:
659                         r = RESUME_GUEST;
660                         break;
661                 case EMULATE_FAIL:
662                         printk(KERN_CRIT "%s: emulation at %lx failed (%08x)\n",
663                                __func__, kvmppc_get_pc(vcpu), kvmppc_get_last_inst(vcpu));
664                         kvmppc_core_queue_program(vcpu, flags);
665                         r = RESUME_GUEST;
666                         break;
667                 case EMULATE_DO_MMIO:
668                         run->exit_reason = KVM_EXIT_MMIO;
669                         r = RESUME_HOST_NV;
670                         break;
671                 default:
672                         BUG();
673                 }
674                 break;
675         }
676         case BOOK3S_INTERRUPT_SYSCALL:
677                 if (vcpu->arch.papr_enabled &&
678                     (kvmppc_get_last_inst(vcpu) == 0x44000022) &&
679                     !(vcpu->arch.shared->msr & MSR_PR)) {
680                         /* SC 1 papr hypercalls */
681                         ulong cmd = kvmppc_get_gpr(vcpu, 3);
682                         int i;
683
684 #ifdef CONFIG_KVM_BOOK3S_64_PR
685                         if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE) {
686                                 r = RESUME_GUEST;
687                                 break;
688                         }
689 #endif
690
691                         run->papr_hcall.nr = cmd;
692                         for (i = 0; i < 9; ++i) {
693                                 ulong gpr = kvmppc_get_gpr(vcpu, 4 + i);
694                                 run->papr_hcall.args[i] = gpr;
695                         }
696                         run->exit_reason = KVM_EXIT_PAPR_HCALL;
697                         vcpu->arch.hcall_needed = 1;
698                         r = RESUME_HOST;
699                 } else if (vcpu->arch.osi_enabled &&
700                     (((u32)kvmppc_get_gpr(vcpu, 3)) == OSI_SC_MAGIC_R3) &&
701                     (((u32)kvmppc_get_gpr(vcpu, 4)) == OSI_SC_MAGIC_R4)) {
702                         /* MOL hypercalls */
703                         u64 *gprs = run->osi.gprs;
704                         int i;
705
706                         run->exit_reason = KVM_EXIT_OSI;
707                         for (i = 0; i < 32; i++)
708                                 gprs[i] = kvmppc_get_gpr(vcpu, i);
709                         vcpu->arch.osi_needed = 1;
710                         r = RESUME_HOST_NV;
711                 } else if (!(vcpu->arch.shared->msr & MSR_PR) &&
712                     (((u32)kvmppc_get_gpr(vcpu, 0)) == KVM_SC_MAGIC_R0)) {
713                         /* KVM PV hypercalls */
714                         kvmppc_set_gpr(vcpu, 3, kvmppc_kvm_pv(vcpu));
715                         r = RESUME_GUEST;
716                 } else {
717                         /* Guest syscalls */
718                         vcpu->stat.syscall_exits++;
719                         kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
720                         r = RESUME_GUEST;
721                 }
722                 break;
723         case BOOK3S_INTERRUPT_FP_UNAVAIL:
724         case BOOK3S_INTERRUPT_ALTIVEC:
725         case BOOK3S_INTERRUPT_VSX:
726         {
727                 int ext_msr = 0;
728
729                 switch (exit_nr) {
730                 case BOOK3S_INTERRUPT_FP_UNAVAIL: ext_msr = MSR_FP;  break;
731                 case BOOK3S_INTERRUPT_ALTIVEC:    ext_msr = MSR_VEC; break;
732                 case BOOK3S_INTERRUPT_VSX:        ext_msr = MSR_VSX; break;
733                 }
734
735                 switch (kvmppc_check_ext(vcpu, exit_nr)) {
736                 case EMULATE_DONE:
737                         /* everything ok - let's enable the ext */
738                         r = kvmppc_handle_ext(vcpu, exit_nr, ext_msr);
739                         break;
740                 case EMULATE_FAIL:
741                         /* we need to emulate this instruction */
742                         goto program_interrupt;
743                         break;
744                 default:
745                         /* nothing to worry about - go again */
746                         break;
747                 }
748                 break;
749         }
750         case BOOK3S_INTERRUPT_ALIGNMENT:
751                 if (kvmppc_read_inst(vcpu) == EMULATE_DONE) {
752                         vcpu->arch.shared->dsisr = kvmppc_alignment_dsisr(vcpu,
753                                 kvmppc_get_last_inst(vcpu));
754                         vcpu->arch.shared->dar = kvmppc_alignment_dar(vcpu,
755                                 kvmppc_get_last_inst(vcpu));
756                         kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
757                 }
758                 r = RESUME_GUEST;
759                 break;
760         case BOOK3S_INTERRUPT_MACHINE_CHECK:
761         case BOOK3S_INTERRUPT_TRACE:
762                 kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
763                 r = RESUME_GUEST;
764                 break;
765         default:
766         {
767                 struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
768                 ulong shadow_srr1 = svcpu->shadow_srr1;
769                 svcpu_put(svcpu);
770                 /* Ugh - bork here! What did we get? */
771                 printk(KERN_EMERG "exit_nr=0x%x | pc=0x%lx | msr=0x%lx\n",
772                         exit_nr, kvmppc_get_pc(vcpu), shadow_srr1);
773                 r = RESUME_HOST;
774                 BUG();
775                 break;
776         }
777         }
778
779         if (!(r & RESUME_HOST)) {
780                 /* To avoid clobbering exit_reason, only check for signals if
781                  * we aren't already exiting to userspace for some other
782                  * reason. */
783
784                 /*
785                  * Interrupts could be timers for the guest which we have to
786                  * inject again, so let's postpone them until we're in the guest
787                  * and if we really did time things so badly, then we just exit
788                  * again due to a host external interrupt.
789                  */
790                 __hard_irq_disable();
791                 if (signal_pending(current)) {
792                         __hard_irq_enable();
793 #ifdef EXIT_DEBUG
794                         printk(KERN_EMERG "KVM: Going back to host\n");
795 #endif
796                         vcpu->stat.signal_exits++;
797                         run->exit_reason = KVM_EXIT_INTR;
798                         r = -EINTR;
799                 } else {
800                         preempt_disable();
801
802                         /* In case an interrupt came in that was triggered
803                          * from userspace (like DEC), we need to check what
804                          * to inject now! */
805                         kvmppc_core_prepare_to_enter(vcpu);
806                 }
807         }
808
809         trace_kvm_book3s_reenter(r, vcpu);
810
811         return r;
812 }
813
814 int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
815                                   struct kvm_sregs *sregs)
816 {
817         struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
818         int i;
819
820         sregs->pvr = vcpu->arch.pvr;
821
822         sregs->u.s.sdr1 = to_book3s(vcpu)->sdr1;
823         if (vcpu->arch.hflags & BOOK3S_HFLAG_SLB) {
824                 for (i = 0; i < 64; i++) {
825                         sregs->u.s.ppc64.slb[i].slbe = vcpu->arch.slb[i].orige | i;
826                         sregs->u.s.ppc64.slb[i].slbv = vcpu->arch.slb[i].origv;
827                 }
828         } else {
829                 for (i = 0; i < 16; i++)
830                         sregs->u.s.ppc32.sr[i] = vcpu->arch.shared->sr[i];
831
832                 for (i = 0; i < 8; i++) {
833                         sregs->u.s.ppc32.ibat[i] = vcpu3s->ibat[i].raw;
834                         sregs->u.s.ppc32.dbat[i] = vcpu3s->dbat[i].raw;
835                 }
836         }
837
838         return 0;
839 }
840
841 int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
842                                   struct kvm_sregs *sregs)
843 {
844         struct kvmppc_vcpu_book3s *vcpu3s = to_book3s(vcpu);
845         int i;
846
847         kvmppc_set_pvr(vcpu, sregs->pvr);
848
849         vcpu3s->sdr1 = sregs->u.s.sdr1;
850         if (vcpu->arch.hflags & BOOK3S_HFLAG_SLB) {
851                 for (i = 0; i < 64; i++) {
852                         vcpu->arch.mmu.slbmte(vcpu, sregs->u.s.ppc64.slb[i].slbv,
853                                                     sregs->u.s.ppc64.slb[i].slbe);
854                 }
855         } else {
856                 for (i = 0; i < 16; i++) {
857                         vcpu->arch.mmu.mtsrin(vcpu, i, sregs->u.s.ppc32.sr[i]);
858                 }
859                 for (i = 0; i < 8; i++) {
860                         kvmppc_set_bat(vcpu, &(vcpu3s->ibat[i]), false,
861                                        (u32)sregs->u.s.ppc32.ibat[i]);
862                         kvmppc_set_bat(vcpu, &(vcpu3s->ibat[i]), true,
863                                        (u32)(sregs->u.s.ppc32.ibat[i] >> 32));
864                         kvmppc_set_bat(vcpu, &(vcpu3s->dbat[i]), false,
865                                        (u32)sregs->u.s.ppc32.dbat[i]);
866                         kvmppc_set_bat(vcpu, &(vcpu3s->dbat[i]), true,
867                                        (u32)(sregs->u.s.ppc32.dbat[i] >> 32));
868                 }
869         }
870
871         /* Flush the MMU after messing with the segments */
872         kvmppc_mmu_pte_flush(vcpu, 0, 0);
873
874         return 0;
875 }
876
877 int kvm_vcpu_ioctl_get_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
878 {
879         int r = -EINVAL;
880
881         switch (reg->id) {
882         case KVM_REG_PPC_HIOR:
883                 r = put_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
884                 break;
885         default:
886                 break;
887         }
888
889         return r;
890 }
891
892 int kvm_vcpu_ioctl_set_one_reg(struct kvm_vcpu *vcpu, struct kvm_one_reg *reg)
893 {
894         int r = -EINVAL;
895
896         switch (reg->id) {
897         case KVM_REG_PPC_HIOR:
898                 r = get_user(to_book3s(vcpu)->hior, (u64 __user *)reg->addr);
899                 if (!r)
900                         to_book3s(vcpu)->hior_explicit = true;
901                 break;
902         default:
903                 break;
904         }
905
906         return r;
907 }
908
909 int kvmppc_core_check_processor_compat(void)
910 {
911         return 0;
912 }
913
914 struct kvm_vcpu *kvmppc_core_vcpu_create(struct kvm *kvm, unsigned int id)
915 {
916         struct kvmppc_vcpu_book3s *vcpu_book3s;
917         struct kvm_vcpu *vcpu;
918         int err = -ENOMEM;
919         unsigned long p;
920
921         vcpu_book3s = vzalloc(sizeof(struct kvmppc_vcpu_book3s));
922         if (!vcpu_book3s)
923                 goto out;
924
925         vcpu_book3s->shadow_vcpu = (struct kvmppc_book3s_shadow_vcpu *)
926                 kzalloc(sizeof(*vcpu_book3s->shadow_vcpu), GFP_KERNEL);
927         if (!vcpu_book3s->shadow_vcpu)
928                 goto free_vcpu;
929
930         vcpu = &vcpu_book3s->vcpu;
931         err = kvm_vcpu_init(vcpu, kvm, id);
932         if (err)
933                 goto free_shadow_vcpu;
934
935         p = __get_free_page(GFP_KERNEL|__GFP_ZERO);
936         /* the real shared page fills the last 4k of our page */
937         vcpu->arch.shared = (void*)(p + PAGE_SIZE - 4096);
938         if (!p)
939                 goto uninit_vcpu;
940
941 #ifdef CONFIG_PPC_BOOK3S_64
942         /* default to book3s_64 (970fx) */
943         vcpu->arch.pvr = 0x3C0301;
944 #else
945         /* default to book3s_32 (750) */
946         vcpu->arch.pvr = 0x84202;
947 #endif
948         kvmppc_set_pvr(vcpu, vcpu->arch.pvr);
949         vcpu->arch.slb_nr = 64;
950
951         vcpu->arch.shadow_msr = MSR_USER64;
952
953         err = kvmppc_mmu_init(vcpu);
954         if (err < 0)
955                 goto uninit_vcpu;
956
957         return vcpu;
958
959 uninit_vcpu:
960         kvm_vcpu_uninit(vcpu);
961 free_shadow_vcpu:
962         kfree(vcpu_book3s->shadow_vcpu);
963 free_vcpu:
964         vfree(vcpu_book3s);
965 out:
966         return ERR_PTR(err);
967 }
968
969 void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
970 {
971         struct kvmppc_vcpu_book3s *vcpu_book3s = to_book3s(vcpu);
972
973         free_page((unsigned long)vcpu->arch.shared & PAGE_MASK);
974         kvm_vcpu_uninit(vcpu);
975         kfree(vcpu_book3s->shadow_vcpu);
976         vfree(vcpu_book3s);
977 }
978
979 int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
980 {
981         int ret;
982         double fpr[32][TS_FPRWIDTH];
983         unsigned int fpscr;
984         int fpexc_mode;
985 #ifdef CONFIG_ALTIVEC
986         vector128 vr[32];
987         vector128 vscr;
988         unsigned long uninitialized_var(vrsave);
989         int used_vr;
990 #endif
991 #ifdef CONFIG_VSX
992         int used_vsr;
993 #endif
994         ulong ext_msr;
995
996         preempt_disable();
997
998         /* Check if we can run the vcpu at all */
999         if (!vcpu->arch.sane) {
1000                 kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
1001                 ret = -EINVAL;
1002                 goto out;
1003         }
1004
1005         kvmppc_core_prepare_to_enter(vcpu);
1006
1007         /*
1008          * Interrupts could be timers for the guest which we have to inject
1009          * again, so let's postpone them until we're in the guest and if we
1010          * really did time things so badly, then we just exit again due to
1011          * a host external interrupt.
1012          */
1013         __hard_irq_disable();
1014
1015         /* No need to go into the guest when all we do is going out */
1016         if (signal_pending(current)) {
1017                 __hard_irq_enable();
1018                 kvm_run->exit_reason = KVM_EXIT_INTR;
1019                 ret = -EINTR;
1020                 goto out;
1021         }
1022
1023         /* Save FPU state in stack */
1024         if (current->thread.regs->msr & MSR_FP)
1025                 giveup_fpu(current);
1026         memcpy(fpr, current->thread.fpr, sizeof(current->thread.fpr));
1027         fpscr = current->thread.fpscr.val;
1028         fpexc_mode = current->thread.fpexc_mode;
1029
1030 #ifdef CONFIG_ALTIVEC
1031         /* Save Altivec state in stack */
1032         used_vr = current->thread.used_vr;
1033         if (used_vr) {
1034                 if (current->thread.regs->msr & MSR_VEC)
1035                         giveup_altivec(current);
1036                 memcpy(vr, current->thread.vr, sizeof(current->thread.vr));
1037                 vscr = current->thread.vscr;
1038                 vrsave = current->thread.vrsave;
1039         }
1040 #endif
1041
1042 #ifdef CONFIG_VSX
1043         /* Save VSX state in stack */
1044         used_vsr = current->thread.used_vsr;
1045         if (used_vsr && (current->thread.regs->msr & MSR_VSX))
1046                         __giveup_vsx(current);
1047 #endif
1048
1049         /* Remember the MSR with disabled extensions */
1050         ext_msr = current->thread.regs->msr;
1051
1052         /* Preload FPU if it's enabled */
1053         if (vcpu->arch.shared->msr & MSR_FP)
1054                 kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP);
1055
1056         kvm_guest_enter();
1057
1058         ret = __kvmppc_vcpu_run(kvm_run, vcpu);
1059
1060         kvm_guest_exit();
1061
1062         current->thread.regs->msr = ext_msr;
1063
1064         /* Make sure we save the guest FPU/Altivec/VSX state */
1065         kvmppc_giveup_ext(vcpu, MSR_FP);
1066         kvmppc_giveup_ext(vcpu, MSR_VEC);
1067         kvmppc_giveup_ext(vcpu, MSR_VSX);
1068
1069         /* Restore FPU state from stack */
1070         memcpy(current->thread.fpr, fpr, sizeof(current->thread.fpr));
1071         current->thread.fpscr.val = fpscr;
1072         current->thread.fpexc_mode = fpexc_mode;
1073
1074 #ifdef CONFIG_ALTIVEC
1075         /* Restore Altivec state from stack */
1076         if (used_vr && current->thread.used_vr) {
1077                 memcpy(current->thread.vr, vr, sizeof(current->thread.vr));
1078                 current->thread.vscr = vscr;
1079                 current->thread.vrsave = vrsave;
1080         }
1081         current->thread.used_vr = used_vr;
1082 #endif
1083
1084 #ifdef CONFIG_VSX
1085         current->thread.used_vsr = used_vsr;
1086 #endif
1087
1088 out:
1089         preempt_enable();
1090         return ret;
1091 }
1092
1093 /*
1094  * Get (and clear) the dirty memory log for a memory slot.
1095  */
1096 int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
1097                                       struct kvm_dirty_log *log)
1098 {
1099         struct kvm_memory_slot *memslot;
1100         struct kvm_vcpu *vcpu;
1101         ulong ga, ga_end;
1102         int is_dirty = 0;
1103         int r;
1104         unsigned long n;
1105
1106         mutex_lock(&kvm->slots_lock);
1107
1108         r = kvm_get_dirty_log(kvm, log, &is_dirty);
1109         if (r)
1110                 goto out;
1111
1112         /* If nothing is dirty, don't bother messing with page tables. */
1113         if (is_dirty) {
1114                 memslot = id_to_memslot(kvm->memslots, log->slot);
1115
1116                 ga = memslot->base_gfn << PAGE_SHIFT;
1117                 ga_end = ga + (memslot->npages << PAGE_SHIFT);
1118
1119                 kvm_for_each_vcpu(n, vcpu, kvm)
1120                         kvmppc_mmu_pte_pflush(vcpu, ga, ga_end);
1121
1122                 n = kvm_dirty_bitmap_bytes(memslot);
1123                 memset(memslot->dirty_bitmap, 0, n);
1124         }
1125
1126         r = 0;
1127 out:
1128         mutex_unlock(&kvm->slots_lock);
1129         return r;
1130 }
1131
1132 int kvmppc_core_prepare_memory_region(struct kvm *kvm,
1133                                       struct kvm_userspace_memory_region *mem)
1134 {
1135         return 0;
1136 }
1137
1138 void kvmppc_core_commit_memory_region(struct kvm *kvm,
1139                                 struct kvm_userspace_memory_region *mem)
1140 {
1141 }
1142
1143 int kvmppc_core_init_vm(struct kvm *kvm)
1144 {
1145         return 0;
1146 }
1147
1148 void kvmppc_core_destroy_vm(struct kvm *kvm)
1149 {
1150 }
1151
1152 static int kvmppc_book3s_init(void)
1153 {
1154         int r;
1155
1156         r = kvm_init(NULL, sizeof(struct kvmppc_vcpu_book3s), 0,
1157                      THIS_MODULE);
1158
1159         if (r)
1160                 return r;
1161
1162         r = kvmppc_mmu_hpte_sysinit();
1163
1164         return r;
1165 }
1166
1167 static void kvmppc_book3s_exit(void)
1168 {
1169         kvmppc_mmu_hpte_sysexit();
1170         kvm_exit();
1171 }
1172
1173 module_init(kvmppc_book3s_init);
1174 module_exit(kvmppc_book3s_exit);