aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2008-12-18 13:30:57 +0100
committerAvi Kivity <avi@redhat.com>2008-12-23 19:53:19 +0200
commit7b8052aecd9c533661493d1140cbec0e1ab311d3 (patch)
tree4748d1946071505af559ba02aae18166174da7bf
parente72dcf1240f59174ff7c18bd461021a00ed3e38c (diff)
KVM: SVM: don't run into endless loop in nested svmkvm-82rc1
With the emulation optimization after clgi, we can potentially run into an endless loop thanks to while(true). While this should never occur in practise, except for when the emulation is broken or really awkward code is executed in the VM, this wasn't a problem so far. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--arch/x86/kvm/svm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index f67ca16cd797..6577934fa096 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -1848,6 +1848,8 @@ static int stgi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
static int clgi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
{
+ int loopcount = 0;
+
if (nested_svm_check_permissions(svm))
return 1;
@@ -1862,7 +1864,7 @@ static int clgi_interception(struct vcpu_svm *svm, struct kvm_run *kvm_run)
/* Let's try to emulate as many instructions as possible in GIF=0 */
- while(true) {
+ while (++loopcount < 100) {
int er;
er = emulate_instruction(&svm->vcpu, kvm_run, 0, 0, 0);