From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vebrg-0008OI-0e for qemu-devel@nongnu.org; Thu, 07 Nov 2013 21:32:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vebra-0005ww-0R for qemu-devel@nongnu.org; Thu, 07 Nov 2013 21:32:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1601) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VebrZ-0005wn-Ow for qemu-devel@nongnu.org; Thu, 07 Nov 2013 21:31:57 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rA82Vti7017006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 7 Nov 2013 21:31:55 -0500 Date: Thu, 7 Nov 2013 19:53:04 -0200 From: Marcelo Tosatti Message-ID: <20131107215304.GA10866@amt.cnet> References: <20131024211158.064049176@amt.cnet> <20131024211249.723543071@amt.cnet> <20131106014930.GA20468@amt.cnet> <20131106015543.GA20766@amt.cnet> <20131106213119.GA15543@amt.cnet> <20131107162459.6bdc39d7@nial.usersys.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131107162459.6bdc39d7@nial.usersys.redhat.com> Subject: Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v4) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: aarcange@redhat.com, gleb@redhat.com, "Michael S. Tsirkin" , qemu-devel@nongnu.org, Gerd Hoffmann , pbonzini@redhat.com On Thu, Nov 07, 2013 at 04:24:59PM +0100, Igor Mammedov wrote: > On Wed, 6 Nov 2013 19:31:19 -0200 > Marcelo Tosatti wrote: > > > > > v2: condition enablement of new mapping to new machine types (Paolo) > > v3: fix changelog > > v4: rebase > > > > ----- > > > > > > Align guest physical address and host physical address > > beyond guest 4GB on a 1GB boundary. > > > > Otherwise 1GB TLBs cannot be cached for the range. > > > > Signed-off-by: Marcelo Tosatti > > > > > > diff --git a/hw/i386/pc.c b/hw/i386/pc.c > > index 12c436e..d29196d 100644 > > --- a/hw/i386/pc.c > > +++ b/hw/i386/pc.c > > @@ -1156,7 +1156,7 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, > > { > > int linux_boot, i; > > MemoryRegion *ram, *option_rom_mr; > > - MemoryRegion *ram_below_4g, *ram_above_4g; > > + MemoryRegion *ram_below_4g, *ram_above_4g, *ram_above_4g_piecetwo; > > FWCfgState *fw_cfg; > > > > linux_boot = (kernel_filename != NULL); > > @@ -1177,10 +1177,45 @@ FWCfgState *pc_memory_init(MemoryRegion *system_memory, > > e820_add_entry(0, below_4g_mem_size, E820_RAM); > > if (above_4g_mem_size > 0) { > > ram_above_4g = g_malloc(sizeof(*ram_above_4g)); > > - memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", ram, > > - below_4g_mem_size, above_4g_mem_size); > > - memory_region_add_subregion(system_memory, 0x100000000ULL, > > + /* > > + * > > + * If 1GB hugepages are used to back guest RAM, map guest address > > + * space in the range [ramsize,ramsize+holesize] to the ram block > > + * range [holestart, 4GB] > > + * > > + * 0 h 4G [ramsize,ramsize+holesize] > > + * > > + * guest-addr-space [ ] [ ][xxx] > > + * /----------/ > > + * contiguous-ram-block [ ][xxx][ ] > > + * > > + * So that memory beyond 4GB is aligned on a 1GB boundary, > > + * at the host physical address space. > > + * > > + */ > I did some corner cases testing and there is alias overlapping in case > -m 4096 -mem-path /var/lib/hugetlbfs/global/pagesize-1GB > > 0000000100000000-000000011fffffff (prio 0, RW): alias ram-above-4g-piecetwo @pc.ram 00000000e0000000-00000000ffffffff > 0000000100000000-0000000100000000 (prio 0, RW): alias ram-above-4g @pc.ram 0000000100000000-0000000100000000 > > perhaps zero sized ram-above-4g shouldn't be created at all? Right. > in addition ram-above-4g-piecetwo starts at half page offset 00000000e0000000 but guest sees it 4Gb offset, > wouldn't it cause the same issue patch tries to solve but only for ram-above-4g-piecetwo tail sync host/guest offsets > are not 1Gb aligned? Piece 1 is aligned. Piece 2 maps from tail of RAM (gpa) to start of hole (ramblock). > there is more misalignment with: > -m 4097 -mem-path /var/lib/hugetlbfs/global/pagesize-1GB > > 0000000100000000-00000001000fffff (prio 0, RW): alias ram-above-4g @pc.ram 0000000100000000-00000001000fffff Piece 1 is aligned. > 0000000100100000-00000001200fffff (prio 0, RW): alias ram-above-4g-piecetwo @pc.ram 00000000e0000000-00000000ffffffff Piece 2 is not. Should allocate one extra MB of RAM to align that. I'll resend, thanks. > where ram-above-4g-piecetwo is aligned with 1Gb+1Mb GPA offset, in addition to 500Mb offset of HPA. > which would cause the same issue as above prehaps?