On 07/19/2017 05:09 PM, Emilio G. Cota wrote:
+ /* We do not yet support multiple TCG contexts, so use one region for now */ + n_regions = 1; + + /* start on a page-aligned address */ + buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size); + g_assert(buf < tcg_init_ctx.code_gen_buffer + size); + + /* discard that initial portion */ + size -= buf - tcg_init_ctx.code_gen_buffer;
It seems pointless wasting most of a page after the prologue when n_regions == 1. We don't really need to start on a page boundary in that case.
+ /* make region_size a multiple of page_size */ + region_size = size / n_regions; + region_size = QEMU_ALIGN_DOWN(region_size, qemu_real_host_page_size);
This division can result in a number of pages at the end of the region being unused. Is it worthwhile freeing them? Or marking them mprotect_none along with the last guard page?
r~