powerpc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  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 IBM Corp. 2007
  16. *
  17. * Authors: Hollis Blanchard <hollisb@us.ibm.com>
  18. * Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
  19. */
  20. #include <linux/errno.h>
  21. #include <linux/err.h>
  22. #include <linux/kvm_host.h>
  23. #include <linux/module.h>
  24. #include <linux/vmalloc.h>
  25. #include <linux/hrtimer.h>
  26. #include <linux/fs.h>
  27. #include <linux/slab.h>
  28. #include <asm/cputable.h>
  29. #include <asm/uaccess.h>
  30. #include <asm/kvm_ppc.h>
  31. #include <asm/tlbflush.h>
  32. #include "timing.h"
  33. #include "../mm/mmu_decl.h"
  34. #define CREATE_TRACE_POINTS
  35. #include "trace.h"
  36. int kvm_arch_vcpu_runnable(struct kvm_vcpu *v)
  37. {
  38. #ifndef CONFIG_KVM_BOOK3S_64_HV
  39. return !(v->arch.shared->msr & MSR_WE) ||
  40. !!(v->arch.pending_exceptions);
  41. #else
  42. return !(v->arch.ceded) || !!(v->arch.pending_exceptions);
  43. #endif
  44. }
  45. int kvmppc_kvm_pv(struct kvm_vcpu *vcpu)
  46. {
  47. int nr = kvmppc_get_gpr(vcpu, 11);
  48. int r;
  49. unsigned long __maybe_unused param1 = kvmppc_get_gpr(vcpu, 3);
  50. unsigned long __maybe_unused param2 = kvmppc_get_gpr(vcpu, 4);
  51. unsigned long __maybe_unused param3 = kvmppc_get_gpr(vcpu, 5);
  52. unsigned long __maybe_unused param4 = kvmppc_get_gpr(vcpu, 6);
  53. unsigned long r2 = 0;
  54. if (!(vcpu->arch.shared->msr & MSR_SF)) {
  55. /* 32 bit mode */
  56. param1 &= 0xffffffff;
  57. param2 &= 0xffffffff;
  58. param3 &= 0xffffffff;
  59. param4 &= 0xffffffff;
  60. }
  61. switch (nr) {
  62. case HC_VENDOR_KVM | KVM_HC_PPC_MAP_MAGIC_PAGE:
  63. {
  64. vcpu->arch.magic_page_pa = param1;
  65. vcpu->arch.magic_page_ea = param2;
  66. r2 = KVM_MAGIC_FEAT_SR;
  67. r = HC_EV_SUCCESS;
  68. break;
  69. }
  70. case HC_VENDOR_KVM | KVM_HC_FEATURES:
  71. r = HC_EV_SUCCESS;
  72. #if defined(CONFIG_PPC_BOOK3S) || defined(CONFIG_KVM_E500)
  73. /* XXX Missing magic page on 44x */
  74. r2 |= (1 << KVM_FEATURE_MAGIC_PAGE);
  75. #endif
  76. /* Second return value is in r4 */
  77. break;
  78. default:
  79. r = HC_EV_UNIMPLEMENTED;
  80. break;
  81. }
  82. kvmppc_set_gpr(vcpu, 4, r2);
  83. return r;
  84. }
  85. int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
  86. {
  87. enum emulation_result er;
  88. int r;
  89. er = kvmppc_emulate_instruction(run, vcpu);
  90. switch (er) {
  91. case EMULATE_DONE:
  92. /* Future optimization: only reload non-volatiles if they were
  93. * actually modified. */
  94. r = RESUME_GUEST_NV;
  95. break;
  96. case EMULATE_DO_MMIO:
  97. run->exit_reason = KVM_EXIT_MMIO;
  98. /* We must reload nonvolatiles because "update" load/store
  99. * instructions modify register state. */
  100. /* Future optimization: only reload non-volatiles if they were
  101. * actually modified. */
  102. r = RESUME_HOST_NV;
  103. break;
  104. case EMULATE_FAIL:
  105. /* XXX Deliver Program interrupt to guest. */
  106. printk(KERN_EMERG "%s: emulation failed (%08x)\n", __func__,
  107. kvmppc_get_last_inst(vcpu));
  108. r = RESUME_HOST;
  109. break;
  110. default:
  111. BUG();
  112. }
  113. return r;
  114. }
  115. int kvm_arch_hardware_enable(void *garbage)
  116. {
  117. return 0;
  118. }
  119. void kvm_arch_hardware_disable(void *garbage)
  120. {
  121. }
  122. int kvm_arch_hardware_setup(void)
  123. {
  124. return 0;
  125. }
  126. void kvm_arch_hardware_unsetup(void)
  127. {
  128. }
  129. void kvm_arch_check_processor_compat(void *rtn)
  130. {
  131. *(int *)rtn = kvmppc_core_check_processor_compat();
  132. }
  133. int kvm_arch_init_vm(struct kvm *kvm)
  134. {
  135. return kvmppc_core_init_vm(kvm);
  136. }
  137. void kvm_arch_destroy_vm(struct kvm *kvm)
  138. {
  139. unsigned int i;
  140. struct kvm_vcpu *vcpu;
  141. kvm_for_each_vcpu(i, vcpu, kvm)
  142. kvm_arch_vcpu_free(vcpu);
  143. mutex_lock(&kvm->lock);
  144. for (i = 0; i < atomic_read(&kvm->online_vcpus); i++)
  145. kvm->vcpus[i] = NULL;
  146. atomic_set(&kvm->online_vcpus, 0);
  147. kvmppc_core_destroy_vm(kvm);
  148. mutex_unlock(&kvm->lock);
  149. }
  150. void kvm_arch_sync_events(struct kvm *kvm)
  151. {
  152. }
  153. int kvm_dev_ioctl_check_extension(long ext)
  154. {
  155. int r;
  156. switch (ext) {
  157. #ifdef CONFIG_BOOKE
  158. case KVM_CAP_PPC_BOOKE_SREGS:
  159. #else
  160. case KVM_CAP_PPC_SEGSTATE:
  161. #endif
  162. case KVM_CAP_PPC_UNSET_IRQ:
  163. case KVM_CAP_PPC_IRQ_LEVEL:
  164. case KVM_CAP_ENABLE_CAP:
  165. r = 1;
  166. break;
  167. #ifndef CONFIG_KVM_BOOK3S_64_HV
  168. case KVM_CAP_PPC_PAIRED_SINGLES:
  169. case KVM_CAP_PPC_OSI:
  170. case KVM_CAP_PPC_GET_PVINFO:
  171. r = 1;
  172. break;
  173. case KVM_CAP_COALESCED_MMIO:
  174. r = KVM_COALESCED_MMIO_PAGE_OFFSET;
  175. break;
  176. #endif
  177. default:
  178. r = 0;
  179. break;
  180. }
  181. return r;
  182. }
  183. long kvm_arch_dev_ioctl(struct file *filp,
  184. unsigned int ioctl, unsigned long arg)
  185. {
  186. return -EINVAL;
  187. }
  188. int kvm_arch_prepare_memory_region(struct kvm *kvm,
  189. struct kvm_memory_slot *memslot,
  190. struct kvm_memory_slot old,
  191. struct kvm_userspace_memory_region *mem,
  192. int user_alloc)
  193. {
  194. return kvmppc_core_prepare_memory_region(kvm, mem);
  195. }
  196. void kvm_arch_commit_memory_region(struct kvm *kvm,
  197. struct kvm_userspace_memory_region *mem,
  198. struct kvm_memory_slot old,
  199. int user_alloc)
  200. {
  201. kvmppc_core_commit_memory_region(kvm, mem);
  202. }
  203. void kvm_arch_flush_shadow(struct kvm *kvm)
  204. {
  205. }
  206. struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
  207. {
  208. struct kvm_vcpu *vcpu;
  209. vcpu = kvmppc_core_vcpu_create(kvm, id);
  210. if (!IS_ERR(vcpu))
  211. kvmppc_create_vcpu_debugfs(vcpu, id);
  212. return vcpu;
  213. }
  214. void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
  215. {
  216. /* Make sure we're not using the vcpu anymore */
  217. hrtimer_cancel(&vcpu->arch.dec_timer);
  218. tasklet_kill(&vcpu->arch.tasklet);
  219. kvmppc_remove_vcpu_debugfs(vcpu);
  220. kvmppc_core_vcpu_free(vcpu);
  221. }
  222. void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
  223. {
  224. kvm_arch_vcpu_free(vcpu);
  225. }
  226. int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu)
  227. {
  228. return kvmppc_core_pending_dec(vcpu);
  229. }
  230. static void kvmppc_decrementer_func(unsigned long data)
  231. {
  232. struct kvm_vcpu *vcpu = (struct kvm_vcpu *)data;
  233. kvmppc_core_queue_dec(vcpu);
  234. if (waitqueue_active(&vcpu->wq)) {
  235. wake_up_interruptible(&vcpu->wq);
  236. vcpu->stat.halt_wakeup++;
  237. }
  238. }
  239. /*
  240. * low level hrtimer wake routine. Because this runs in hardirq context
  241. * we schedule a tasklet to do the real work.
  242. */
  243. enum hrtimer_restart kvmppc_decrementer_wakeup(struct hrtimer *timer)
  244. {
  245. struct kvm_vcpu *vcpu;
  246. vcpu = container_of(timer, struct kvm_vcpu, arch.dec_timer);
  247. tasklet_schedule(&vcpu->arch.tasklet);
  248. return HRTIMER_NORESTART;
  249. }
  250. int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
  251. {
  252. hrtimer_init(&vcpu->arch.dec_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
  253. tasklet_init(&vcpu->arch.tasklet, kvmppc_decrementer_func, (ulong)vcpu);
  254. vcpu->arch.dec_timer.function = kvmppc_decrementer_wakeup;
  255. vcpu->arch.dec_expires = ~(u64)0;
  256. #ifdef CONFIG_KVM_EXIT_TIMING
  257. mutex_init(&vcpu->arch.exit_timing_lock);
  258. #endif
  259. return 0;
  260. }
  261. void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu)
  262. {
  263. kvmppc_mmu_destroy(vcpu);
  264. }
  265. void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
  266. {
  267. #ifdef CONFIG_BOOKE
  268. /*
  269. * vrsave (formerly usprg0) isn't used by Linux, but may
  270. * be used by the guest.
  271. *
  272. * On non-booke this is associated with Altivec and
  273. * is handled by code in book3s.c.
  274. */
  275. mtspr(SPRN_VRSAVE, vcpu->arch.vrsave);
  276. #endif
  277. kvmppc_core_vcpu_load(vcpu, cpu);
  278. vcpu->cpu = smp_processor_id();
  279. }
  280. void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
  281. {
  282. kvmppc_core_vcpu_put(vcpu);
  283. #ifdef CONFIG_BOOKE
  284. vcpu->arch.vrsave = mfspr(SPRN_VRSAVE);
  285. #endif
  286. vcpu->cpu = -1;
  287. }
  288. int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
  289. struct kvm_guest_debug *dbg)
  290. {
  291. return -EINVAL;
  292. }
  293. static void kvmppc_complete_dcr_load(struct kvm_vcpu *vcpu,
  294. struct kvm_run *run)
  295. {
  296. kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, run->dcr.data);
  297. }
  298. static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
  299. struct kvm_run *run)
  300. {
  301. u64 uninitialized_var(gpr);
  302. if (run->mmio.len > sizeof(gpr)) {
  303. printk(KERN_ERR "bad MMIO length: %d\n", run->mmio.len);
  304. return;
  305. }
  306. if (vcpu->arch.mmio_is_bigendian) {
  307. switch (run->mmio.len) {
  308. case 8: gpr = *(u64 *)run->mmio.data; break;
  309. case 4: gpr = *(u32 *)run->mmio.data; break;
  310. case 2: gpr = *(u16 *)run->mmio.data; break;
  311. case 1: gpr = *(u8 *)run->mmio.data; break;
  312. }
  313. } else {
  314. /* Convert BE data from userland back to LE. */
  315. switch (run->mmio.len) {
  316. case 4: gpr = ld_le32((u32 *)run->mmio.data); break;
  317. case 2: gpr = ld_le16((u16 *)run->mmio.data); break;
  318. case 1: gpr = *(u8 *)run->mmio.data; break;
  319. }
  320. }
  321. if (vcpu->arch.mmio_sign_extend) {
  322. switch (run->mmio.len) {
  323. #ifdef CONFIG_PPC64
  324. case 4:
  325. gpr = (s64)(s32)gpr;
  326. break;
  327. #endif
  328. case 2:
  329. gpr = (s64)(s16)gpr;
  330. break;
  331. case 1:
  332. gpr = (s64)(s8)gpr;
  333. break;
  334. }
  335. }
  336. kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr);
  337. switch (vcpu->arch.io_gpr & KVM_REG_EXT_MASK) {
  338. case KVM_REG_GPR:
  339. kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr);
  340. break;
  341. case KVM_REG_FPR:
  342. vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr;
  343. break;
  344. #ifdef CONFIG_PPC_BOOK3S
  345. case KVM_REG_QPR:
  346. vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr;
  347. break;
  348. case KVM_REG_FQPR:
  349. vcpu->arch.fpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr;
  350. vcpu->arch.qpr[vcpu->arch.io_gpr & KVM_REG_MASK] = gpr;
  351. break;
  352. #endif
  353. default:
  354. BUG();
  355. }
  356. }
  357. int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
  358. unsigned int rt, unsigned int bytes, int is_bigendian)
  359. {
  360. if (bytes > sizeof(run->mmio.data)) {
  361. printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__,
  362. run->mmio.len);
  363. }
  364. run->mmio.phys_addr = vcpu->arch.paddr_accessed;
  365. run->mmio.len = bytes;
  366. run->mmio.is_write = 0;
  367. vcpu->arch.io_gpr = rt;
  368. vcpu->arch.mmio_is_bigendian = is_bigendian;
  369. vcpu->mmio_needed = 1;
  370. vcpu->mmio_is_write = 0;
  371. vcpu->arch.mmio_sign_extend = 0;
  372. return EMULATE_DO_MMIO;
  373. }
  374. /* Same as above, but sign extends */
  375. int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu,
  376. unsigned int rt, unsigned int bytes, int is_bigendian)
  377. {
  378. int r;
  379. r = kvmppc_handle_load(run, vcpu, rt, bytes, is_bigendian);
  380. vcpu->arch.mmio_sign_extend = 1;
  381. return r;
  382. }
  383. int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
  384. u64 val, unsigned int bytes, int is_bigendian)
  385. {
  386. void *data = run->mmio.data;
  387. if (bytes > sizeof(run->mmio.data)) {
  388. printk(KERN_ERR "%s: bad MMIO length: %d\n", __func__,
  389. run->mmio.len);
  390. }
  391. run->mmio.phys_addr = vcpu->arch.paddr_accessed;
  392. run->mmio.len = bytes;
  393. run->mmio.is_write = 1;
  394. vcpu->mmio_needed = 1;
  395. vcpu->mmio_is_write = 1;
  396. /* Store the value at the lowest bytes in 'data'. */
  397. if (is_bigendian) {
  398. switch (bytes) {
  399. case 8: *(u64 *)data = val; break;
  400. case 4: *(u32 *)data = val; break;
  401. case 2: *(u16 *)data = val; break;
  402. case 1: *(u8 *)data = val; break;
  403. }
  404. } else {
  405. /* Store LE value into 'data'. */
  406. switch (bytes) {
  407. case 4: st_le32(data, val); break;
  408. case 2: st_le16(data, val); break;
  409. case 1: *(u8 *)data = val; break;
  410. }
  411. }
  412. return EMULATE_DO_MMIO;
  413. }
  414. int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
  415. {
  416. int r;
  417. sigset_t sigsaved;
  418. if (vcpu->sigset_active)
  419. sigprocmask(SIG_SETMASK, &vcpu->sigset, &sigsaved);
  420. if (vcpu->mmio_needed) {
  421. if (!vcpu->mmio_is_write)
  422. kvmppc_complete_mmio_load(vcpu, run);
  423. vcpu->mmio_needed = 0;
  424. } else if (vcpu->arch.dcr_needed) {
  425. if (!vcpu->arch.dcr_is_write)
  426. kvmppc_complete_dcr_load(vcpu, run);
  427. vcpu->arch.dcr_needed = 0;
  428. } else if (vcpu->arch.osi_needed) {
  429. u64 *gprs = run->osi.gprs;
  430. int i;
  431. for (i = 0; i < 32; i++)
  432. kvmppc_set_gpr(vcpu, i, gprs[i]);
  433. vcpu->arch.osi_needed = 0;
  434. } else if (vcpu->arch.hcall_needed) {
  435. int i;
  436. kvmppc_set_gpr(vcpu, 3, run->papr_hcall.ret);
  437. for (i = 0; i < 9; ++i)
  438. kvmppc_set_gpr(vcpu, 4 + i, run->papr_hcall.args[i]);
  439. vcpu->arch.hcall_needed = 0;
  440. }
  441. kvmppc_core_deliver_interrupts(vcpu);
  442. r = kvmppc_vcpu_run(run, vcpu);
  443. if (vcpu->sigset_active)
  444. sigprocmask(SIG_SETMASK, &sigsaved, NULL);
  445. return r;
  446. }
  447. int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu, struct kvm_interrupt *irq)
  448. {
  449. if (irq->irq == KVM_INTERRUPT_UNSET)
  450. kvmppc_core_dequeue_external(vcpu, irq);
  451. else
  452. kvmppc_core_queue_external(vcpu, irq);
  453. if (waitqueue_active(&vcpu->wq)) {
  454. wake_up_interruptible(&vcpu->wq);
  455. vcpu->stat.halt_wakeup++;
  456. } else if (vcpu->cpu != -1) {
  457. smp_send_reschedule(vcpu->cpu);
  458. }
  459. return 0;
  460. }
  461. static int kvm_vcpu_ioctl_enable_cap(struct kvm_vcpu *vcpu,
  462. struct kvm_enable_cap *cap)
  463. {
  464. int r;
  465. if (cap->flags)
  466. return -EINVAL;
  467. switch (cap->cap) {
  468. case KVM_CAP_PPC_OSI:
  469. r = 0;
  470. vcpu->arch.osi_enabled = true;
  471. break;
  472. default:
  473. r = -EINVAL;
  474. break;
  475. }
  476. return r;
  477. }
  478. int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
  479. struct kvm_mp_state *mp_state)
  480. {
  481. return -EINVAL;
  482. }
  483. int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
  484. struct kvm_mp_state *mp_state)
  485. {
  486. return -EINVAL;
  487. }
  488. long kvm_arch_vcpu_ioctl(struct file *filp,
  489. unsigned int ioctl, unsigned long arg)
  490. {
  491. struct kvm_vcpu *vcpu = filp->private_data;
  492. void __user *argp = (void __user *)arg;
  493. long r;
  494. switch (ioctl) {
  495. case KVM_INTERRUPT: {
  496. struct kvm_interrupt irq;
  497. r = -EFAULT;
  498. if (copy_from_user(&irq, argp, sizeof(irq)))
  499. goto out;
  500. r = kvm_vcpu_ioctl_interrupt(vcpu, &irq);
  501. goto out;
  502. }
  503. case KVM_ENABLE_CAP:
  504. {
  505. struct kvm_enable_cap cap;
  506. r = -EFAULT;
  507. if (copy_from_user(&cap, argp, sizeof(cap)))
  508. goto out;
  509. r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
  510. break;
  511. }
  512. default:
  513. r = -EINVAL;
  514. }
  515. out:
  516. return r;
  517. }
  518. static int kvm_vm_ioctl_get_pvinfo(struct kvm_ppc_pvinfo *pvinfo)
  519. {
  520. u32 inst_lis = 0x3c000000;
  521. u32 inst_ori = 0x60000000;
  522. u32 inst_nop = 0x60000000;
  523. u32 inst_sc = 0x44000002;
  524. u32 inst_imm_mask = 0xffff;
  525. /*
  526. * The hypercall to get into KVM from within guest context is as
  527. * follows:
  528. *
  529. * lis r0, r0, KVM_SC_MAGIC_R0@h
  530. * ori r0, KVM_SC_MAGIC_R0@l
  531. * sc
  532. * nop
  533. */
  534. pvinfo->hcall[0] = inst_lis | ((KVM_SC_MAGIC_R0 >> 16) & inst_imm_mask);
  535. pvinfo->hcall[1] = inst_ori | (KVM_SC_MAGIC_R0 & inst_imm_mask);
  536. pvinfo->hcall[2] = inst_sc;
  537. pvinfo->hcall[3] = inst_nop;
  538. return 0;
  539. }
  540. long kvm_arch_vm_ioctl(struct file *filp,
  541. unsigned int ioctl, unsigned long arg)
  542. {
  543. void __user *argp = (void __user *)arg;
  544. long r;
  545. switch (ioctl) {
  546. case KVM_PPC_GET_PVINFO: {
  547. struct kvm_ppc_pvinfo pvinfo;
  548. memset(&pvinfo, 0, sizeof(pvinfo));
  549. r = kvm_vm_ioctl_get_pvinfo(&pvinfo);
  550. if (copy_to_user(argp, &pvinfo, sizeof(pvinfo))) {
  551. r = -EFAULT;
  552. goto out;
  553. }
  554. break;
  555. }
  556. default:
  557. r = -ENOTTY;
  558. }
  559. out:
  560. return r;
  561. }
  562. int kvm_arch_init(void *opaque)
  563. {
  564. return 0;
  565. }
  566. void kvm_arch_exit(void)
  567. {
  568. }