On Thu, Oct 24, 2013 at 10:55:54PM +0100, Peter Maydell wrote: > On 24 October 2013 22:12, Marcelo Tosatti <mtosa...@redhat.com> wrote: > > Align guest physical address and host physical address > > beyond guest 4GB on a 1GB boundary, in case hugetlbfs is used. > > > > Otherwise 1GB TLBs cannot be cached for the range. > > > + if (hpagesize == (1<<30)) { > > + unsigned long holesize = 0x100000000ULL - below_4g_mem_size; > > + > > + memory_region_init_alias(ram_above_4g, NULL, "ram-above-4g", > > ram, > > + 0x100000000ULL, > > + above_4g_mem_size - holesize); > > + memory_region_add_subregion(system_memory, 0x100000000ULL, > > + ram_above_4g); > > + > > + ram_above_4g_piecetwo = > > g_malloc(sizeof(*ram_above_4g_piecetwo)); > > + memory_region_init_alias(ram_above_4g_piecetwo, NULL, > > + "ram-above-4g-piecetwo", ram, > > + 0x100000000ULL - holesize, holesize); > > + memory_region_add_subregion(system_memory, > > + 0x100000000ULL + > > + above_4g_mem_size - holesize, > > + ram_above_4g_piecetwo); > > + } else { > > + 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, > > ram_above_4g); > > This looks pretty weird. Presence or absence of host OS features > shouldn't affect how we model the guest hardware and RAM.
This is not visible to the guest (read the comment in the patch). > Conversely, if hugetlbs have performance related requirements > then a patch which only touches the x86 pc model seems rather > limited. The requirement is that gpa and and hpas must be aligned on hugepage boundaries. The memory region API allows gpas to be registered at custom hpas (via the offset parameter). It is not entirely clear what is your request.