[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 08/21] hw/i386/kvm/xen_evtchn: Fix off-by-one in do_remove_pci_vector()
- To: David Woodhouse <dwmw2@xxxxxxxxxxxxx>, Paul Durrant <xadimgnik@xxxxxxxxx>, qemu-devel@xxxxxxxxxx
- From: Paul Durrant <xadimgnik@xxxxxxxxx>
- Date: Wed, 25 Nov 2026 13:31:17 +0000
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID:From"
- Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, kvm@xxxxxxxxxxxxxxx, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, "Edgar E . Iglesias" <edgar.iglesias@xxxxxxxxx>, "Michael S . Tsirkin" <mst@xxxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Marcelo Tosatti <mtosatti@xxxxxxxxxx>, Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>, Jason Wang <jasowangio@xxxxxxxxx>, Hui Peng <benquike@xxxxxxxxx>, Mark Syms <mark.syms@xxxxxxxxxx>, Feifan Qian <bea1e@xxxxxxxxx>
- Delivery-date: Wed, 25 Nov 2026 13:31:34 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 25/11/2026 05:03, David Woodhouse wrote:
On Wed, 2026-11-25 at 11:16 +0000, Paul Durrant wrote:
I guess I'm missing a subtlety here, but the test only fires if pirq is
a multiple of 64... so why is advancing to the next word by adding 64
not correct?
You're missing the same subtlety that I missed when I wrote it in the
first place: the loop *itself* does pirq++ every time, so when we do
'pirq += 64; continue;' we end up adding *65*.
for (pirq = 0; pirq < s->nr_pirqs; pirq++) {
/*
* We could be cleverer here, but it isn't really a fast path, and
* this trivial optimisation is enough to let us skip the big gap
* in the middle a bit quicker (in terms of both loop iterations,
* and cache lines).
*/
if (!(pirq & 63) && !(pirq_inuse_word(s, pirq))) {
pirq += 63;
continue;
}
Gah! Recoding as a while loop where the increment is either 1 or 64
would make this much less fragile.
|