[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <939b9cb1-2b1d-05e8-90dd-827f8325ce80@redhat.com>
Date: Tue, 1 Mar 2022 18:10:16 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sasha Levin <sashal@...nel.org>, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Cc: Maxim Levitsky <mlevitsk@...hat.com>, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, dave.hansen@...ux.intel.com,
x86@...nel.org, kvm@...r.kernel.org
Subject: Re: [PATCH MANUALSEL 5.15 1/2] KVM: x86: lapic: don't touch
irr_pending in kvm_apic_update_apicv when inhibiting it
On 2/22/22 15:05, Sasha Levin wrote:
> From: Maxim Levitsky <mlevitsk@...hat.com>
>
> [ Upstream commit 755c2bf878607dbddb1423df9abf16b82205896f ]
>
> kvm_apic_update_apicv is called when AVIC is still active, thus IRR bits
> can be set by the CPU after it is called, and don't cause the irr_pending
> to be set to true.
>
> Also logic in avic_kick_target_vcpu doesn't expect a race with this
> function so to make it simple, just keep irr_pending set to true and
> let the next interrupt injection to the guest clear it.
>
> Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
> Message-Id: <20220207155447.840194-9-mlevitsk@...hat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@...hat.com>
> Signed-off-by: Sasha Levin <sashal@...nel.org>
> ---
> arch/x86/kvm/lapic.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
> index 91c2dc9f198df..5f935e7a09566 100644
> --- a/arch/x86/kvm/lapic.c
> +++ b/arch/x86/kvm/lapic.c
> @@ -2306,7 +2306,12 @@ void kvm_apic_update_apicv(struct kvm_vcpu *vcpu)
> apic->irr_pending = true;
> apic->isr_count = 1;
> } else {
> - apic->irr_pending = (apic_search_irr(apic) != -1);
> + /*
> + * Don't clear irr_pending, searching the IRR can race with
> + * updates from the CPU as APICv is still active from hardware's
> + * perspective. The flag will be cleared as appropriate when
> + * KVM injects the interrupt.
> + */
> apic->isr_count = count_vectors(apic->regs + APIC_ISR);
> }
> }
Acked-by: Paolo Bonzini <pbonzini@...hat.com>
Paolo
Powered by blists - more mailing lists