From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfrrP-000320-TZ for qemu-devel@nongnu.org; Fri, 24 May 2013 09:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfrrO-0001pB-H7 for qemu-devel@nongnu.org; Fri, 24 May 2013 09:16:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25365) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfrZs-0003Z2-H8 for qemu-devel@nongnu.org; Fri, 24 May 2013 08:58:36 -0400 Message-ID: <519F63EE.8080208@redhat.com> Date: Fri, 24 May 2013 14:58:22 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> <1369133851-1894-16-git-send-email-pbonzini@redhat.com> <519F1E7E.7050700@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 15/30] memory: add address_space_valid List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: David Gibson , qemu-devel@nongnu.org, jan.kiszka@gmail.com Il 24/05/2013 12:52, Peter Maydell ha scritto: > On 24 May 2013 09:02, Paolo Bonzini wrote: >> Il 23/05/2013 20:04, Peter Maydell ha scritto: >>> Shouldn't we be calling the MemoryRegionOps >>> accepts() callback here? What about access alignment constraints >>> and access size restrictions? >> >> Yes, we should. >> >>> What if the validity of the range >>> changes between the time you asked and when you actually do the >>> access? >> >> If that's a concern, you shouldn't use this API, you should just do the >> access and rely on the return value of address_space_rw & friends. > > So when *is* it a good idea to use this API? In real > hardware you don't usually get a "tell me whether this > access would succeed if I did it" bus operation -- you > just do the operation and the memory transaction either > succeeds or it doesn't. Are we modelling something that > really exists in hardware on spapr here? Well, sPAPR is not hardware. :) It is a paravirtualized interface. Anyhow, I can eliminate all the references to unassigned and basically do this: bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write) { MemoryRegionSection *section; hwaddr l, xlat; while (len > 0) { l = len; section = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(section->mr, is_write)) { l = memory_access_size(l, addr); if (!memory_region_access_valid(section->mr, addr1, l) { return false; } } len -= l; addr += l; } return true; } It requires some more changes however. I'll drop this patch. If it's okay for you, I'll send a pull request up to "memory: clean up phys_page_find" and go on with the next series. Paolo