e500.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*
  2. * Copyright (C) 2008-2011 Freescale Semiconductor, Inc. All rights reserved.
  3. *
  4. * Author: Yu Liu, <yu.liu@freescale.com>
  5. *
  6. * Description:
  7. * This file is derived from arch/powerpc/kvm/44x.c,
  8. * by Hollis Blanchard <hollisb@us.ibm.com>.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License, version 2, as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/kvm_host.h>
  15. #include <linux/slab.h>
  16. #include <linux/err.h>
  17. #include <linux/export.h>
  18. #include <linux/module.h>
  19. #include <linux/miscdevice.h>
  20. #include <asm/reg.h>
  21. #include <asm/cputable.h>
  22. #include <asm/tlbflush.h>
  23. #include <asm/kvm_ppc.h>
  24. #include "../mm/mmu_decl.h"
  25. #include "booke.h"
  26. #include "e500.h"
  27. struct id {
  28. unsigned long val;
  29. struct id **pentry;
  30. };
  31. #define NUM_TIDS 256
  32. /*
  33. * This table provide mappings from:
  34. * (guestAS,guestTID,guestPR) --> ID of physical cpu
  35. * guestAS [0..1]
  36. * guestTID [0..255]
  37. * guestPR [0..1]
  38. * ID [1..255]
  39. * Each vcpu keeps one vcpu_id_table.
  40. */
  41. struct vcpu_id_table {
  42. struct id id[2][NUM_TIDS][2];
  43. };
  44. /*
  45. * This table provide reversed mappings of vcpu_id_table:
  46. * ID --> address of vcpu_id_table item.
  47. * Each physical core has one pcpu_id_table.
  48. */
  49. struct pcpu_id_table {
  50. struct id *entry[NUM_TIDS];
  51. };
  52. static DEFINE_PER_CPU(struct pcpu_id_table, pcpu_sids);
  53. /* This variable keeps last used shadow ID on local core.
  54. * The valid range of shadow ID is [1..255] */
  55. static DEFINE_PER_CPU(unsigned long, pcpu_last_used_sid);
  56. /*
  57. * Allocate a free shadow id and setup a valid sid mapping in given entry.
  58. * A mapping is only valid when vcpu_id_table and pcpu_id_table are match.
  59. *
  60. * The caller must have preemption disabled, and keep it that way until
  61. * it has finished with the returned shadow id (either written into the
  62. * TLB or arch.shadow_pid, or discarded).
  63. */
  64. static inline int local_sid_setup_one(struct id *entry)
  65. {
  66. unsigned long sid;
  67. int ret = -1;
  68. sid = ++(__get_cpu_var(pcpu_last_used_sid));
  69. if (sid < NUM_TIDS) {
  70. __get_cpu_var(pcpu_sids).entry[sid] = entry;
  71. entry->val = sid;
  72. entry->pentry = &__get_cpu_var(pcpu_sids).entry[sid];
  73. ret = sid;
  74. }
  75. /*
  76. * If sid == NUM_TIDS, we've run out of sids. We return -1, and
  77. * the caller will invalidate everything and start over.
  78. *
  79. * sid > NUM_TIDS indicates a race, which we disable preemption to
  80. * avoid.
  81. */
  82. WARN_ON(sid > NUM_TIDS);
  83. return ret;
  84. }
  85. /*
  86. * Check if given entry contain a valid shadow id mapping.
  87. * An ID mapping is considered valid only if
  88. * both vcpu and pcpu know this mapping.
  89. *
  90. * The caller must have preemption disabled, and keep it that way until
  91. * it has finished with the returned shadow id (either written into the
  92. * TLB or arch.shadow_pid, or discarded).
  93. */
  94. static inline int local_sid_lookup(struct id *entry)
  95. {
  96. if (entry && entry->val != 0 &&
  97. __get_cpu_var(pcpu_sids).entry[entry->val] == entry &&
  98. entry->pentry == &__get_cpu_var(pcpu_sids).entry[entry->val])
  99. return entry->val;
  100. return -1;
  101. }
  102. /* Invalidate all id mappings on local core -- call with preempt disabled */
  103. static inline void local_sid_destroy_all(void)
  104. {
  105. __get_cpu_var(pcpu_last_used_sid) = 0;
  106. memset(&__get_cpu_var(pcpu_sids), 0, sizeof(__get_cpu_var(pcpu_sids)));
  107. }
  108. static void *kvmppc_e500_id_table_alloc(struct kvmppc_vcpu_e500 *vcpu_e500)
  109. {
  110. vcpu_e500->idt = kzalloc(sizeof(struct vcpu_id_table), GFP_KERNEL);
  111. return vcpu_e500->idt;
  112. }
  113. static void kvmppc_e500_id_table_free(struct kvmppc_vcpu_e500 *vcpu_e500)
  114. {
  115. kfree(vcpu_e500->idt);
  116. vcpu_e500->idt = NULL;
  117. }
  118. /* Map guest pid to shadow.
  119. * We use PID to keep shadow of current guest non-zero PID,
  120. * and use PID1 to keep shadow of guest zero PID.
  121. * So that guest tlbe with TID=0 can be accessed at any time */
  122. static void kvmppc_e500_recalc_shadow_pid(struct kvmppc_vcpu_e500 *vcpu_e500)
  123. {
  124. preempt_disable();
  125. vcpu_e500->vcpu.arch.shadow_pid = kvmppc_e500_get_sid(vcpu_e500,
  126. get_cur_as(&vcpu_e500->vcpu),
  127. get_cur_pid(&vcpu_e500->vcpu),
  128. get_cur_pr(&vcpu_e500->vcpu), 1);
  129. vcpu_e500->vcpu.arch.shadow_pid1 = kvmppc_e500_get_sid(vcpu_e500,
  130. get_cur_as(&vcpu_e500->vcpu), 0,
  131. get_cur_pr(&vcpu_e500->vcpu), 1);
  132. preempt_enable();
  133. }
  134. /* Invalidate all mappings on vcpu */
  135. static void kvmppc_e500_id_table_reset_all(struct kvmppc_vcpu_e500 *vcpu_e500)
  136. {
  137. memset(vcpu_e500->idt, 0, sizeof(struct vcpu_id_table));
  138. /* Update shadow pid when mappings are changed */
  139. kvmppc_e500_recalc_shadow_pid(vcpu_e500);
  140. }
  141. /* Invalidate one ID mapping on vcpu */
  142. static inline void kvmppc_e500_id_table_reset_one(
  143. struct kvmppc_vcpu_e500 *vcpu_e500,
  144. int as, int pid, int pr)
  145. {
  146. struct vcpu_id_table *idt = vcpu_e500->idt;
  147. BUG_ON(as >= 2);
  148. BUG_ON(pid >= NUM_TIDS);
  149. BUG_ON(pr >= 2);
  150. idt->id[as][pid][pr].val = 0;
  151. idt->id[as][pid][pr].pentry = NULL;
  152. /* Update shadow pid when mappings are changed */
  153. kvmppc_e500_recalc_shadow_pid(vcpu_e500);
  154. }
  155. /*
  156. * Map guest (vcpu,AS,ID,PR) to physical core shadow id.
  157. * This function first lookup if a valid mapping exists,
  158. * if not, then creates a new one.
  159. *
  160. * The caller must have preemption disabled, and keep it that way until
  161. * it has finished with the returned shadow id (either written into the
  162. * TLB or arch.shadow_pid, or discarded).
  163. */
  164. unsigned int kvmppc_e500_get_sid(struct kvmppc_vcpu_e500 *vcpu_e500,
  165. unsigned int as, unsigned int gid,
  166. unsigned int pr, int avoid_recursion)
  167. {
  168. struct vcpu_id_table *idt = vcpu_e500->idt;
  169. int sid;
  170. BUG_ON(as >= 2);
  171. BUG_ON(gid >= NUM_TIDS);
  172. BUG_ON(pr >= 2);
  173. sid = local_sid_lookup(&idt->id[as][gid][pr]);
  174. while (sid <= 0) {
  175. /* No mapping yet */
  176. sid = local_sid_setup_one(&idt->id[as][gid][pr]);
  177. if (sid <= 0) {
  178. _tlbil_all();
  179. local_sid_destroy_all();
  180. }
  181. /* Update shadow pid when mappings are changed */
  182. if (!avoid_recursion)
  183. kvmppc_e500_recalc_shadow_pid(vcpu_e500);
  184. }
  185. return sid;
  186. }
  187. unsigned int kvmppc_e500_get_tlb_stid(struct kvm_vcpu *vcpu,
  188. struct kvm_book3e_206_tlb_entry *gtlbe)
  189. {
  190. return kvmppc_e500_get_sid(to_e500(vcpu), get_tlb_ts(gtlbe),
  191. get_tlb_tid(gtlbe), get_cur_pr(vcpu), 0);
  192. }
  193. void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 pid)
  194. {
  195. struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
  196. if (vcpu->arch.pid != pid) {
  197. vcpu_e500->pid[0] = vcpu->arch.pid = pid;
  198. kvmppc_e500_recalc_shadow_pid(vcpu_e500);
  199. }
  200. }
  201. /* gtlbe must not be mapped by more than one host tlbe */
  202. void kvmppc_e500_tlbil_one(struct kvmppc_vcpu_e500 *vcpu_e500,
  203. struct kvm_book3e_206_tlb_entry *gtlbe)
  204. {
  205. struct vcpu_id_table *idt = vcpu_e500->idt;
  206. unsigned int pr, tid, ts, pid;
  207. u32 val, eaddr;
  208. unsigned long flags;
  209. ts = get_tlb_ts(gtlbe);
  210. tid = get_tlb_tid(gtlbe);
  211. preempt_disable();
  212. /* One guest ID may be mapped to two shadow IDs */
  213. for (pr = 0; pr < 2; pr++) {
  214. /*
  215. * The shadow PID can have a valid mapping on at most one
  216. * host CPU. In the common case, it will be valid on this
  217. * CPU, in which case we do a local invalidation of the
  218. * specific address.
  219. *
  220. * If the shadow PID is not valid on the current host CPU,
  221. * we invalidate the entire shadow PID.
  222. */
  223. pid = local_sid_lookup(&idt->id[ts][tid][pr]);
  224. if (pid <= 0) {
  225. kvmppc_e500_id_table_reset_one(vcpu_e500, ts, tid, pr);
  226. continue;
  227. }
  228. /*
  229. * The guest is invalidating a 4K entry which is in a PID
  230. * that has a valid shadow mapping on this host CPU. We
  231. * search host TLB to invalidate it's shadow TLB entry,
  232. * similar to __tlbil_va except that we need to look in AS1.
  233. */
  234. val = (pid << MAS6_SPID_SHIFT) | MAS6_SAS;
  235. eaddr = get_tlb_eaddr(gtlbe);
  236. local_irq_save(flags);
  237. mtspr(SPRN_MAS6, val);
  238. asm volatile("tlbsx 0, %[eaddr]" : : [eaddr] "r" (eaddr));
  239. val = mfspr(SPRN_MAS1);
  240. if (val & MAS1_VALID) {
  241. mtspr(SPRN_MAS1, val & ~MAS1_VALID);
  242. asm volatile("tlbwe");
  243. }
  244. local_irq_restore(flags);
  245. }
  246. preempt_enable();
  247. }
  248. void kvmppc_e500_tlbil_all(struct kvmppc_vcpu_e500 *vcpu_e500)
  249. {
  250. kvmppc_e500_id_table_reset_all(vcpu_e500);
  251. }
  252. void kvmppc_mmu_msr_notify(struct kvm_vcpu *vcpu, u32 old_msr)
  253. {
  254. /* Recalc shadow pid since MSR changes */
  255. kvmppc_e500_recalc_shadow_pid(to_e500(vcpu));
  256. }
  257. void kvmppc_core_load_host_debugstate(struct kvm_vcpu *vcpu)
  258. {
  259. }
  260. void kvmppc_core_load_guest_debugstate(struct kvm_vcpu *vcpu)
  261. {
  262. }
  263. static void kvmppc_core_vcpu_load_e500(struct kvm_vcpu *vcpu, int cpu)
  264. {
  265. kvmppc_booke_vcpu_load(vcpu, cpu);
  266. /* Shadow PID may be expired on local core */
  267. kvmppc_e500_recalc_shadow_pid(to_e500(vcpu));
  268. }
  269. static void kvmppc_core_vcpu_put_e500(struct kvm_vcpu *vcpu)
  270. {
  271. #ifdef CONFIG_SPE
  272. if (vcpu->arch.shadow_msr & MSR_SPE)
  273. kvmppc_vcpu_disable_spe(vcpu);
  274. #endif
  275. kvmppc_booke_vcpu_put(vcpu);
  276. }
  277. int kvmppc_core_check_processor_compat(void)
  278. {
  279. int r;
  280. if (strcmp(cur_cpu_spec->cpu_name, "e500v2") == 0)
  281. r = 0;
  282. else
  283. r = -ENOTSUPP;
  284. return r;
  285. }
  286. static void kvmppc_e500_tlb_setup(struct kvmppc_vcpu_e500 *vcpu_e500)
  287. {
  288. struct kvm_book3e_206_tlb_entry *tlbe;
  289. /* Insert large initial mapping for guest. */
  290. tlbe = get_entry(vcpu_e500, 1, 0);
  291. tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_256M);
  292. tlbe->mas2 = 0;
  293. tlbe->mas7_3 = E500_TLB_SUPER_PERM_MASK;
  294. /* 4K map for serial output. Used by kernel wrapper. */
  295. tlbe = get_entry(vcpu_e500, 1, 1);
  296. tlbe->mas1 = MAS1_VALID | MAS1_TSIZE(BOOK3E_PAGESZ_4K);
  297. tlbe->mas2 = (0xe0004500 & 0xFFFFF000) | MAS2_I | MAS2_G;
  298. tlbe->mas7_3 = (0xe0004500 & 0xFFFFF000) | E500_TLB_SUPER_PERM_MASK;
  299. }
  300. int kvmppc_core_vcpu_setup(struct kvm_vcpu *vcpu)
  301. {
  302. struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
  303. kvmppc_e500_tlb_setup(vcpu_e500);
  304. /* Registers init */
  305. vcpu->arch.pvr = mfspr(SPRN_PVR);
  306. vcpu_e500->svr = mfspr(SPRN_SVR);
  307. vcpu->arch.cpu_type = KVM_CPU_E500V2;
  308. return 0;
  309. }
  310. static int kvmppc_core_get_sregs_e500(struct kvm_vcpu *vcpu,
  311. struct kvm_sregs *sregs)
  312. {
  313. struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
  314. sregs->u.e.features |= KVM_SREGS_E_ARCH206_MMU | KVM_SREGS_E_SPE |
  315. KVM_SREGS_E_PM;
  316. sregs->u.e.impl_id = KVM_SREGS_E_IMPL_FSL;
  317. sregs->u.e.impl.fsl.features = 0;
  318. sregs->u.e.impl.fsl.svr = vcpu_e500->svr;
  319. sregs->u.e.impl.fsl.hid0 = vcpu_e500->hid0;
  320. sregs->u.e.impl.fsl.mcar = vcpu_e500->mcar;
  321. sregs->u.e.ivor_high[0] = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL];
  322. sregs->u.e.ivor_high[1] = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_DATA];
  323. sregs->u.e.ivor_high[2] = vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_ROUND];
  324. sregs->u.e.ivor_high[3] =
  325. vcpu->arch.ivor[BOOKE_IRQPRIO_PERFORMANCE_MONITOR];
  326. kvmppc_get_sregs_ivor(vcpu, sregs);
  327. kvmppc_get_sregs_e500_tlb(vcpu, sregs);
  328. return 0;
  329. }
  330. static int kvmppc_core_set_sregs_e500(struct kvm_vcpu *vcpu,
  331. struct kvm_sregs *sregs)
  332. {
  333. struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
  334. int ret;
  335. if (sregs->u.e.impl_id == KVM_SREGS_E_IMPL_FSL) {
  336. vcpu_e500->svr = sregs->u.e.impl.fsl.svr;
  337. vcpu_e500->hid0 = sregs->u.e.impl.fsl.hid0;
  338. vcpu_e500->mcar = sregs->u.e.impl.fsl.mcar;
  339. }
  340. ret = kvmppc_set_sregs_e500_tlb(vcpu, sregs);
  341. if (ret < 0)
  342. return ret;
  343. if (!(sregs->u.e.features & KVM_SREGS_E_IVOR))
  344. return 0;
  345. if (sregs->u.e.features & KVM_SREGS_E_SPE) {
  346. vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_UNAVAIL] =
  347. sregs->u.e.ivor_high[0];
  348. vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_DATA] =
  349. sregs->u.e.ivor_high[1];
  350. vcpu->arch.ivor[BOOKE_IRQPRIO_SPE_FP_ROUND] =
  351. sregs->u.e.ivor_high[2];
  352. }
  353. if (sregs->u.e.features & KVM_SREGS_E_PM) {
  354. vcpu->arch.ivor[BOOKE_IRQPRIO_PERFORMANCE_MONITOR] =
  355. sregs->u.e.ivor_high[3];
  356. }
  357. return kvmppc_set_sregs_ivor(vcpu, sregs);
  358. }
  359. static int kvmppc_get_one_reg_e500(struct kvm_vcpu *vcpu, u64 id,
  360. union kvmppc_one_reg *val)
  361. {
  362. int r = kvmppc_get_one_reg_e500_tlb(vcpu, id, val);
  363. return r;
  364. }
  365. static int kvmppc_set_one_reg_e500(struct kvm_vcpu *vcpu, u64 id,
  366. union kvmppc_one_reg *val)
  367. {
  368. int r = kvmppc_get_one_reg_e500_tlb(vcpu, id, val);
  369. return r;
  370. }
  371. static struct kvm_vcpu *kvmppc_core_vcpu_create_e500(struct kvm *kvm,
  372. unsigned int id)
  373. {
  374. struct kvmppc_vcpu_e500 *vcpu_e500;
  375. struct kvm_vcpu *vcpu;
  376. int err;
  377. vcpu_e500 = kmem_cache_zalloc(kvm_vcpu_cache, GFP_KERNEL);
  378. if (!vcpu_e500) {
  379. err = -ENOMEM;
  380. goto out;
  381. }
  382. vcpu = &vcpu_e500->vcpu;
  383. err = kvm_vcpu_init(vcpu, kvm, id);
  384. if (err)
  385. goto free_vcpu;
  386. if (kvmppc_e500_id_table_alloc(vcpu_e500) == NULL)
  387. goto uninit_vcpu;
  388. err = kvmppc_e500_tlb_init(vcpu_e500);
  389. if (err)
  390. goto uninit_id;
  391. vcpu->arch.shared = (void*)__get_free_page(GFP_KERNEL|__GFP_ZERO);
  392. if (!vcpu->arch.shared)
  393. goto uninit_tlb;
  394. return vcpu;
  395. uninit_tlb:
  396. kvmppc_e500_tlb_uninit(vcpu_e500);
  397. uninit_id:
  398. kvmppc_e500_id_table_free(vcpu_e500);
  399. uninit_vcpu:
  400. kvm_vcpu_uninit(vcpu);
  401. free_vcpu:
  402. kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
  403. out:
  404. return ERR_PTR(err);
  405. }
  406. static void kvmppc_core_vcpu_free_e500(struct kvm_vcpu *vcpu)
  407. {
  408. struct kvmppc_vcpu_e500 *vcpu_e500 = to_e500(vcpu);
  409. free_page((unsigned long)vcpu->arch.shared);
  410. kvmppc_e500_tlb_uninit(vcpu_e500);
  411. kvmppc_e500_id_table_free(vcpu_e500);
  412. kvm_vcpu_uninit(vcpu);
  413. kmem_cache_free(kvm_vcpu_cache, vcpu_e500);
  414. }
  415. static int kvmppc_core_init_vm_e500(struct kvm *kvm)
  416. {
  417. return 0;
  418. }
  419. static void kvmppc_core_destroy_vm_e500(struct kvm *kvm)
  420. {
  421. }
  422. static struct kvmppc_ops kvm_ops_e500 = {
  423. .get_sregs = kvmppc_core_get_sregs_e500,
  424. .set_sregs = kvmppc_core_set_sregs_e500,
  425. .get_one_reg = kvmppc_get_one_reg_e500,
  426. .set_one_reg = kvmppc_set_one_reg_e500,
  427. .vcpu_load = kvmppc_core_vcpu_load_e500,
  428. .vcpu_put = kvmppc_core_vcpu_put_e500,
  429. .vcpu_create = kvmppc_core_vcpu_create_e500,
  430. .vcpu_free = kvmppc_core_vcpu_free_e500,
  431. .mmu_destroy = kvmppc_mmu_destroy_e500,
  432. .init_vm = kvmppc_core_init_vm_e500,
  433. .destroy_vm = kvmppc_core_destroy_vm_e500,
  434. .emulate_op = kvmppc_core_emulate_op_e500,
  435. .emulate_mtspr = kvmppc_core_emulate_mtspr_e500,
  436. .emulate_mfspr = kvmppc_core_emulate_mfspr_e500,
  437. };
  438. static int __init kvmppc_e500_init(void)
  439. {
  440. int r, i;
  441. unsigned long ivor[3];
  442. /* Process remaining handlers above the generic first 16 */
  443. unsigned long *handler = &kvmppc_booke_handler_addr[16];
  444. unsigned long handler_len;
  445. unsigned long max_ivor = 0;
  446. r = kvmppc_core_check_processor_compat();
  447. if (r)
  448. goto err_out;
  449. r = kvmppc_booke_init();
  450. if (r)
  451. goto err_out;
  452. /* copy extra E500 exception handlers */
  453. ivor[0] = mfspr(SPRN_IVOR32);
  454. ivor[1] = mfspr(SPRN_IVOR33);
  455. ivor[2] = mfspr(SPRN_IVOR34);
  456. for (i = 0; i < 3; i++) {
  457. if (ivor[i] > ivor[max_ivor])
  458. max_ivor = i;
  459. handler_len = handler[i + 1] - handler[i];
  460. memcpy((void *)kvmppc_booke_handlers + ivor[i],
  461. (void *)handler[i], handler_len);
  462. }
  463. handler_len = handler[max_ivor + 1] - handler[max_ivor];
  464. flush_icache_range(kvmppc_booke_handlers, kvmppc_booke_handlers +
  465. ivor[max_ivor] + handler_len);
  466. r = kvm_init(NULL, sizeof(struct kvmppc_vcpu_e500), 0, THIS_MODULE);
  467. if (r)
  468. goto err_out;
  469. kvm_ops_e500.owner = THIS_MODULE;
  470. kvmppc_pr_ops = &kvm_ops_e500;
  471. err_out:
  472. return r;
  473. }
  474. static void __exit kvmppc_e500_exit(void)
  475. {
  476. kvmppc_pr_ops = NULL;
  477. kvmppc_booke_exit();
  478. }
  479. module_init(kvmppc_e500_init);
  480. module_exit(kvmppc_e500_exit);
  481. MODULE_ALIAS_MISCDEV(KVM_MINOR);
  482. MODULE_ALIAS("devname:kvm");