Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b19f3e6 authored by Avi Kivity's avatar Avi Kivity
Browse files

KVM: Add a special exit reason when exiting due to an interrupt



This is redundant, as we also return -EINTR from the ioctl, but it
allows us to examine the exit_reason field on resume without seeing
old data.

Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 8eb7d334
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -1619,12 +1619,14 @@ static int svm_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
		if (signal_pending(current)) {
		if (signal_pending(current)) {
			++kvm_stat.signal_exits;
			++kvm_stat.signal_exits;
			post_kvm_run_save(vcpu, kvm_run);
			post_kvm_run_save(vcpu, kvm_run);
			kvm_run->exit_reason = KVM_EXIT_INTR;
			return -EINTR;
			return -EINTR;
		}
		}


		if (dm_request_for_irq_injection(vcpu, kvm_run)) {
		if (dm_request_for_irq_injection(vcpu, kvm_run)) {
			++kvm_stat.request_irq_exits;
			++kvm_stat.request_irq_exits;
			post_kvm_run_save(vcpu, kvm_run);
			post_kvm_run_save(vcpu, kvm_run);
			kvm_run->exit_reason = KVM_EXIT_INTR;
			return -EINTR;
			return -EINTR;
		}
		}
		kvm_resched(vcpu);
		kvm_resched(vcpu);
+2 −0
Original line number Original line Diff line number Diff line
@@ -1941,12 +1941,14 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
			if (signal_pending(current)) {
			if (signal_pending(current)) {
				++kvm_stat.signal_exits;
				++kvm_stat.signal_exits;
				post_kvm_run_save(vcpu, kvm_run);
				post_kvm_run_save(vcpu, kvm_run);
				kvm_run->exit_reason = KVM_EXIT_INTR;
				return -EINTR;
				return -EINTR;
			}
			}


			if (dm_request_for_irq_injection(vcpu, kvm_run)) {
			if (dm_request_for_irq_injection(vcpu, kvm_run)) {
				++kvm_stat.request_irq_exits;
				++kvm_stat.request_irq_exits;
				post_kvm_run_save(vcpu, kvm_run);
				post_kvm_run_save(vcpu, kvm_run);
				kvm_run->exit_reason = KVM_EXIT_INTR;
				return -EINTR;
				return -EINTR;
			}
			}


+2 −1
Original line number Original line Diff line number Diff line
@@ -11,7 +11,7 @@
#include <asm/types.h>
#include <asm/types.h>
#include <linux/ioctl.h>
#include <linux/ioctl.h>


#define KVM_API_VERSION 8
#define KVM_API_VERSION 9


/*
/*
 * Architectural interrupt line count, and the size of the bitmap needed
 * Architectural interrupt line count, and the size of the bitmap needed
@@ -45,6 +45,7 @@ enum kvm_exit_reason {
	KVM_EXIT_IRQ_WINDOW_OPEN  = 7,
	KVM_EXIT_IRQ_WINDOW_OPEN  = 7,
	KVM_EXIT_SHUTDOWN         = 8,
	KVM_EXIT_SHUTDOWN         = 8,
	KVM_EXIT_FAIL_ENTRY       = 9,
	KVM_EXIT_FAIL_ENTRY       = 9,
	KVM_EXIT_INTR             = 10,
};
};


/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */