@@ -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.
@@ -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)
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@imgtec.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Radim Krčmář" <rkrcmar@redhat.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com> Cc: David Daney <david.daney@cavium.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: linux-mips@linux-mips.org Cc: kvm@vger.kernel.org Cc: linux-doc@vger.kernel.org --- Documentation/virtual/kvm/hypercalls.txt | 6 ++++++ arch/mips/kvm/hypcall.c | 18 +++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-)