include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / powerpc / kvm / e500.c
index 7992da4..669a5c5 100644 (file)
@@ -13,6 +13,7 @@
  */
 
 #include <linux/kvm_host.h>
+#include <linux/slab.h>
 #include <linux/err.h>
 
 #include <asm/reg.h>
@@ -21,6 +22,7 @@
 #include <asm/kvm_e500.h>
 #include <asm/kvm_ppc.h>
 
+#include "booke.h"
 #include "e500_tlb.h"
 
 void kvmppc_core_load_host_debugstate(struct kvm_vcpu *vcpu)
@@ -59,9 +61,12 @@ int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
 
        kvmppc_e500_tlb_setup(vcpu_e500);
 
-       /* Use the same core vertion as host's */
+       /* Registers init */
        vcpu->arch.pvr = mfspr(SPRN_PVR);
 
+       /* Since booke kvm only support one core, update all vcpus' PIR to 0 */
+       vcpu->vcpu_id = 0;
+
        return 0;
 }
 
@@ -131,18 +136,35 @@ void kvmppc_core_vcpu_free(struct kvm_vcpu *vcpu)
        kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
 }
 
-static int kvmppc_e500_init(void)
+static int __init kvmppc_e500_init(void)
 {
-       int r;
+       int r, i;
+       unsigned long ivor[3];
+       unsigned long max_ivor = 0;
 
        r = kvmppc_booke_init();
        if (r)
                return r;
 
+       /* copy extra E500 exception handlers */
+       ivor[0] = mfspr(SPRN_IVOR32);
+       ivor[1] = mfspr(SPRN_IVOR33);
+       ivor[2] = mfspr(SPRN_IVOR34);
+       for (i = 0; i < 3; i++) {
+               if (ivor[i] > max_ivor)
+                       max_ivor = ivor[i];
+
+               memcpy((void *)kvmppc_booke_handlers + ivor[i],
+                      kvmppc_handlers_start + (i + 16) * kvmppc_handler_len,
+                      kvmppc_handler_len);
+       }
+       flush_icache_range(kvmppc_booke_handlers,
+                       kvmppc_booke_handlers + max_ivor + kvmppc_handler_len);
+
        return kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), THIS_MODULE);
 }
 
-static void kvmppc_e500_exit(void)
+static void __init kvmppc_e500_exit(void)
 {
        kvmppc_booke_exit();
 }