kvm_para.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_MIPS_KVM_PARA_H
  3. #define _ASM_MIPS_KVM_PARA_H
  4. #include <uapi/asm/kvm_para.h>
  5. #define KVM_HYPERCALL ".word 0x42000028"
  6. /*
  7. * Hypercalls for KVM.
  8. *
  9. * Hypercall number is passed in v0.
  10. * Return value will be placed in v0.
  11. * Up to 3 arguments are passed in a0, a1, and a2.
  12. */
  13. static inline unsigned long kvm_hypercall0(unsigned long num)
  14. {
  15. register unsigned long n asm("v0");
  16. register unsigned long r asm("v0");
  17. n = num;
  18. __asm__ __volatile__(
  19. KVM_HYPERCALL
  20. : "=r" (r) : "r" (n) : "memory"
  21. );
  22. return r;
  23. }
  24. static inline unsigned long kvm_hypercall1(unsigned long num,
  25. unsigned long arg0)
  26. {
  27. register unsigned long n asm("v0");
  28. register unsigned long r asm("v0");
  29. register unsigned long a0 asm("a0");
  30. n = num;
  31. a0 = arg0;
  32. __asm__ __volatile__(
  33. KVM_HYPERCALL
  34. : "=r" (r) : "r" (n), "r" (a0) : "memory"
  35. );
  36. return r;
  37. }
  38. static inline unsigned long kvm_hypercall2(unsigned long num,
  39. unsigned long arg0, unsigned long arg1)
  40. {
  41. register unsigned long n asm("v0");
  42. register unsigned long r asm("v0");
  43. register unsigned long a0 asm("a0");
  44. register unsigned long a1 asm("a1");
  45. n = num;
  46. a0 = arg0;
  47. a1 = arg1;
  48. __asm__ __volatile__(
  49. KVM_HYPERCALL
  50. : "=r" (r) : "r" (n), "r" (a0), "r" (a1) : "memory"
  51. );
  52. return r;
  53. }
  54. static inline unsigned long kvm_hypercall3(unsigned long num,
  55. unsigned long arg0, unsigned long arg1, unsigned long arg2)
  56. {
  57. register unsigned long n asm("v0");
  58. register unsigned long r asm("v0");
  59. register unsigned long a0 asm("a0");
  60. register unsigned long a1 asm("a1");
  61. register unsigned long a2 asm("a2");
  62. n = num;
  63. a0 = arg0;
  64. a1 = arg1;
  65. a2 = arg2;
  66. __asm__ __volatile__(
  67. KVM_HYPERCALL
  68. : "=r" (r) : "r" (n), "r" (a0), "r" (a1), "r" (a2) : "memory"
  69. );
  70. return r;
  71. }
  72. static inline bool kvm_check_and_clear_guest_paused(void)
  73. {
  74. return false;
  75. }
  76. static inline unsigned int kvm_arch_para_features(void)
  77. {
  78. return 0;
  79. }
  80. static inline unsigned int kvm_arch_para_hints(void)
  81. {
  82. return 0;
  83. }
  84. #ifdef CONFIG_MIPS_PARAVIRT
  85. static inline bool kvm_para_available(void)
  86. {
  87. return true;
  88. }
  89. #else
  90. static inline bool kvm_para_available(void)
  91. {
  92. return false;
  93. }
  94. #endif
  95. #endif /* _ASM_MIPS_KVM_PARA_H */