From patchwork Mon Jun 20 13:38:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gollub X-Patchwork-Id: 897432 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5KDkFmi024258 for ; Mon, 20 Jun 2011 13:46:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753394Ab1FTNqA (ORCPT ); Mon, 20 Jun 2011 09:46:00 -0400 Received: from schattenjagd.systems.b1-systems.de ([217.11.58.34]:36579 "EHLO mx1.b1-systems.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754581Ab1FTNp4 (ORCPT ); Mon, 20 Jun 2011 09:45:56 -0400 Received: from marvin.site (ppp-88-217-124-96.dynamic.mnet-online.de [88.217.124.96]) by mx1.b1-systems.de (Postfix) with ESMTPSA id 28035406C; Mon, 20 Jun 2011 15:40:18 +0200 (CEST) From: Daniel Gollub To: kvm@vger.kernel.org Cc: Daniel Gollub Subject: [PATCH 1/2] Inroduce panic hypercall KVM_HC_PANIC (host) Date: Mon, 20 Jun 2011 15:38:13 +0200 Message-Id: <1308577094-17551-2-git-send-email-gollub@b1-systems.de> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308577094-17551-1-git-send-email-gollub@b1-systems.de> References: <1308577094-17551-1-git-send-email-gollub@b1-systems.de> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 20 Jun 2011 13:46:15 +0000 (UTC) Introduce panic hypercall (KVM_HC_PANIC) on host-end to signal that the guest crashed/paniced. This gets signal to userspace with KVM API and ioctl KVM_RUN with exit_reason: KVM_EXIT_PANIC Signed-off-by: Daniel Gollub --- arch/x86/kvm/x86.c | 9 +++++++++ include/linux/kvm.h | 1 + include/linux/kvm_host.h | 1 + include/linux/kvm_para.h | 1 + 4 files changed, 12 insertions(+), 0 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index d88de56..bbe91fe 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -5103,6 +5103,10 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu) case KVM_HC_MMU_OP: r = kvm_pv_mmu_op(vcpu, a0, hc_gpa(vcpu, a1, a2), &ret); break; + case KVM_HC_PANIC: + set_bit(KVM_REQ_PANIC, &vcpu->requests); + ret = 0; + break; default: ret = -KVM_ENOSYS; break; @@ -5431,6 +5435,11 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) r = 1; goto out; } + if (kvm_check_request(KVM_REQ_PANIC, vcpu)) { + vcpu->run->exit_reason = KVM_EXIT_PANIC; + r = 0; + goto out; + } } r = kvm_mmu_reload(vcpu); diff --git a/include/linux/kvm.h b/include/linux/kvm.h index 55ef181..8a8b609 100644 --- a/include/linux/kvm.h +++ b/include/linux/kvm.h @@ -161,6 +161,7 @@ struct kvm_pit_config { #define KVM_EXIT_NMI 16 #define KVM_EXIT_INTERNAL_ERROR 17 #define KVM_EXIT_OSI 18 +#define KVM_EXIT_PANIC 19 /* For KVM_EXIT_INTERNAL_ERROR */ #define KVM_INTERNAL_ERROR_EMULATION 1 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b9c3299..1819414 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -47,6 +47,7 @@ #define KVM_REQ_DEACTIVATE_FPU 10 #define KVM_REQ_EVENT 11 #define KVM_REQ_APF_HALT 12 +#define KVM_REQ_PANIC 13 #define KVM_USERSPACE_IRQ_SOURCE_ID 0 diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h index 47a070b..5cdf61b 100644 --- a/include/linux/kvm_para.h +++ b/include/linux/kvm_para.h @@ -19,6 +19,7 @@ #define KVM_HC_MMU_OP 2 #define KVM_HC_FEATURES 3 #define KVM_HC_PPC_MAP_MAGIC_PAGE 4 +#define KVM_HC_PANIC 5 /* * hypercalls use architecture specific