Skip to content

Commit 322a569

Browse files
committed
KVM: VMX: Split out the non-virtualization part of vmx_interrupt_blocked()
Move the non-VMX chunk of the "interrupt blocked" checks to a separate helper so that KVM can reuse the code to detect if interrupts are blocked for L2, e.g. to determine if a virtual interrupt _for L2_ is a valid wake event. If L1 disables HLT-exiting for L2, nested APICv is enabled, and L2 HLTs, then L2 virtual interrupts are valid wake events, but if and only if interrupts are unblocked for L2. Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 32f55e4 commit 322a569

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5049,14 +5049,19 @@ int vmx_nmi_allowed(struct kvm_vcpu *vcpu, bool for_injection)
50495049
return !vmx_nmi_blocked(vcpu);
50505050
}
50515051

5052+
bool __vmx_interrupt_blocked(struct kvm_vcpu *vcpu)
5053+
{
5054+
return !(vmx_get_rflags(vcpu) & X86_EFLAGS_IF) ||
5055+
(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) &
5056+
(GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS));
5057+
}
5058+
50525059
bool vmx_interrupt_blocked(struct kvm_vcpu *vcpu)
50535060
{
50545061
if (is_guest_mode(vcpu) && nested_exit_on_intr(vcpu))
50555062
return false;
50565063

5057-
return !(vmx_get_rflags(vcpu) & X86_EFLAGS_IF) ||
5058-
(vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) &
5059-
(GUEST_INTR_STATE_STI | GUEST_INTR_STATE_MOV_SS));
5064+
return __vmx_interrupt_blocked(vcpu);
50605065
}
50615066

50625067
int vmx_interrupt_allowed(struct kvm_vcpu *vcpu, bool for_injection)

arch/x86/kvm/vmx/vmx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ u64 construct_eptp(struct kvm_vcpu *vcpu, hpa_t root_hpa, int root_level);
406406
bool vmx_guest_inject_ac(struct kvm_vcpu *vcpu);
407407
void vmx_update_exception_bitmap(struct kvm_vcpu *vcpu);
408408
bool vmx_nmi_blocked(struct kvm_vcpu *vcpu);
409+
bool __vmx_interrupt_blocked(struct kvm_vcpu *vcpu);
409410
bool vmx_interrupt_blocked(struct kvm_vcpu *vcpu);
410411
bool vmx_get_nmi_mask(struct kvm_vcpu *vcpu);
411412
void vmx_set_nmi_mask(struct kvm_vcpu *vcpu, bool masked);

0 commit comments

Comments
 (0)