ia64/xen-unstable

changeset 10584:4260eb8c0874

kunmap_atomic() must zap the PTE to avoid dangling references
when attempting to free memory back to Xen. We can implement
something more efficient in future.

Also add debug print message if guest tries to free 'in use'
memory. We'll make it a real guest-visible error in future.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Wed Jun 28 18:17:41 2006 +0100 (2006-06-28)
parents 5fa6c1723e08
children d49e5cc672eb
files linux-2.6-xen-sparse/arch/i386/mm/highmem-xen.c xen/common/memory.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/mm/highmem-xen.c	Wed Jun 28 17:56:34 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/mm/highmem-xen.c	Wed Jun 28 18:17:41 2006 +0100
     1.3 @@ -79,6 +79,16 @@ void kunmap_atomic(void *kvaddr, enum km
     1.4  	 */
     1.5  	pte_clear(&init_mm, vaddr, kmap_pte-idx);
     1.6  	__flush_tlb_one(vaddr);
     1.7 +#elif defined(CONFIG_XEN)
     1.8 +	/*
     1.9 +	 * We must ensure there are no dangling pagetable references when
    1.10 +	 * returning memory to Xen (decrease_reservation).
    1.11 +	 * XXX TODO: We could make this faster by only zapping when
    1.12 +	 * kmap_flush_unused is called but that is trickier and more invasive.
    1.13 +	 */
    1.14 +	unsigned long vaddr = (unsigned long) kvaddr & PAGE_MASK;
    1.15 +	enum fixed_addresses idx = type + KM_TYPE_NR*smp_processor_id();
    1.16 +	pte_clear(&init_mm, vaddr, kmap_pte-idx);
    1.17  #endif
    1.18  
    1.19  	dec_preempt_count();
     2.1 --- a/xen/common/memory.c	Wed Jun 28 17:56:34 2006 +0100
     2.2 +++ b/xen/common/memory.c	Wed Jun 28 18:17:41 2006 +0100
     2.3 @@ -170,6 +170,15 @@ guest_remove_page(
     2.4      if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
     2.5          put_page(page);
     2.6  
     2.7 +    if ( unlikely((page->count_info & PGC_count_mask) != 1) )
     2.8 +    {
     2.9 +        /* We'll make this a guest-visible error in future, so take heed! */
    2.10 +        DPRINTK("Dom%d freeing in-use page %lx (pseudophys %lx):"
    2.11 +                " count=%x type=%lx\n",
    2.12 +                d->domain_id, mfn, get_gpfn_from_mfn(mfn),
    2.13 +                page->count_info, page->u.inuse.type_info);
    2.14 +    }
    2.15 +
    2.16      guest_physmap_remove_page(d, gmfn, mfn);
    2.17  
    2.18      put_page(page);