From patchwork Mon Feb 6 10:46:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 9557535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EFB7B60413 for ; Mon, 6 Feb 2017 10:47:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD1FC223A6 for ; Mon, 6 Feb 2017 10:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1D8A27F93; Mon, 6 Feb 2017 10:47:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 735EF223A6 for ; Mon, 6 Feb 2017 10:47:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751468AbdBFKrL (ORCPT ); Mon, 6 Feb 2017 05:47:11 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:38480 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751438AbdBFKrJ (ORCPT ); Mon, 6 Feb 2017 05:47:09 -0500 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 5CCE0EAAE93DE; Mon, 6 Feb 2017 10:47:04 +0000 (GMT) Received: from jhogan-linux.le.imgtec.org (192.168.154.110) by hhmail02.hh.imgtec.org (10.100.10.21) with Microsoft SMTP Server (TLS) id 14.3.294.0; Mon, 6 Feb 2017 10:47:06 +0000 From: James Hogan To: CC: James Hogan , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Ralf Baechle , Andreas Herrmann , David Daney , Jonathan Corbet , , Subject: [PATCH 2/4] KVM: MIPS: Implement GET_CLOCK_FREQ hypercall Date: Mon, 6 Feb 2017 10:46:47 +0000 Message-ID: X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 In-Reply-To: References: X-Originating-IP: [192.168.154.110] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Paolo Bonzini Cc: "Radim Krčmář" Cc: Ralf Baechle Cc: Andreas Herrmann Cc: David Daney Cc: Jonathan Corbet 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(-) 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)