diff options
| author | David Daney <david.daney@cavium.com> | 2014-05-28 17:52:12 -0400 |
|---|---|---|
| committer | Ralf Baechle <ralf@linux-mips.org> | 2014-05-30 15:01:11 -0400 |
| commit | 90dfdc7ceb577c0d7b7635def3c62039a091e50d (patch) | |
| tree | e20938cbe7d542786d79371b38a6ba0090c8829a | |
| parent | cd3f5389489146297eb2c11e4f9d1c4e8aaeb59f (diff) | |
MIPS: Add functions for hypervisor call
Introduce kvm_hypercall[0-3].
Define three new hypercalls for MIPS: GET_CLOCK_FREQ, EXIT_VM, and
CONSOLE_OUTPUT.
[andreas.herrmann:
* Properly define hypercalls and HC numbers for MIPS
in kvm_para.h header files]
Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>
Cc: linux-mips@linux-mips.org
Cc: James Hogan <james.hogan@imgtec.com>
Cc: kvm@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/7005/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
| -rw-r--r-- | arch/mips/include/asm/kvm_para.h | 109 | ||||
| -rw-r--r-- | arch/mips/include/uapi/asm/kvm_para.h | 6 | ||||
| -rw-r--r-- | include/uapi/linux/kvm_para.h | 3 |
3 files changed, 117 insertions, 1 deletions
diff --git a/arch/mips/include/asm/kvm_para.h b/arch/mips/include/asm/kvm_para.h new file mode 100644 index 000000000000..5a9aa918abe6 --- /dev/null +++ b/arch/mips/include/asm/kvm_para.h | |||
| @@ -0,0 +1,109 @@ | |||
| 1 | #ifndef _ASM_MIPS_KVM_PARA_H | ||
| 2 | #define _ASM_MIPS_KVM_PARA_H | ||
| 3 | |||
| 4 | #include <uapi/asm/kvm_para.h> | ||
| 5 | |||
| 6 | #define KVM_HYPERCALL ".word 0x42000028" | ||
| 7 | |||
| 8 | /* | ||
| 9 | * Hypercalls for KVM. | ||
| 10 | * | ||
| 11 | * Hypercall number is passed in v0. | ||
| 12 | * Return value will be placed in v0. | ||
| 13 | * Up to 3 arguments are passed in a0, a1, and a2. | ||
| 14 | */ | ||
| 15 | static inline unsigned long kvm_hypercall0(unsigned long num) | ||
| 16 | { | ||
| 17 | register unsigned long n asm("v0"); | ||
| 18 | register unsigned long r asm("v0"); | ||
| 19 | |||
| 20 | n = num; | ||
| 21 | __asm__ __volatile__( | ||
| 22 | KVM_HYPERCALL | ||
| 23 | : "=r" (r) : "r" (n) : "memory" | ||
| 24 | ); | ||
| 25 | |||
| 26 | return r; | ||
| 27 | } | ||
| 28 | |||
| 29 | static inline unsigned long kvm_hypercall1(unsigned long num, | ||
| 30 | unsigned long arg0) | ||
| 31 | { | ||
| 32 | register unsigned long n asm("v0"); | ||
| 33 | register unsigned long r asm("v0"); | ||
| 34 | register unsigned long a0 asm("a0"); | ||
| 35 | |||
| 36 | n = num; | ||
| 37 | a0 = arg0; | ||
| 38 | __asm__ __volatile__( | ||
| 39 | KVM_HYPERCALL | ||
| 40 | : "=r" (r) : "r" (n), "r" (a0) : "memory" | ||
| 41 | ); | ||
| 42 | |||
| 43 | return r; | ||
| 44 | } | ||
| 45 | |||
| 46 | static inline unsigned long kvm_hypercall2(unsigned long num, | ||
| 47 | unsigned long arg0, unsigned long arg1) | ||
| 48 | { | ||
| 49 | register unsigned long n asm("v0"); | ||
| 50 | register unsigned long r asm("v0"); | ||
| 51 | register unsigned long a0 asm("a0"); | ||
| 52 | register unsigned long a1 asm("a1"); | ||
| 53 | |||
| 54 | n = num; | ||
| 55 | a0 = arg0; | ||
| 56 | a1 = arg1; | ||
| 57 | __asm__ __volatile__( | ||
| 58 | KVM_HYPERCALL | ||
| 59 | : "=r" (r) : "r" (n), "r" (a0), "r" (a1) : "memory" | ||
| 60 | ); | ||
| 61 | |||
| 62 | return r; | ||
| 63 | } | ||
| 64 | |||
| 65 | static inline unsigned long kvm_hypercall3(unsigned long num, | ||
| 66 | unsigned long arg0, unsigned long arg1, unsigned long arg2) | ||
| 67 | { | ||
| 68 | register unsigned long n asm("v0"); | ||
| 69 | register unsigned long r asm("v0"); | ||
| 70 | register unsigned long a0 asm("a0"); | ||
| 71 | register unsigned long a1 asm("a1"); | ||
| 72 | register unsigned long a2 asm("a2"); | ||
| 73 | |||
| 74 | n = num; | ||
| 75 | a0 = arg0; | ||
| 76 | a1 = arg1; | ||
| 77 | a2 = arg2; | ||
| 78 | __asm__ __volatile__( | ||
| 79 | KVM_HYPERCALL | ||
| 80 | : "=r" (r) : "r" (n), "r" (a0), "r" (a1), "r" (a2) : "memory" | ||
| 81 | ); | ||
| 82 | |||
| 83 | return r; | ||
| 84 | } | ||
| 85 | |||
| 86 | static inline bool kvm_check_and_clear_guest_paused(void) | ||
| 87 | { | ||
| 88 | return false; | ||
| 89 | } | ||
| 90 | |||
| 91 | static inline unsigned int kvm_arch_para_features(void) | ||
| 92 | { | ||
| 93 | return 0; | ||
| 94 | } | ||
| 95 | |||
| 96 | #ifdef CONFIG_MIPS_PARAVIRT | ||
| 97 | static inline bool kvm_para_available(void) | ||
| 98 | { | ||
| 99 | return true; | ||
| 100 | } | ||
| 101 | #else | ||
| 102 | static inline bool kvm_para_available(void) | ||
| 103 | { | ||
| 104 | return false; | ||
| 105 | } | ||
| 106 | #endif | ||
| 107 | |||
| 108 | |||
| 109 | #endif /* _ASM_MIPS_KVM_PARA_H */ | ||
diff --git a/arch/mips/include/uapi/asm/kvm_para.h b/arch/mips/include/uapi/asm/kvm_para.h index 14fab8f0b957..7e16d7c42e65 100644 --- a/arch/mips/include/uapi/asm/kvm_para.h +++ b/arch/mips/include/uapi/asm/kvm_para.h | |||
| @@ -1 +1,5 @@ | |||
| 1 | #include <asm-generic/kvm_para.h> | 1 | #ifndef _UAPI_ASM_MIPS_KVM_PARA_H |
| 2 | #define _UAPI_ASM_MIPS_KVM_PARA_H | ||
| 3 | |||
| 4 | |||
| 5 | #endif /* _UAPI_ASM_MIPS_KVM_PARA_H */ | ||
diff --git a/include/uapi/linux/kvm_para.h b/include/uapi/linux/kvm_para.h index 2841f86eae0b..bf6cd7d5cac2 100644 --- a/include/uapi/linux/kvm_para.h +++ b/include/uapi/linux/kvm_para.h | |||
| @@ -20,6 +20,9 @@ | |||
| 20 | #define KVM_HC_FEATURES 3 | 20 | #define KVM_HC_FEATURES 3 |
| 21 | #define KVM_HC_PPC_MAP_MAGIC_PAGE 4 | 21 | #define KVM_HC_PPC_MAP_MAGIC_PAGE 4 |
| 22 | #define KVM_HC_KICK_CPU 5 | 22 | #define KVM_HC_KICK_CPU 5 |
| 23 | #define KVM_HC_MIPS_GET_CLOCK_FREQ 6 | ||
| 24 | #define KVM_HC_MIPS_EXIT_VM 7 | ||
| 25 | #define KVM_HC_MIPS_CONSOLE_OUTPUT 8 | ||
| 23 | 26 | ||
| 24 | /* | 27 | /* |
| 25 | * hypercalls use architecture specific | 28 | * hypercalls use architecture specific |
