kvm.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. unsigned long kvm_hypercall(unsigned long *in,
  31. unsigned long *out,
  32. unsigned long nr)
  33. {
  34. unsigned long register r0 asm("r0");
  35. unsigned long register r3 asm("r3") = in[0];
  36. unsigned long register r4 asm("r4") = in[1];
  37. unsigned long register r5 asm("r5") = in[2];
  38. unsigned long register r6 asm("r6") = in[3];
  39. unsigned long register r7 asm("r7") = in[4];
  40. unsigned long register r8 asm("r8") = in[5];
  41. unsigned long register r9 asm("r9") = in[6];
  42. unsigned long register r10 asm("r10") = in[7];
  43. unsigned long register r11 asm("r11") = nr;
  44. unsigned long register r12 asm("r12");
  45. asm volatile("bl kvm_hypercall_start"
  46. : "=r"(r0), "=r"(r3), "=r"(r4), "=r"(r5), "=r"(r6),
  47. "=r"(r7), "=r"(r8), "=r"(r9), "=r"(r10), "=r"(r11),
  48. "=r"(r12)
  49. : "r"(r3), "r"(r4), "r"(r5), "r"(r6), "r"(r7), "r"(r8),
  50. "r"(r9), "r"(r10), "r"(r11)
  51. : "memory", "cc", "xer", "ctr", "lr");
  52. out[0] = r4;
  53. out[1] = r5;
  54. out[2] = r6;
  55. out[3] = r7;
  56. out[4] = r8;
  57. out[5] = r9;
  58. out[6] = r10;
  59. out[7] = r11;
  60. return r3;
  61. }
  62. EXPORT_SYMBOL_GPL(kvm_hypercall);