From: Christoffer Dall <cdall@linaro.org>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Subject: Re: [PATCH v3 09/10] KVM: arm/arm64: use vcpu requests for irq injection
Date: Mon, 8 May 2017 10:56:13 +0200 [thread overview]
Message-ID: <20170508085613.GA21528@cbox> (raw)
In-Reply-To: <74607682-1da8-8299-900c-de5137e0b7f5@redhat.com>
On Mon, May 08, 2017 at 10:48:57AM +0200, Paolo Bonzini wrote:
>
>
> On 06/05/2017 20:49, Christoffer Dall wrote:
> > On Thu, May 04, 2017 at 01:47:41PM +0200, Paolo Bonzini wrote:
> >>
> >>
> >> On 03/05/2017 18:06, Andrew Jones wrote:
> >>> Don't use request-less VCPU kicks when injecting IRQs, as a VCPU
> >>> kick meant to trigger the interrupt injection could be sent while
> >>> the VCPU is outside guest mode, which means no IPI is sent, and
> >>> after it has called kvm_vgic_flush_hwstate(), meaning it won't see
> >>> the updated GIC state until its next exit some time later for some
> >>> other reason. The receiving VCPU only needs to check this request
> >>> in VCPU RUN to handle it. By checking it, if it's pending, a
> >>> memory barrier will be issued that ensures all state is visible.
> >>> We still create a vcpu_req_irq_pending() function (which is a nop),
> >>> though, in order to allow us to use the standard request checking
> >>> pattern.
> >>
> >> I wonder if you aren't just papering over this race:
> >>
> >> /*
> >> * If there are no virtual interrupts active or pending for this
> >> * VCPU, then there is no work to do and we can bail out without
> >> * taking any lock. There is a potential race with someone injecting
> >> * interrupts to the VCPU, but it is a benign race as the VCPU will
> >> * either observe the new interrupt before or after doing this check,
> >> * and introducing additional synchronization mechanism doesn't change
> >> * this.
> >> */
> >> if (list_empty(&vcpu->arch.vgic_cpu.ap_list_head))
> >> return;
> >>
> >> spin_lock(&vcpu->arch.vgic_cpu.ap_list_lock);
> >> vgic_flush_lr_state(vcpu);
> >> spin_unlock(&vcpu->arch.vgic_cpu.ap_list_lock);
> >>
> >> not being so "benign" after all. :) Maybe you can remove the if (list_empty()),
> >> and have kvm_arch_vcpu_ioctl_run do this instead:
> >
> > I don't see how removing this shortcut improves anything. You'd still
> > have the same window where you could loose an interrupt right after the
> > spin_unlock.
>
> It's not removing it that matters; it's just unnecessary if you add
> KVM_REQ_IRQ_PENDING and you key the call to kvm_vgic_flush_hwstate on it.
>
That doesn't work, because you can have active interrupts in flight long
after someone sent you that request which means you'll have interrupts
on the ap_list that you need to flush.
Thanks,
-Christoffer
next prev parent reply other threads:[~2017-05-08 8:56 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 16:06 [PATCH v3 00/10] KVM: arm/arm64: race fixes and vcpu requests Andrew Jones
2017-05-03 16:06 ` [PATCH v3 01/10] KVM: add kvm_request_pending Andrew Jones
2017-05-03 16:06 ` [PATCH v3 02/10] KVM: Add documentation for VCPU requests Andrew Jones
2017-05-04 11:27 ` Paolo Bonzini
2017-05-04 12:06 ` Andrew Jones
2017-05-04 12:51 ` Paolo Bonzini
2017-05-04 13:31 ` Andrew Jones
2017-05-03 16:06 ` [PATCH v3 03/10] KVM: arm/arm64: prepare to use vcpu requests Andrew Jones
2017-05-03 16:06 ` [PATCH v3 04/10] KVM: arm/arm64: use vcpu request in kvm_arm_halt_vcpu Andrew Jones
2017-05-06 18:08 ` Christoffer Dall
2017-05-09 17:02 ` Andrew Jones
2017-05-10 9:59 ` Christoffer Dall
2017-05-15 11:14 ` Christoffer Dall
2017-05-16 2:17 ` Andrew Jones
2017-05-16 10:06 ` Christoffer Dall
2017-05-03 16:06 ` [PATCH v3 05/10] KVM: arm/arm64: don't clear exit request from caller Andrew Jones
2017-05-06 18:12 ` Christoffer Dall
2017-05-09 17:17 ` Andrew Jones
2017-05-10 9:55 ` Christoffer Dall
2017-05-10 10:07 ` Andrew Jones
2017-05-10 12:19 ` Christoffer Dall
2017-05-03 16:06 ` [PATCH v3 06/10] KVM: arm/arm64: use vcpu requests for power_off Andrew Jones
2017-05-06 18:17 ` Christoffer Dall
2017-05-03 16:06 ` [PATCH v3 07/10] KVM: arm/arm64: optimize VCPU RUN Andrew Jones
2017-05-06 18:27 ` Christoffer Dall
2017-05-09 17:40 ` Andrew Jones
2017-05-09 20:13 ` Christoffer Dall
2017-05-10 6:58 ` Andrew Jones
2017-05-10 8:07 ` Christoffer Dall
2017-05-10 8:20 ` Andrew Jones
2017-05-10 9:06 ` Christoffer Dall
2017-05-03 16:06 ` [PATCH v3 08/10] KVM: arm/arm64: change exit request to sleep request Andrew Jones
2017-05-04 11:38 ` Paolo Bonzini
2017-05-04 12:07 ` Andrew Jones
2017-05-03 16:06 ` [PATCH v3 09/10] KVM: arm/arm64: use vcpu requests for irq injection Andrew Jones
2017-05-04 11:47 ` Paolo Bonzini
2017-05-06 18:49 ` Christoffer Dall
2017-05-08 8:48 ` Paolo Bonzini
2017-05-08 8:56 ` Christoffer Dall [this message]
2017-05-06 18:51 ` Christoffer Dall
2017-05-09 17:53 ` Andrew Jones
2017-05-03 16:06 ` [PATCH v3 10/10] KVM: arm/arm64: PMU: remove request-less vcpu kick Andrew Jones
2017-05-06 18:55 ` Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170508085613.GA21528@cbox \
--to=cdall@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=marc.zyngier@arm.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox