From patchwork Mon Feb 6 10:46:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 9557533 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 27C3860413 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 152D3223A6 for ; Mon, 6 Feb 2017 10:47:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A16B27F93; 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 6870826E54 for ; Mon, 6 Feb 2017 10:47:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751524AbdBFKrM (ORCPT ); Mon, 6 Feb 2017 05:47:12 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:52799 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbdBFKrK (ORCPT ); Mon, 6 Feb 2017 05:47:10 -0500 Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id 142224C9F949E; Mon, 6 Feb 2017 10:47:05 +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:07 +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 3/4] KVM: MIPS: Implement EXIT_VM hypercall Date: Mon, 6 Feb 2017 10:46:48 +0000 Message-ID: <0cdae923b50fc9ea8355e7520a935b7a6705c095.1486377433.git-series.james.hogan@imgtec.com> 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 EXIT_VM hypercall used by paravirtual guest kernels. When the guest performs this hypercall, the request is passed to userland in the form of a KVM_EXIT_SYSTEM_EVENT exit reason with system event type KVM_SYSTEM_EVENT_SHUTDOWN. 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 | 9 +++++++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/Documentation/virtual/kvm/hypercalls.txt b/Documentation/virtual/kvm/hypercalls.txt index e9f1c9d3da98..f8108c84c46b 100644 --- a/Documentation/virtual/kvm/hypercalls.txt +++ b/Documentation/virtual/kvm/hypercalls.txt @@ -92,3 +92,9 @@ is used in the hypercall for future use. Architecture: mips Status: active Purpose: Return the frequency of CP0_Count in HZ. + +7. KVM_HC_MIPS_EXIT_VM +------------------------ +Architecture: mips +Status: active +Purpose: Shut down the virtual machine. diff --git a/arch/mips/kvm/hypcall.c b/arch/mips/kvm/hypcall.c index 7c74ec25f2b9..c3345e5eec02 100644 --- a/arch/mips/kvm/hypcall.c +++ b/arch/mips/kvm/hypcall.c @@ -40,6 +40,15 @@ static int kvm_mips_hypercall(struct kvm_vcpu *vcpu, unsigned long num, *hret = (s32)vcpu->arch.count_hz; break; + case KVM_HC_MIPS_EXIT_VM: + /* Pass shutdown system event to userland */ + memset(&vcpu->run->system_event, 0, + sizeof(vcpu->run->system_event)); + vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SHUTDOWN; + vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; + ret = RESUME_HOST; + break; + default: /* Report unimplemented hypercall to guest */ *hret = -KVM_ENOSYS;