KVM: Fold kvm_run::exit_type into kvm_run::exit_reason
Currently, userspace is told about the nature of the last exit from the guest using two fields, exit_type and exit_reason, where exit_type has just two enumerations (and no need for more). So fold exit_type into exit_reason, reducing the complexity of determining what really happened. Signed-off-by: Avi Kivity <avi@qumranet.com>
This commit is contained in:
parent
b4e63f560b
commit
8eb7d334bd
|
@ -1608,8 +1608,7 @@ static int kvm_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
|||
|
||||
vcpu->mmio_needed = 0;
|
||||
|
||||
if (kvm_run->exit_type == KVM_EXIT_TYPE_VM_EXIT
|
||||
&& kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
|
||||
if (kvm_run->exit_reason == KVM_EXIT_HYPERCALL) {
|
||||
kvm_arch_ops->cache_regs(vcpu);
|
||||
vcpu->regs[VCPU_REGS_RAX] = kvm_run->hypercall.ret;
|
||||
kvm_arch_ops->decache_regs(vcpu);
|
||||
|
|
|
@ -1298,8 +1298,6 @@ static int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
|
|||
{
|
||||
u32 exit_code = vcpu->svm->vmcb->control.exit_code;
|
||||
|
||||
kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT;
|
||||
|
||||
if (is_external_interrupt(vcpu->svm->vmcb->control.exit_int_info) &&
|
||||
exit_code != SVM_EXIT_EXCP_BASE + PF_VECTOR)
|
||||
printk(KERN_ERR "%s: unexpected exit_ini_info 0x%x "
|
||||
|
@ -1609,8 +1607,9 @@ again:
|
|||
vcpu->svm->next_rip = 0;
|
||||
|
||||
if (vcpu->svm->vmcb->control.exit_code == SVM_EXIT_ERR) {
|
||||
kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY;
|
||||
kvm_run->exit_reason = vcpu->svm->vmcb->control.exit_code;
|
||||
kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
|
||||
kvm_run->fail_entry.hardware_entry_failure_reason
|
||||
= vcpu->svm->vmcb->control.exit_code;
|
||||
post_kvm_run_save(vcpu, kvm_run);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1922,10 +1922,10 @@ again:
|
|||
|
||||
asm ("mov %0, %%ds; mov %0, %%es" : : "r"(__USER_DS));
|
||||
|
||||
kvm_run->exit_type = 0;
|
||||
if (fail) {
|
||||
kvm_run->exit_type = KVM_EXIT_TYPE_FAIL_ENTRY;
|
||||
kvm_run->exit_reason = vmcs_read32(VM_INSTRUCTION_ERROR);
|
||||
kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
|
||||
kvm_run->fail_entry.hardware_entry_failure_reason
|
||||
= vmcs_read32(VM_INSTRUCTION_ERROR);
|
||||
r = 0;
|
||||
} else {
|
||||
/*
|
||||
|
@ -1935,7 +1935,6 @@ again:
|
|||
profile_hit(KVM_PROFILING, (void *)vmcs_readl(GUEST_RIP));
|
||||
|
||||
vcpu->launched = 1;
|
||||
kvm_run->exit_type = KVM_EXIT_TYPE_VM_EXIT;
|
||||
r = kvm_handle_exit(kvm_run, vcpu);
|
||||
if (r > 0) {
|
||||
/* Give scheduler a change to reschedule. */
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <asm/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
#define KVM_API_VERSION 7
|
||||
#define KVM_API_VERSION 8
|
||||
|
||||
/*
|
||||
* Architectural interrupt line count, and the size of the bitmap needed
|
||||
|
@ -34,9 +34,6 @@ struct kvm_memory_region {
|
|||
#define KVM_MEM_LOG_DIRTY_PAGES 1UL
|
||||
|
||||
|
||||
#define KVM_EXIT_TYPE_FAIL_ENTRY 1
|
||||
#define KVM_EXIT_TYPE_VM_EXIT 2
|
||||
|
||||
enum kvm_exit_reason {
|
||||
KVM_EXIT_UNKNOWN = 0,
|
||||
KVM_EXIT_EXCEPTION = 1,
|
||||
|
@ -47,6 +44,7 @@ enum kvm_exit_reason {
|
|||
KVM_EXIT_MMIO = 6,
|
||||
KVM_EXIT_IRQ_WINDOW_OPEN = 7,
|
||||
KVM_EXIT_SHUTDOWN = 8,
|
||||
KVM_EXIT_FAIL_ENTRY = 9,
|
||||
};
|
||||
|
||||
/* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
|
||||
|
@ -57,12 +55,11 @@ struct kvm_run {
|
|||
__u8 padding1[3];
|
||||
|
||||
/* out */
|
||||
__u32 exit_type;
|
||||
__u32 exit_reason;
|
||||
__u32 instruction_length;
|
||||
__u8 ready_for_interrupt_injection;
|
||||
__u8 if_flag;
|
||||
__u16 padding2;
|
||||
__u8 padding2[6];
|
||||
|
||||
/* in (pre_kvm_run), out (post_kvm_run) */
|
||||
__u64 cr8;
|
||||
|
@ -71,8 +68,12 @@ struct kvm_run {
|
|||
union {
|
||||
/* KVM_EXIT_UNKNOWN */
|
||||
struct {
|
||||
__u32 hardware_exit_reason;
|
||||
__u64 hardware_exit_reason;
|
||||
} hw;
|
||||
/* KVM_EXIT_FAIL_ENTRY */
|
||||
struct {
|
||||
__u64 hardware_entry_failure_reason;
|
||||
} fail_entry;
|
||||
/* KVM_EXIT_EXCEPTION */
|
||||
struct {
|
||||
__u32 exception;
|
||||
|
|
Loading…
Reference in New Issue