From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35162) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1al0E3-0000J6-Iu for qemu-devel@nongnu.org; Tue, 29 Mar 2016 16:27:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1al0E0-0001lZ-Tj for qemu-devel@nongnu.org; Tue, 29 Mar 2016 16:26:55 -0400 Received: from mail-qg0-x243.google.com ([2607:f8b0:400d:c04::243]:35705) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1al0E0-0001lU-Pc for qemu-devel@nongnu.org; Tue, 29 Mar 2016 16:26:52 -0400 Received: by mail-qg0-x243.google.com with SMTP id b32so1761702qgf.2 for ; Tue, 29 Mar 2016 13:26:52 -0700 (PDT) Sender: Richard Henderson References: <1459280892-8789-1-git-send-email-sergey.fedorov@linaro.org> <1459280892-8789-3-git-send-email-sergey.fedorov@linaro.org> From: Richard Henderson Message-ID: <56FAE508.1050904@twiddle.net> Date: Tue, 29 Mar 2016 13:26:48 -0700 MIME-Version: 1.0 In-Reply-To: <1459280892-8789-3-git-send-email-sergey.fedorov@linaro.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 2/3] tcg: reorganize tb_find_physical loop List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Sergey Fedorov , qemu-devel@nongnu.org Cc: Sergey Fedorov , Peter Crosthwaite , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Paolo Bonzini On 03/29/2016 12:48 PM, Sergey Fedorov wrote: > + while (tb) { > if (tb->pc == pc && > tb->page_addr[0] == phys_page1 && > tb->cs_base == cs_base && > tb->flags == flags) { > - /* check next page if needed */ > - if (tb->page_addr[1] != -1) { > - tb_page_addr_t phys_page2; > > - virt_page2 = (pc & TARGET_PAGE_MASK) + > - TARGET_PAGE_SIZE; > - phys_page2 = get_page_addr_code(env, virt_page2); > + if (tb->page_addr[1] == -1) { > + /* done, we have a match */ > + break; > + } else { > + /* check next page if needed */ > + target_ulong virt_page2 = (pc & TARGET_PAGE_MASK) + > + TARGET_PAGE_SIZE; > + tb_page_addr_t phys_page2 = get_page_addr_code(env, virt_page2); > + > if (tb->page_addr[1] == phys_page2) { > break; > } > - } else { > - break; > } > } FYI, There's an issue here before and after this patch: calling get_page_addr_code will cause an exception to be thrown if the page isn't mapped. Except this is a search routine looking for matching TB's. We shouldn't be raising an exception within this loop. We need a variant of get_page_addr_code that reloads the TLB, if possible, but without generating a fault. Something that I don't think we can actually do with the current tlb_fill target hooks. So not something for this patch, but something to put on someone's radar, hopefully... r~