Skip to content

Commit

Permalink
KVM: SVM: reorganize svm_interrupt_allowed
Browse files Browse the repository at this point in the history
This patch reorganizes the logic in svm_interrupt_allowed to
make it better to read. This is important because the logic
is a lot more complicated with Nested SVM.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
  • Loading branch information
Joerg Roedel authored and Avi Kivity committed Dec 3, 2009
1 parent bfc33be commit 7fcdb51
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions arch/x86/kvm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2472,10 +2472,18 @@ static int svm_interrupt_allowed(struct kvm_vcpu *vcpu)
{
struct vcpu_svm *svm = to_svm(vcpu);
struct vmcb *vmcb = svm->vmcb;
return (vmcb->save.rflags & X86_EFLAGS_IF) &&
!(vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) &&
gif_set(svm) &&
!(is_nested(svm) && (svm->vcpu.arch.hflags & HF_VINTR_MASK));
int ret;

if (!gif_set(svm) ||
(vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK))
return 0;

ret = !!(vmcb->save.rflags & X86_EFLAGS_IF);

if (is_nested(svm))
return ret && !(svm->vcpu.arch.hflags & HF_VINTR_MASK);

return ret;
}

static void enable_irq_window(struct kvm_vcpu *vcpu)
Expand Down

0 comments on commit 7fcdb51

Please sign in to comment.