Message ID | 1675673814-23372-1-git-send-email-lirongqing@baidu.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode. | expand |
On Mon, 2023-02-06 at 16:56 +0800, lirongqing@baidu.com wrote: > From: Li RongQing <lirongqing@baidu.com> > > 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@baidu.com> > --- > 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. Best regards, Maxim Levitsky
> -----Original Message----- > From: Maxim Levitsky <mlevitsk@redhat.com> > Sent: Monday, February 6, 2023 5:10 PM > To: Li,Rongqing <lirongqing@baidu.com>; kvm@vger.kernel.org > 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@baidu.com wrote: > > From: Li RongQing <lirongqing@baidu.com> > > > > 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@baidu.com> > > --- > > 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
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); }