[PATCH 2/4] KVM: MIPS: Implement GET_CLOCK_FREQ hypercall

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Implement the MIPS GET_CLOCK_FREQ hypercall used by paravirtual guest
kernels. When the guest performs this hypercall, the value of count_hz
is returned, which is the current rate of the CP0_Count register.

We also document the hypercall along with the others as the
documentation was never added.

Signed-off-by: James Hogan <james.hogan@xxxxxxxxxx>
Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Cc: "Radim Krčmář" <rkrcmar@xxxxxxxxxx>
Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
Cc: Andreas Herrmann <andreas.herrmann@xxxxxxxxxxxxxxxxxx>
Cc: David Daney <david.daney@xxxxxxxxxx>
Cc: Jonathan Corbet <corbet@xxxxxxx>
Cc: linux-mips@xxxxxxxxxxxxxx
Cc: kvm@xxxxxxxxxxxxxxx
Cc: linux-doc@xxxxxxxxxxxxxxx
---
 Documentation/virtual/kvm/hypercalls.txt |  6 ++++++
 arch/mips/kvm/hypcall.c                  | 18 +++++++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/Documentation/virtual/kvm/hypercalls.txt b/Documentation/virtual/kvm/hypercalls.txt
index 8f36582ce2b7..e9f1c9d3da98 100644
--- a/Documentation/virtual/kvm/hypercalls.txt
+++ b/Documentation/virtual/kvm/hypercalls.txt
@@ -86,3 +86,9 @@ the vcpu to sleep until occurrence of an appropriate event. Another vcpu of the
 same guest can wakeup the sleeping vcpu by issuing KVM_HC_KICK_CPU hypercall,
 specifying APIC ID (a1) of the vcpu to be woken up. An additional argument (a0)
 is used in the hypercall for future use.
+
+6. KVM_HC_MIPS_GET_CLOCK_FREQ
+------------------------
+Architecture: mips
+Status: active
+Purpose: Return the frequency of CP0_Count in HZ.
diff --git a/arch/mips/kvm/hypcall.c b/arch/mips/kvm/hypcall.c
index 83063435195f..7c74ec25f2b9 100644
--- a/arch/mips/kvm/hypcall.c
+++ b/arch/mips/kvm/hypcall.c
@@ -32,9 +32,21 @@ enum emulation_result kvm_mips_emul_hypcall(struct kvm_vcpu *vcpu,
 static int kvm_mips_hypercall(struct kvm_vcpu *vcpu, unsigned long num,
 			      const unsigned long *args, unsigned long *hret)
 {
-	/* Report unimplemented hypercall to guest */
-	*hret = -KVM_ENOSYS;
-	return RESUME_GUEST;
+	int ret = RESUME_GUEST;
+
+	switch (num) {
+	case KVM_HC_MIPS_GET_CLOCK_FREQ:
+		/* Return frequency of count/compare timer */
+		*hret = (s32)vcpu->arch.count_hz;
+		break;
+
+	default:
+		/* Report unimplemented hypercall to guest */
+		*hret = -KVM_ENOSYS;
+		break;
+	};
+
+	return ret;
 }
 
 int kvm_mips_handle_hypcall(struct kvm_vcpu *vcpu)
-- 
git-series 0.8.10



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux