From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f1UVk-0005VH-Dv for qemu-devel@nongnu.org; Thu, 29 Mar 2018 06:10:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f1UVd-0005MF-Vu for qemu-devel@nongnu.org; Thu, 29 Mar 2018 06:10:24 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:39999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f1UVd-0005Ka-HQ for qemu-devel@nongnu.org; Thu, 29 Mar 2018 06:10:17 -0400 Received: by mail-wm0-x242.google.com with SMTP id x4so10461424wmh.5 for ; Thu, 29 Mar 2018 03:10:17 -0700 (PDT) References: <1519709965-29833-1-git-send-email-cota@braap.org> <1519709965-29833-9-git-send-email-cota@braap.org> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <1519709965-29833-9-git-send-email-cota@braap.org> Date: Thu, 29 Mar 2018 11:10:15 +0100 Message-ID: <87y3ib6vlk.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 08/16] translate-all: work page-by-page in tb_invalidate_phys_range_1 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Emilio G. Cota" Cc: qemu-devel@nongnu.org, Paolo Bonzini , Richard Henderson Emilio G. Cota writes: > So that we pass a same-page range to tb_invalidate_phys_page_range, > instead of always passing an end address that could be on a different > page. > > As discussed with Peter Maydell on the list [1], tb_invalidate_phys_page_= range > doesn't actually do much with 'end', which explains why we have never > hit a bug despite going against what the comment on top of > tb_invalidate_phys_page_range requires: > >> * Invalidate all TBs which intersect with the target physical address ra= nge >> * [start;end[. NOTE: start and end must refer to the *same* physical pag= e. > > The appended honours the comment, which avoids confusion. > > While at it, rework the loop into a for loop, which is less error prone > (e.g. "continue" won't result in an infinite loop). > > [1] https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg09165.html > > Signed-off-by: Emilio G. Cota Reviewed-by: Alex Benn=C3=A9e > --- > accel/tcg/translate-all.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c > index 816419a..a98e182 100644 > --- a/accel/tcg/translate-all.c > +++ b/accel/tcg/translate-all.c > @@ -1381,10 +1381,14 @@ TranslationBlock *tb_gen_code(CPUState *cpu, > */ > static void tb_invalidate_phys_range_1(tb_page_addr_t start, tb_page_add= r_t end) > { > - while (start < end) { > - tb_invalidate_phys_page_range(start, end, 0); > - start &=3D TARGET_PAGE_MASK; > - start +=3D TARGET_PAGE_SIZE; > + tb_page_addr_t next; > + > + for (next =3D (start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; > + start < end; > + start =3D next, next +=3D TARGET_PAGE_SIZE) { > + tb_page_addr_t bound =3D MIN(next, end); > + > + tb_invalidate_phys_page_range(start, bound, 0); > } > } -- Alex Benn=C3=A9e