From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgiJu-000592-AG for qemu-devel@nongnu.org; Wed, 13 Nov 2013 16:50:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VgiJo-0006sM-B0 for qemu-devel@nongnu.org; Wed, 13 Nov 2013 16:49:54 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:43526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VgiJo-0006s2-2X for qemu-devel@nongnu.org; Wed, 13 Nov 2013 16:49:48 -0500 Date: Wed, 13 Nov 2013 16:49:45 -0500 (EST) From: Paolo Bonzini Message-ID: <477497661.24367224.1384379385806.JavaMail.root@redhat.com> In-Reply-To: <20131113203926.GA30546@amt.cnet> References: <20131024211249.723543071@amt.cnet> <20131107162459.6bdc39d7@nial.usersys.redhat.com> <20131107215304.GA10866@amt.cnet> <20131110204753.GA11389@amt.cnet> <20131112211637.GA11395@amt.cnet> <5283B32B.6020602@redhat.com> <20131113195832.GA29433@amt.cnet> <20131113203926.GA30546@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] i386: pc: align gpa<->hpa on 1GB boundary (v6) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: aarcange@redhat.com, gleb@redhat.com, "Michael S. Tsirkin" , qemu-devel@nongnu.org, Gerd Hoffmann , Igor Mammedov > > > + if (guest_info->gb_align && above_4g_mem_size > holesize) { > > > + /* Round the allocation up to 2 MB to use more hugepages. > > To align to 2MB boundary, the number of hugepages is the same. Right. > > > + * Remove the slack from the [yyy] piece so that pieceonesize > > > + * (and thus the start of piecetwo) remains aligned. > > > + */ > > > + align_offset = ROUND_UP(memsize, 1UL << 21) - memsize; > > > + piecetwosize = holesize - align_offset; > > > + } else { > > > + /* There's no "piece one", all memory above 4G starts > > Piece two. I'm calling "piece one" the part that is aligned at 0x100000000 in the RAM block, and "piece two" the part that starts at below_4g_mem_size. I'll change to "there's no [zzzzz] region". > > > + * at below_4g_mem_size in the RAM block. Also no need > > > + * to align anything. > > > + */ > > > + align_offset = 0; > > > + piecetwosize = above_4g_mem_size; > > > + } > > > + > > > ram = g_malloc(sizeof(*ram)); > > > - memory_region_init_ram(ram, NULL, "pc.ram", > > > - below_4g_mem_size + above_4g_mem_size); > > > + memory_region_init_ram(ram, NULL, "pc.ram", memsize + align_offset); > > > vmstate_register_ram_global(ram); > > > *ram_memory = ram; > > > + > > > ram_below_4g = g_malloc(sizeof(*ram_below_4g)); > > > memory_region_init_alias(ram_below_4g, NULL, "ram-below-4g", ram, > > > 0, below_4g_mem_size); > > > memory_region_add_subregion(system_memory, 0, ram_below_4g); > > > + > > > + pieceonesize = above_4g_mem_size - piecetwosize; > > > + if (pieceonesize) { > > > + ram_above_4g_pieceone = > > > g_malloc(sizeof(*ram_above_4g_pieceone)); > > > + memory_region_init_alias(ram_above_4g_pieceone, NULL, > > > + "ram-above-4g-pieceone", ram, > > > + 0x100000000ULL, pieceonesize); > > > + memory_region_add_subregion(system_memory, 0x100000000ULL, > > > + ram_above_4g_pieceone); > > > + } > > > > Can you change the name of aliases and subregions without breaking > > migration? Yes, memory regions are invisible except for RAM regions. > Test with Q35? Will do. Thanks for the review! Paolo