Re: [PATCH 4/4] KVM: x86: Skip KVM_GUESTDBG_BLOCKIRQ APICv update if APICv is disabled

From: Maxim Levitsky
Date: Mon Apr 18 2022 - 09:36:44 EST


On Sat, 2022-04-16 at 03:42 +0000, Sean Christopherson wrote:
> Skip the APICv inhibit update for KVM_GUESTDBG_BLOCKIRQ if APICv is
> disabled at the module level to avoid having to acquire the mutex and
> potentially process all vCPUs. The DISABLE inhibit will (barring bugs)
> never be lifted, so piling on more inhibits is unnecessary.
>
> Fixes: cae72dcc3b21 ("KVM: x86: inhibit APICv when KVM_GUESTDBG_BLOCKIRQ active")
> Cc: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
> arch/x86/kvm/x86.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 09a270cc1c8f..16c5fa7d165d 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -11048,6 +11048,9 @@ static void kvm_arch_vcpu_guestdbg_update_apicv_inhibit(struct kvm *kvm)
> struct kvm_vcpu *vcpu;
> unsigned long i;
>
> + if (!enable_apicv)
> + return;
> +
> down_write(&kvm->arch.apicv_update_lock);
>
> kvm_for_each_vcpu(i, vcpu, kvm) {

Makes sense as a precation.

Reviewed-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>


Best regards,
Maxim Levitsky