On Sun, Apr 07, 2024 at 11:50:04AM +0800, Chao Gao <chao.gao@xxxxxxxxx> wrote: > >> > >+ union tdx_vcpu_state_details details; > >> > >+ struct vcpu_tdx *tdx = to_tdx(vcpu); > >> > >+ > >> > >+ if (ret || vcpu->arch.mp_state != KVM_MP_STATE_HALTED) > >> > >+ return true; > >> > > >> > Question: why mp_state matters here? > >> > >+ > >> > >+ if (tdx->interrupt_disabled_hlt) > >> > >+ return false; > >> > > >> > Shouldn't we move this into vt_interrupt_allowed()? VMX calls the function to > >> > check if interrupt is disabled. > > > >Chao, are you suggesting to implement tdx_interrupt_allowed() as > >"EXIT_REASON_HLT && a0" instead of "return true"? > >I don't think it makes sense because it's rare case and we can't avoid spurious > >wakeup for TDX case. > > Yes. KVM differeniates "interrupt allowed" from "has interrupt", e.g., > > static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu) > ... > > if (kvm_arch_interrupt_allowed(vcpu) && > (kvm_cpu_has_interrupt(vcpu) || > kvm_guest_apic_has_interrupt(vcpu))) > return true; > > > I think tdx_protected_apic_has_interrupt() mixes them together, which isn't > good. Your point is code clarity. Ok, we can code in that way. I don't expect any performance difference. -- Isaku Yamahata <isaku.yamahata@xxxxxxxxx>