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 <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 | 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; -- git-series 0.8.10