@@ -857,6 +857,8 @@ struct kvm_vcpu_arch {
bool preempt_count_enabled;
struct gfn_to_hva_cache preempt_count_cache;
} pv_pc;
+ /* guest irq disabled state, valid iff the vCPU is not loaded */
+ bool last_guest_irq_disabled;
/*
* Indicates the guest is trying to write a gfn that contains one or
@@ -4584,6 +4584,7 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
static_call(kvm_x86_vcpu_load)(vcpu, cpu);
+ vcpu->arch.last_guest_irq_disabled = false;
/* Save host pkru register if supported */
vcpu->arch.host_pkru = read_pkru();
@@ -4676,6 +4677,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
static_call(kvm_x86_vcpu_put)(vcpu);
vcpu->arch.last_host_tsc = rdtsc();
+ vcpu->arch.last_guest_irq_disabled = !static_call(kvm_x86_get_if_flag)(vcpu);
}
static int kvm_vcpu_ioctl_get_lapic(struct kvm_vcpu *vcpu,
@@ -11227,6 +11229,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
vcpu->arch.pending_external_vector = -1;
vcpu->arch.preempted_in_kernel = false;
vcpu->arch.pv_pc.preempt_count_enabled = false;
+ vcpu->arch.last_guest_irq_disabled = false;
#if IS_ENABLED(CONFIG_HYPERV)
vcpu->arch.hv_root_tdp = INVALID_PAGE;