kvm.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2010 SUSE Linux Products GmbH. All rights reserved.
  3. *
  4. * Authors:
  5. * Alexander Graf <agraf@suse.de>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License, version 2, as
  9. * published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #include <linux/kvm_host.h>
  21. #include <linux/init.h>
  22. #include <linux/kvm_para.h>
  23. #include <linux/slab.h>
  24. #include <linux/of.h>
  25. #include <asm/reg.h>
  26. #include <asm/kvm_ppc.h>
  27. #include <asm/sections.h>
  28. #include <asm/cacheflush.h>
  29. #include <asm/disassemble.h>
  30. #define KVM_MAGIC_PAGE (-4096L)
  31. #define magic_var(x) KVM_MAGIC_PAGE + offsetof(struct kvm_vcpu_arch_shared, x)
  32. unsigned long kvm_hypercall(unsigned long *in,
  33. unsigned long *out,
  34. unsigned long nr)
  35. {
  36. unsigned long register r0 asm("r0");
  37. unsigned long register r3 asm("r3") = in[0];
  38. unsigned long register r4 asm("r4") = in[1];
  39. unsigned long register r5 asm("r5") = in[2];
  40. unsigned long register r6 asm("r6") = in[3];
  41. unsigned long register r7 asm("r7") = in[4];
  42. unsigned long register r8 asm("r8") = in[5];
  43. unsigned long register r9 asm("r9") = in[6];
  44. unsigned long register r10 asm("r10") = in[7];
  45. unsigned long register r11 asm("r11") = nr;
  46. unsigned long register r12 asm("r12");
  47. asm volatile("bl kvm_hypercall_start"
  48. : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6),
  49. "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11),
  50. "=r"(r12)
  51. : "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7), "r"(r8),
  52. "r"(r9), "r"(r10), "r"(r11)
  53. : "memory", "cc", "xer", "ctr", "lr");
  54. out[0] = r4;
  55. out[1] = r5;
  56. out[2] = r6;
  57. out[3] = r7;
  58. out[4] = r8;
  59. out[5] = r9;
  60. out[6] = r10;
  61. out[7] = r11;
  62. return r3;
  63. }
  64. EXPORT_SYMBOL_GPL(kvm_hypercall);