From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFc4J-0004lB-KX for qemu-devel@nongnu.org; Wed, 22 Jun 2016 02:55:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFc4H-0006cB-Fx for qemu-devel@nongnu.org; Wed, 22 Jun 2016 02:55:22 -0400 MIME-Version: 1.0 In-Reply-To: References: <1466528974-12183-1-git-send-email-peter.maydell@linaro.org> <1466528974-12183-3-git-send-email-peter.maydell@linaro.org> From: Vijay Kilari Date: Wed, 22 Jun 2016 12:25:19 +0530 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [Qemu-devel] Fw: [Qemu-arm] [PATCH v2 2/6] exec.c: Remove static allocation of sub_section of sub_page List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "Kumar, Vijaya" , patches@linaro.org, QEMU Developers , qemu-arm , Paolo Bonzini > ________________________________ > From: Qemu-arm on > behalf of Peter Maydell > Sent: Tuesday, June 21, 2016 10:39 PM > To: qemu-arm@nongnu.org; qemu-devel@nongnu.org > Cc: Paolo Bonzini; Kumar, Vijaya; patches@linaro.org > Subject: [Qemu-arm] [PATCH v2 2/6] exec.c: Remove static allocation of > sub_section of sub_page > > From: Vijaya Kumar K > > Allocate sub_section dynamically. Remove dependency > on TARGET_PAGE_SIZE to make run-time page size detection > for arm platforms. > > Signed-off-by: Vijaya Kumar K > Message-id: 1465808915-4887-3-git-send-email-vijayak@caviumnetworks.com > [PMM: use flexible array member rather than separate malloc > so we don't need an extra pointer deref when using it] > Signed-off-by: Peter Maydell > --- > exec.c | 5 ++--- > 1 file changed, 2 insertions(+), 3 deletions(-) > > diff --git a/exec.c b/exec.c > index 0122ef7..8eaeb0c 100644 > --- a/exec.c > +++ b/exec.c > @@ -153,7 +153,7 @@ typedef struct subpage_t { > MemoryRegion iomem; > AddressSpace *as; > hwaddr base; > - uint16_t sub_section[TARGET_PAGE_SIZE]; > + uint16_t sub_section[]; NIT: Comment that this variable should be last member of this struct will be helpful. > } subpage_t; > > #define PHYS_SECTION_UNASSIGNED 0 > @@ -2270,8 +2270,7 @@ static subpage_t *subpage_init(AddressSpace *as, > hwaddr base) > { > subpage_t *mmio; > > - mmio = g_malloc0(sizeof(subpage_t)); > - > + mmio = g_malloc0(sizeof(subpage_t) + TARGET_PAGE_SIZE * > sizeof(uint16_t)); NIT: sizeof(mmio->sub_section[0]) looks better than sizeof(uint16_t) > mmio->as = as; > mmio->base = base; > memory_region_init_io(&mmio->iomem, NULL, &subpage_ops, mmio, > -- > 1.9.1 > >