On Wed, 2020-02-05 at 14:12 +0000, David Woodhouse wrote: > I think we have a viable path to fixing that, by folding PGC_broken in to > the state bits so that we can disambiguate. Will experiment. Here, it looks something like this. First we fold PGC_broken into the state bits giving us 8 possible states of which only 6 are currently in use. Then in the second patch we can move PGC_state_inuse from zero (the default contents of the frame table at startup), and make a new state PGC_state_uninitialised with the value zero. We can make free_xenheap_pages() and free_domheap_pages() call init_heap_pages() instead of free_heap_pages() if they see a page range which is still in PGC_state_uninitialised. We need to fix up a couple of asserts not only to cope with PGC_state_inuse not being zero (as Julien has already looked at) but also to take PGC_state_uninitialised pages. In assign_pages() that's because we map the multiboot module containing the initramfs to dom0. That might actually cross node boundaries, contain MFN#0, etc. — so if/when that gets released by dom0 we'd want those pages to be passed to init_heap_pages() just the same as boot- allocated memory. In share_xen_page_with_guest() it happens because we share all non-RAM page frames with dom0. (2 patches follow...)