> -----Original Message----- > From: Maxim Levitsky <mlevitsk@xxxxxxxxxx> > Sent: Monday, February 6, 2023 5:10 PM > To: Li,Rongqing <lirongqing@xxxxxxxxx>; kvm@xxxxxxxxxxxxxxx > Subject: Re: [RFC][PATCH] kvm: i8254: Deactivate APICv when using in-kernel PIT > re-injection mode. > > On Mon, 2023-02-06 at 16:56 +0800, lirongqing@xxxxxxxxx wrote: > > From: Li RongQing <lirongqing@xxxxxxxxx> > > > > Intel VMX APICv accelerates EOI write and does not trap. This causes > > in-kernel PIT re-injection mode to fail since it relies on irq-ack > > notifier mechanism. So, APICv is activated only when in-kernel PIT is > > in discard mode e.g. w/ qemu option: > > > > -global kvm-pit.lost_tick_policy=discard > > > > Signed-off-by: Li RongQing <lirongqing@xxxxxxxxx> > > --- > > arch/x86/kvm/vmx/vmx.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index > > fe5615f..16952a9 100644 > > --- a/arch/x86/kvm/vmx/vmx.c > > +++ b/arch/x86/kvm/vmx/vmx.c > > @@ -8051,7 +8051,8 @@ static bool vmx_check_apicv_inhibit_reasons(enum > kvm_apicv_inhibit reason) > > BIT(APICV_INHIBIT_REASON_HYPERV) | > > BIT(APICV_INHIBIT_REASON_BLOCKIRQ) | > > BIT(APICV_INHIBIT_REASON_APIC_ID_MODIFIED) | > > - BIT(APICV_INHIBIT_REASON_APIC_BASE_MODIFIED); > > + BIT(APICV_INHIBIT_REASON_APIC_BASE_MODIFIED) | > > + BIT(APICV_INHIBIT_REASON_PIT_REINJ); > > > > return supported & BIT(reason); > > } > > AFAIK, APICv has EOI exiting bitmap, for this exact purpose, it allows to trap only > some vectors when EOI is performed. > > KVM uses it so APICv shouldn't need this inhibit but it is possible that something > got broken. > > Take a look at vcpu_load_eoi_exitmap. > Thanks, I will look at it -Li > Best regards, > Maxim Levitsky