All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode.
@ 2023-02-06  8:56 lirongqing
  2023-02-06  9:10 ` Maxim Levitsky
  0 siblings, 1 reply; 3+ messages in thread
From: lirongqing @ 2023-02-06  8:56 UTC (permalink / raw)
  To: kvm

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);
 }
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC][PATCH] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode.
  2023-02-06  8:56 [RFC][PATCH] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode lirongqing
@ 2023-02-06  9:10 ` Maxim Levitsky
  2023-02-07  3:17   ` Li,Rongqing
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Levitsky @ 2023-02-06  9:10 UTC (permalink / raw)
  To: lirongqing, kvm

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [RFC][PATCH] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode.
  2023-02-06  9:10 ` Maxim Levitsky
@ 2023-02-07  3:17   ` Li,Rongqing
  0 siblings, 0 replies; 3+ messages in thread
From: Li,Rongqing @ 2023-02-07  3:17 UTC (permalink / raw)
  To: Maxim Levitsky, kvm



> -----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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-07  3:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06  8:56 [RFC][PATCH] kvm: i8254: Deactivate APICv when using in-kernel PIT re-injection mode lirongqing
2023-02-06  9:10 ` Maxim Levitsky
2023-02-07  3:17   ` Li,Rongqing

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.