aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2007-01-26 03:56:42 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-01-26 16:50:57 -0500
commit46fe4ddd9dbb15305ab9b458e6cfa4dd47ac3e47 (patch)
treed7a7d0443d519f7de0b6c5157cf610726b4ab0bf /drivers/kvm
parent73b1087e6176a34c01eea3db269848f72fad72c1 (diff)
[PATCH] KVM: SVM: Propagate cpu shutdown events to userspace
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> Signed-off-by: Avi Kivity <avi@qumranet.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/svm.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 717aabb012cc..9c70ff65e6b7 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -502,6 +502,7 @@ static void init_vmcb(struct vmcb *vmcb)
502 (1ULL << INTERCEPT_IOIO_PROT) | 502 (1ULL << INTERCEPT_IOIO_PROT) |
503 (1ULL << INTERCEPT_MSR_PROT) | 503 (1ULL << INTERCEPT_MSR_PROT) |
504 (1ULL << INTERCEPT_TASK_SWITCH) | 504 (1ULL << INTERCEPT_TASK_SWITCH) |
505 (1ULL << INTERCEPT_SHUTDOWN) |
505 (1ULL << INTERCEPT_VMRUN) | 506 (1ULL << INTERCEPT_VMRUN) |
506 (1ULL << INTERCEPT_VMMCALL) | 507 (1ULL << INTERCEPT_VMMCALL) |
507 (1ULL << INTERCEPT_VMLOAD) | 508 (1ULL << INTERCEPT_VMLOAD) |
@@ -892,6 +893,19 @@ static int pf_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
892 return 0; 893 return 0;
893} 894}
894 895
896static int shutdown_interception(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
897{
898 /*
899 * VMCB is undefined after a SHUTDOWN intercept
900 * so reinitialize it.
901 */
902 memset(vcpu->svm->vmcb, 0, PAGE_SIZE);
903 init_vmcb(vcpu->svm->vmcb);
904
905 kvm_run->exit_reason = KVM_EXIT_SHUTDOWN;
906 return 0;
907}
908
895static int io_get_override(struct kvm_vcpu *vcpu, 909static int io_get_override(struct kvm_vcpu *vcpu,
896 struct vmcb_seg **seg, 910 struct vmcb_seg **seg,
897 int *addr_override) 911 int *addr_override)
@@ -1249,6 +1263,7 @@ static int (*svm_exit_handlers[])(struct kvm_vcpu *vcpu,
1249 [SVM_EXIT_IOIO] = io_interception, 1263 [SVM_EXIT_IOIO] = io_interception,
1250 [SVM_EXIT_MSR] = msr_interception, 1264 [SVM_EXIT_MSR] = msr_interception,
1251 [SVM_EXIT_TASK_SWITCH] = task_switch_interception, 1265 [SVM_EXIT_TASK_SWITCH] = task_switch_interception,
1266 [SVM_EXIT_SHUTDOWN] = shutdown_interception,
1252 [SVM_EXIT_VMRUN] = invalid_op_interception, 1267 [SVM_EXIT_VMRUN] = invalid_op_interception,
1253 [SVM_EXIT_VMMCALL] = invalid_op_interception, 1268 [SVM_EXIT_VMMCALL] = invalid_op_interception,
1254 [SVM_EXIT_VMLOAD] = invalid_op_interception, 1269 [SVM_EXIT_VMLOAD] = invalid_op_interception,