On 17/03/2017 11:17, Borislav Petkov wrote: > >> I also don't really like the patch as is (plus it fails modpost), but >> IMO reusing __change_page_attr and __split_large_page is the right thing >> to do. > > Right, so teaching pageattr.c about memblock could theoretically come > around and bite us later when a page allocated with memblock gets freed > with free_page(). Theoretically or practically? > And looking at this more, we have all this kernel pagetable preparation > code down the init_mem_mapping() call and the pagetable setup in > arch/x86/mm/init_{32,64}.c It only looks at the E820 map, doesn't it? Why does it have to do anything with percpu memory areas? Paolo > And that code even does some basic page splitting. Oh and it uses > alloc_low_pages() which knows whether to do memblock reservation or the > common __get_free_pages() when slabs are up. > > So what would be much cleaner, IMHO, is if one would reuse that code to > change init_mm.pgd mappings early without copying pageattr.c. > > init_mem_mapping() gets called before kvm_guest_init() in setup_arch() > so the guest would simply fixup its pagetable right there.