LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] KVM: propagate SHUTDOWN intercept to userspace on SVM
@ 2007-01-23 12:50 Joerg Roedel
  2007-01-23 13:08 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Joerg Roedel @ 2007-01-23 12:50 UTC (permalink / raw)
  To: Avi Kivity; +Cc: linux-kernel, kvm-devel

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

This patch implements forwarding of SHUTDOWN intercepts from the guest
on to userspace on AMD SVM. A SHUTDOWN event occurs when the guest produces
a triple fault (e.g. on reboot). This also fixes the bug that a guest
reboot actually causes a host reboot under some circumstances.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

-- 
Joerg Roedel
Operating System Research Center
AMD Saxony LLC & Co. KG

[-- Attachment #2: kvm-svm-reboot.patch --]
[-- Type: text/plain, Size: 1711 bytes --]

diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 714f6a7..1bbaa16 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -502,6 +502,7 @@ static void init_vmcb(struct vmcb *vmcb)
 				(1ULL << INTERCEPT_IOIO_PROT) |
 				(1ULL << INTERCEPT_MSR_PROT) |
 				(1ULL << INTERCEPT_TASK_SWITCH) |
+				(1ULL << INTERCEPT_SHUTDOWN) |
 				(1ULL << INTERCEPT_VMRUN) |
 				(1ULL << INTERCEPT_VMMCALL) |
 				(1ULL << INTERCEPT_VMLOAD) |
@@ -892,6 +893,19 @@ static int pf_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
 	return 0;
 }
 
+static int shutdown_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
+{
+	/* 
+	 * VMCB is undefined after a SHUTDOWN intercept 
+	 * so reinitalize it
+	 */
+	memset(vcpu->svm->vmcb, 0, PAGE_SIZE);
+	init_vmcb(vcpu->svm->vmcb);
+
+	kvm_run->exit_reason = KVM_EXIT_SHUTDOWN;
+	return 0;
+}
+
 static int io_get_override(struct kvm_vcpu *vcpu,
 			  struct vmcb_seg **seg,
 			  int *addr_override)
@@ -1249,6 +1263,7 @@ static int (*svm_exit_handlers[])(struct kvm_vcpu *vcpu,
 	[SVM_EXIT_IOIO] 		  	= io_interception,
 	[SVM_EXIT_MSR]				= msr_interception,
 	[SVM_EXIT_TASK_SWITCH]			= task_switch_interception,
+	[SVM_EXIT_SHUTDOWN]			= shutdown_interception,
 	[SVM_EXIT_VMRUN]			= invalid_op_interception,
 	[SVM_EXIT_VMMCALL]			= invalid_op_interception,
 	[SVM_EXIT_VMLOAD]			= invalid_op_interception,
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index bc8b461..1be148f 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -46,6 +46,7 @@ enum kvm_exit_reason {
 	KVM_EXIT_HLT              = 5,
 	KVM_EXIT_MMIO             = 6,
 	KVM_EXIT_IRQ_WINDOW_OPEN  = 7,
+	KVM_EXIT_SHUTDOWN         = 8,
 };
 
 /* for KVM_RUN */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] KVM: propagate SHUTDOWN intercept to userspace on SVM
  2007-01-23 12:50 [PATCH] KVM: propagate SHUTDOWN intercept to userspace on SVM Joerg Roedel
@ 2007-01-23 13:08 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2007-01-23 13:08 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: linux-kernel, kvm-devel

Joerg Roedel wrote:
> This patch implements forwarding of SHUTDOWN intercepts from the guest
> on to userspace on AMD SVM. A SHUTDOWN event occurs when the guest produces
> a triple fault (e.g. on reboot). This also fixes the bug that a guest
> reboot actually causes a host reboot under some circumstances.
>
>   

Applied, thanks.


-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-01-23 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-01-23 12:50 [PATCH] KVM: propagate SHUTDOWN intercept to userspace on SVM Joerg Roedel
2007-01-23 13:08 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).