From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54693) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTbjW-0000fy-C5 for qemu-devel@nongnu.org; Fri, 28 Mar 2014 14:42:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTbjN-0002gE-9o for qemu-devel@nongnu.org; Fri, 28 Mar 2014 14:42:26 -0400 Received: from mail-qg0-x230.google.com ([2607:f8b0:400d:c04::230]:45767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTbjN-0002g9-5u for qemu-devel@nongnu.org; Fri, 28 Mar 2014 14:42:17 -0400 Received: by mail-qg0-f48.google.com with SMTP id j107so4829560qga.35 for ; Fri, 28 Mar 2014 11:42:16 -0700 (PDT) Sender: Richard Henderson Message-ID: <5335C281.6000706@twiddle.net> Date: Fri, 28 Mar 2014 11:42:09 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1396023024-2262-1-git-send-email-peter.maydell@linaro.org> <1396023024-2262-13-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1396023024-2262-13-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 12/37] target-arm: A64: Implement DC ZVA List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Peter Crosthwaite , patches@linaro.org, Michael Matz , Alexander Graf , Will Newton , Dirk Mueller , Laurent Desnogues , =?ISO-8859-1?Q?Alex_Benn=E9e?= , kvmarm@lists.cs.columbia.edu, Christoffer Dall On 03/28/2014 09:09 AM, Peter Maydell wrote: > + for (i = 0; i < maxidx; i++) { > + hostaddr[i] = tlb_vaddr_to_host(env, > + vaddr + TARGET_PAGE_SIZE * i, > + 1, cpu_mmu_index(env)); > + if (!hostaddr[i]) { > + break; > + } > + } > + if (i == maxidx) { > + /* If it's all in the TLB it's fair game for just writing to; > + * we know we don't need to update dirty status, etc. > + */ > + for (i = 0; i < maxidx - 1; i++) { > + memset(hostaddr[i], 0, TARGET_PAGE_SIZE); > + } > + memset(hostaddr[i], 0, blocklen - (i * TARGET_PAGE_SIZE)); > + return; > + } Doesn't this fail if blocklen < TARGET_PAGE_SIZE? Since blocklen must be a power of 4, it's either less than TARGET_PAGE_SIZE or a multiple of TARGET_PAGE_SIZE, so that last memset looks suspect. I think all this would be easier to follow as two cases: if (blocklen <= TARGET_PAGE_SIZE) { // One look up and no hostaddr array } else { // Multiple pages; much of what you have now, only no partial pages } r~