Skip to contentSkip to conversation

nested SVM: don't run into endless loop

PATCH Applied Alexander Graf 2 participants 2 messages Dec 18, 2008 – Dec 23, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nested SVM: don't run into endless loop

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.

---
 arch/x86/kvm/svm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
arch/x86/kvm/svm.c +3 -1
index f67ca16..bf901e7 100644
@@ -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);
Signature · 1 line
1.5.6
Applied
#1 lore raw
Quoted 8 lines · Alexander Graf

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.

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function