From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:37054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZRx-0007L2-2B for qemu-devel@nongnu.org; Thu, 23 May 2013 13:37:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfZRv-0003gF-Q6 for qemu-devel@nongnu.org; Thu, 23 May 2013 13:37:13 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:37819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfZRv-0003g9-JT for qemu-devel@nongnu.org; Thu, 23 May 2013 13:37:11 -0400 Received: by mail-lb0-f177.google.com with SMTP id o10so3717548lbi.36 for ; Thu, 23 May 2013 10:37:10 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1369133851-1894-6-git-send-email-pbonzini@redhat.com> References: <1369133851-1894-1-git-send-email-pbonzini@redhat.com> <1369133851-1894-6-git-send-email-pbonzini@redhat.com> From: Peter Maydell Date: Thu, 23 May 2013 18:36:50 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] [PATCH 05/30] memory: assert that PhysPageEntry's ptr does not overflow List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: jan.kiszka@gmail.com, qemu-devel@nongnu.org, David Gibson On 21 May 2013 11:57, Paolo Bonzini wrote: > While sized to 15 bits in PhysPageEntry, the ptr field is ORed into the > iotlb entries together with a page-aligned pointer. The ptr field must > not overflow into this page-aligned value, assert that it is smaller than > the page size. > > Signed-off-by: Paolo Bonzini > --- > exec.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/exec.c b/exec.c > index 1355661..380245f 100644 > --- a/exec.c > +++ b/exec.c > @@ -713,6 +713,8 @@ static void destroy_all_mappings(AddressSpaceDispatch *d) > > static uint16_t phys_section_add(MemoryRegionSection *section) > { You might consider having the rationale for the assert in a comment here as well as in the commit log. > + assert(phys_sections_nb < TARGET_PAGE_SIZE); > + > if (phys_sections_nb == phys_sections_nb_alloc) { > phys_sections_nb_alloc = MAX(phys_sections_nb_alloc * 2, 16); > phys_sections = g_renew(MemoryRegionSection, phys_sections, Reviewed-by: Peter Maydell -- PMM