This can really happen -- all our PV Linux kernels have a race
between vmalloc_sync_all() and pgdir pinning/unpinning. The former is
protected by pgd_lock while the latter by mm->page_table_lock. Hence
they can happen concurrently, and vmalloc_sync_all() can attempt to
set_pmd() on a page directory which is in the process of being
pinned. This can confuse the hypervisor which may see a type change,
and hence fail do_mmu_update(). Until this patch. :-)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
case MMU_NORMAL_PT_UPDATE:
case MMU_PT_UPDATE_PRESERVE_AD:
{
+ unsigned int retries = 0;
p2m_type_t p2mt;
rc = xsm_mmu_normal_update(d, pg_owner, req.val);
(unsigned long)(req.ptr & ~PAGE_MASK));
page = mfn_to_page(mfn);
+ retry:
if ( page_lock(page) )
{
switch ( page->u.inuse.type_info & PGT_type_mask )
v, va, req.val, _mfn(mfn));
put_page_type(page);
}
+ else if ( retries++ < 5 )
+ {
+ /* Page type can be in flux, so we retry a few times. */
+ goto retry;
+ }
unmap_domain_page_with_cache(va, &mapcache);
put_page(page);