From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXYmn-0007XJ-I5 for qemu-devel@nongnu.org; Mon, 05 Dec 2011 08:40:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RXYmh-0000tE-GR for qemu-devel@nongnu.org; Mon, 05 Dec 2011 08:40:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39620) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RXYmh-0000sz-7m for qemu-devel@nongnu.org; Mon, 05 Dec 2011 08:40:43 -0500 Message-ID: <4EDCC9D3.7040800@redhat.com> Date: Mon, 05 Dec 2011 15:40:35 +0200 From: Avi Kivity MIME-Version: 1.0 References: <1323082897-15249-1-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1323082897-15249-1-git-send-email-peter.maydell@linaro.org> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] exec.c: Allow memory region start_addr and region_offset to vary in low bits List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Paul Brook , qemu-devel@nongnu.org, patches@linaro.org On 12/05/2011 01:01 PM, Peter Maydell wrote: > Fix a long-standing deficiency of cpu_register_physical_memory_log() > where the start address and region offset had to have the same low > bits (otherwise the IO functions would be passed an incorrect address > offset). This was most likely to bite when registering memory regions > which started at a non-page-boundary. > > Signed-off-by: Peter Maydell > --- > This is such a small change to correct this issue that I'm kind of > suspicious of it :-) Your instincts are correct, unfortunately. > @@ -2677,7 +2674,11 @@ void cpu_register_physical_memory_log(target_phys_addr_t start_addr, > if (phys_offset == IO_MEM_UNASSIGNED) { > region_offset = start_addr; > } > - region_offset &= TARGET_PAGE_MASK; > + /* Adjust the region offset to account for the start_addr possibly > + * not being page aligned, so we end up passing the IO functions > + * the true offset from the start of the region. > + */ > + region_offset -= (start_addr & ~TARGET_PAGE_MASK); > size = (size + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK; > end_addr = start_addr + (target_phys_addr_t)size; > region_offset is added to iotlb in tlb_set_page(), smashing the low bits with your change. It's safe in subpage, since that doesn't happen there. -- error compiling committee.c: too many arguments to function