Index: kernel/generic/src/mm/as.c
===================================================================
--- kernel/generic/src/mm/as.c	(revision 1b20da07baaa3e3c424f62c927274e676e4295cd)
+++ kernel/generic/src/mm/as.c	(revision 34e1206ec4dc79f0592077e3ee270fba91d1eb9d)
@@ -114,8 +114,8 @@
 {
 	as_t *as = (as_t *) obj;
-	
+
 	link_initialize(&as->inactive_as_with_asid_link);
 	mutex_initialize(&as->lock, MUTEX_PASSIVE);
-	
+
 	return as_constructor_arch(as, flags);
 }
@@ -130,12 +130,12 @@
 {
 	as_arch_init();
-	
+
 	as_cache = slab_cache_create("as_t", sizeof(as_t), 0,
 	    as_constructor, as_destructor, SLAB_CACHE_MAGDEFERRED);
-	
+
 	AS_KERNEL = as_create(FLAG_AS_KERNEL);
 	if (!AS_KERNEL)
 		panic("Cannot create kernel address space.");
-	
+
 	/*
 	 * Make sure the kernel address space
@@ -155,15 +155,15 @@
 	as_t *as = (as_t *) slab_alloc(as_cache, 0);
 	(void) as_create_arch(as, 0);
-	
+
 	btree_create(&as->as_area_btree);
-	
+
 	if (flags & FLAG_AS_KERNEL)
 		as->asid = ASID_KERNEL;
 	else
 		as->asid = ASID_INVALID;
-	
+
 	atomic_set(&as->refcount, 0);
 	as->cpu_refcount = 0;
-	
+
 #ifdef AS_PAGE_TABLE
 	as->genarch.page_table = page_table_create(flags);
@@ -171,5 +171,5 @@
 	page_table_create(flags);
 #endif
-	
+
 	return as;
 }
@@ -188,13 +188,13 @@
 {
 	DEADLOCK_PROBE_INIT(p_asidlock);
-	
+
 	assert(as != AS);
 	assert(atomic_get(&as->refcount) == 0);
-	
+
 	/*
 	 * Since there is no reference to this address space, it is safe not to
 	 * lock its mutex.
 	 */
-	
+
 	/*
 	 * We need to avoid deadlock between TLB shootdown and asidlock.
@@ -206,5 +206,5 @@
 	preemption_disable();
 	ipl_t ipl = interrupts_read();
-	
+
 retry:
 	interrupts_disable();
@@ -214,19 +214,19 @@
 		goto retry;
 	}
-	
+
 	/* Interrupts disabled, enable preemption */
 	preemption_enable();
-	
+
 	if ((as->asid != ASID_INVALID) && (as != AS_KERNEL)) {
 		if (as->cpu_refcount == 0)
 			list_remove(&as->inactive_as_with_asid_link);
-		
+
 		asid_put(as->asid);
 	}
-	
+
 	spinlock_unlock(&asidlock);
 	interrupts_restore(ipl);
-	
-	
+
+
 	/*
 	 * Destroy address space areas of the address space.
@@ -237,15 +237,15 @@
 	while (cond) {
 		assert(!list_empty(&as->as_area_btree.leaf_list));
-		
+
 		btree_node_t *node =
 		    list_get_instance(list_first(&as->as_area_btree.leaf_list),
 		    btree_node_t, leaf_link);
-		
+
 		if ((cond = node->keys))
 			as_area_destroy(as, node->key[0]);
 	}
-	
+
 	btree_destroy(&as->as_area_btree);
-	
+
 #ifdef AS_PAGE_TABLE
 	page_table_destroy(as->genarch.page_table);
@@ -253,5 +253,5 @@
 	page_table_destroy(NULL);
 #endif
-	
+
 	slab_free(as_cache, as);
 }
@@ -307,5 +307,5 @@
 	if (overflows_into_positive(addr, P2SZ(count)))
 		return false;
-	
+
 	/*
 	 * We don't want any area to have conflicts with NULL page.
@@ -328,5 +328,5 @@
 			return false;
 	}
-	
+
 	/* First, check the two border cases. */
 	btree_node_t *node =
@@ -334,5 +334,5 @@
 	if (node) {
 		area = (as_area_t *) node->value[node->keys - 1];
-		
+
 		if (area != avoid) {
 			mutex_lock(&area->lock);
@@ -346,5 +346,5 @@
 			int const gp = (guarded ||
 			    (area->flags & AS_AREA_GUARD)) ? 1 : 0;
-			
+
 			/*
 			 * The area comes from the left neighbour node, which
@@ -358,13 +358,13 @@
 				return false;
 			}
-			
+
 			mutex_unlock(&area->lock);
 		}
 	}
-	
+
 	node = btree_leaf_node_right_neighbour(&as->as_area_btree, leaf);
 	if (node) {
 		area = (as_area_t *) node->value[0];
-		
+
 		if (area != avoid) {
 			int gp;
@@ -382,5 +382,5 @@
 				gp--;
 			}
-			
+
 			if (overlaps(addr, P2SZ(count + gp), area->base,
 			    P2SZ(area->pages))) {
@@ -388,9 +388,9 @@
 				return false;
 			}
-			
+
 			mutex_unlock(&area->lock);
 		}
 	}
-	
+
 	/* Second, check the leaf node. */
 	btree_key_t i;
@@ -399,8 +399,8 @@
 		int agp;
 		int gp;
-		
+
 		if (area == avoid)
 			continue;
-		
+
 		mutex_lock(&area->lock);
 
@@ -421,8 +421,8 @@
 			return false;
 		}
-		
+
 		mutex_unlock(&area->lock);
 	}
-	
+
 	/*
 	 * So far, the area does not conflict with other areas.
@@ -434,5 +434,5 @@
 		    addr, P2SZ(count));
 	}
-	
+
 	return true;
 }
@@ -456,8 +456,8 @@
 {
 	assert(mutex_locked(&as->lock));
-	
+
 	if (size == 0)
 		return (uintptr_t) -1;
-	
+
 	/*
 	 * Make sure we allocate from page-aligned
@@ -465,12 +465,12 @@
 	 * each step.
 	 */
-	
+
 	size_t pages = SIZE2FRAMES(size);
-	
+
 	/*
 	 * Find the lowest unmapped address aligned on the size
 	 * boundary, not smaller than bound and of the required size.
 	 */
-	
+
 	/* First check the bound address itself */
 	uintptr_t addr = ALIGN_UP(bound, PAGE_SIZE);
@@ -486,13 +486,13 @@
 			return addr;
 	}
-	
+
 	/* Eventually check the addresses behind each area */
 	list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t, node) {
-		
+
 		for (btree_key_t i = 0; i < node->keys; i++) {
 			as_area_t *area = (as_area_t *) node->value[i];
-			
+
 			mutex_lock(&area->lock);
-			
+
 			addr =
 			    ALIGN_UP(area->base + P2SZ(area->pages), PAGE_SIZE);
@@ -508,12 +508,12 @@
 			    ((addr >= bound) && (addr >= area->base) &&
 			    (check_area_conflicts(as, addr, pages, guarded, area)));
-			
+
 			mutex_unlock(&area->lock);
-			
+
 			if (avail)
 				return addr;
 		}
 	}
-	
+
 	/* No suitable address space area found */
 	return (uintptr_t) -1;
@@ -530,11 +530,11 @@
 {
 	bool dealloc = false;
-	
+
 	mutex_lock(&sh_info->lock);
 	assert(sh_info->refcount);
-	
+
 	if (--sh_info->refcount == 0) {
 		dealloc = true;
-		
+
 		/*
 		 * Now walk carefully the pagemap B+tree and free/remove
@@ -544,12 +544,12 @@
 		    btree_node_t, node) {
 			btree_key_t i;
-			
+
 			for (i = 0; i < node->keys; i++)
 				frame_free((uintptr_t) node->value[i], 1);
 		}
-		
+
 	}
 	mutex_unlock(&sh_info->lock);
-	
+
 	if (dealloc) {
 		if (sh_info->backend && sh_info->backend->destroy_shared_data) {
@@ -588,10 +588,10 @@
 	if ((*base != (uintptr_t) AS_AREA_ANY) && !IS_ALIGNED(*base, PAGE_SIZE))
 		return NULL;
-	
+
 	if (size == 0)
 		return NULL;
 
 	size_t pages = SIZE2FRAMES(size);
-	
+
 	/* Writeable executable areas are not supported. */
 	if ((flags & AS_AREA_EXEC) && (flags & AS_AREA_WRITE))
@@ -599,7 +599,7 @@
 
 	bool const guarded = flags & AS_AREA_GUARD;
-	
+
 	mutex_lock(&as->lock);
-	
+
 	if (*base == (uintptr_t) AS_AREA_ANY) {
 		*base = as_get_unmapped_area(as, bound, size, guarded);
@@ -619,9 +619,9 @@
 		return NULL;
 	}
-	
+
 	as_area_t *area = (as_area_t *) malloc(sizeof(as_area_t), 0);
-	
+
 	mutex_initialize(&area->lock, MUTEX_PASSIVE);
-	
+
 	area->as = as;
 	area->flags = flags;
@@ -632,5 +632,5 @@
 	area->backend = backend;
 	area->sh_info = NULL;
-	
+
 	if (backend_data)
 		area->backend_data = *backend_data;
@@ -655,5 +655,5 @@
 
 		area->sh_info = si;
-	
+
 		if (area->backend && area->backend->create_shared_data) {
 			if (!area->backend->create_shared_data(area)) {
@@ -679,7 +679,7 @@
 	btree_insert(&as->as_area_btree, *base, (void *) area,
 	    NULL);
-	
+
 	mutex_unlock(&as->lock);
-	
+
 	return area;
 }
@@ -697,5 +697,5 @@
 {
 	assert(mutex_locked(&as->lock));
-	
+
 	btree_node_t *leaf;
 	as_area_t *area = (as_area_t *) btree_search(&as->as_area_btree, va,
@@ -706,5 +706,5 @@
 		return area;
 	}
-	
+
 	/*
 	 * Search the leaf node and the rightmost record of its left neighbour
@@ -712,11 +712,11 @@
 	 * space area found there.
 	 */
-	
+
 	/* First, search the leaf node itself. */
 	btree_key_t i;
-	
+
 	for (i = 0; i < leaf->keys; i++) {
 		area = (as_area_t *) leaf->value[i];
-		
+
 		mutex_lock(&area->lock);
 
@@ -724,8 +724,8 @@
 		    (va <= area->base + (P2SZ(area->pages) - 1)))
 			return area;
-		
+
 		mutex_unlock(&area->lock);
 	}
-	
+
 	/*
 	 * Second, locate the left neighbour and test its last record.
@@ -736,13 +736,13 @@
 	if (lnode) {
 		area = (as_area_t *) lnode->value[lnode->keys - 1];
-		
+
 		mutex_lock(&area->lock);
-		
+
 		if (va <= area->base + (P2SZ(area->pages) - 1))
 			return area;
-		
+
 		mutex_unlock(&area->lock);
 	}
-	
+
 	return NULL;
 }
@@ -766,5 +766,5 @@
 
 	mutex_lock(&as->lock);
-	
+
 	/*
 	 * Locate the area.
@@ -784,5 +784,5 @@
 		return ENOTSUP;
 	}
-	
+
 	mutex_lock(&area->sh_info->lock);
 	if (area->sh_info->shared) {
@@ -797,5 +797,5 @@
 	}
 	mutex_unlock(&area->sh_info->lock);
-	
+
 	size_t pages = SIZE2FRAMES((address - area->base) + size);
 	if (!pages) {
@@ -807,15 +807,15 @@
 		return EPERM;
 	}
-	
+
 	if (pages < area->pages) {
 		uintptr_t start_free = area->base + P2SZ(pages);
-		
+
 		/*
 		 * Shrinking the area.
 		 * No need to check for overlaps.
 		 */
-		
+
 		page_table_lock(as, false);
-		
+
 		/*
 		 * Remove frames belonging to used space starting from
@@ -828,9 +828,9 @@
 		while (cond) {
 			assert(!list_empty(&area->used_space.leaf_list));
-			
+
 			btree_node_t *node =
 			    list_get_instance(list_last(&area->used_space.leaf_list),
 			    btree_node_t, leaf_link);
-			
+
 			if ((cond = (node->keys != 0))) {
 				uintptr_t ptr = node->key[node->keys - 1];
@@ -838,8 +838,8 @@
 				    (size_t) node->value[node->keys - 1];
 				size_t i = 0;
-				
+
 				if (overlaps(ptr, P2SZ(node_size), area->base,
 				    P2SZ(pages))) {
-					
+
 					if (ptr + P2SZ(node_size) <= start_free) {
 						/*
@@ -850,5 +850,5 @@
 						break;
 					}
-					
+
 					/*
 					 * Part of the interval corresponding
@@ -856,5 +856,5 @@
 					 * address space area.
 					 */
-					
+
 					/* We are almost done */
 					cond = false;
@@ -871,5 +871,5 @@
 						panic("Cannot remove used space.");
 				}
-				
+
 				/*
 				 * Start TLB shootdown sequence.
@@ -887,14 +887,14 @@
 				    as->asid, area->base + P2SZ(pages),
 				    area->pages - pages);
-		
+
 				for (; i < node_size; i++) {
 					pte_t pte;
 					bool found = page_mapping_find(as,
 					    ptr + P2SZ(i), false, &pte);
-					
+
 					assert(found);
 					assert(PTE_VALID(&pte));
 					assert(PTE_PRESENT(&pte));
-					
+
 					if ((area->backend) &&
 					    (area->backend->frame_free)) {
@@ -903,16 +903,16 @@
 						    PTE_GET_FRAME(&pte));
 					}
-					
+
 					page_mapping_remove(as, ptr + P2SZ(i));
 				}
-		
+
 				/*
 				 * Finish TLB shootdown sequence.
 				 */
-		
+
 				tlb_invalidate_pages(as->asid,
 				    area->base + P2SZ(pages),
 				    area->pages - pages);
-		
+
 				/*
 				 * Invalidate software translation caches
@@ -944,5 +944,5 @@
 		}
 	}
-	
+
 	if (area->backend && area->backend->resize) {
 		if (!area->backend->resize(area, pages)) {
@@ -952,10 +952,10 @@
 		}
 	}
-	
+
 	area->pages = pages;
-	
+
 	mutex_unlock(&area->lock);
 	mutex_unlock(&as->lock);
-	
+
 	return 0;
 }
@@ -972,5 +972,5 @@
 {
 	mutex_lock(&as->lock);
-	
+
 	as_area_t *area = find_area_and_lock(as, address);
 	if (!area) {
@@ -981,9 +981,9 @@
 	if (area->backend && area->backend->destroy)
 		area->backend->destroy(area);
-	
+
 	uintptr_t base = area->base;
-	
+
 	page_table_lock(as, false);
-	
+
 	/*
 	 * Start TLB shootdown sequence.
@@ -991,5 +991,5 @@
 	ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid, area->base,
 	    area->pages);
-	
+
 	/*
 	 * Visit only the pages mapped by used_space B+tree.
@@ -998,18 +998,18 @@
 	    node) {
 		btree_key_t i;
-		
+
 		for (i = 0; i < node->keys; i++) {
 			uintptr_t ptr = node->key[i];
 			size_t size;
-			
+
 			for (size = 0; size < (size_t) node->value[i]; size++) {
 				pte_t pte;
 				bool found = page_mapping_find(as,
 				     ptr + P2SZ(size), false, &pte);
-				
+
 				assert(found);
 				assert(PTE_VALID(&pte));
 				assert(PTE_PRESENT(&pte));
-				
+
 				if ((area->backend) &&
 				    (area->backend->frame_free)) {
@@ -1018,16 +1018,16 @@
 					    PTE_GET_FRAME(&pte));
 				}
-				
+
 				page_mapping_remove(as, ptr + P2SZ(size));
 			}
 		}
 	}
-	
+
 	/*
 	 * Finish TLB shootdown sequence.
 	 */
-	
+
 	tlb_invalidate_pages(as->asid, area->base, area->pages);
-	
+
 	/*
 	 * Invalidate potential software translation caches
@@ -1036,22 +1036,22 @@
 	as_invalidate_translation_cache(as, area->base, area->pages);
 	tlb_shootdown_finalize(ipl);
-	
+
 	page_table_unlock(as, false);
-	
+
 	btree_destroy(&area->used_space);
-	
+
 	area->attributes |= AS_AREA_ATTR_PARTIAL;
-	
+
 	sh_info_remove_reference(area->sh_info);
-	
+
 	mutex_unlock(&area->lock);
-	
+
 	/*
 	 * Remove the empty area from address space.
 	 */
 	btree_remove(&as->as_area_btree, base, NULL);
-	
+
 	free(area);
-	
+
 	mutex_unlock(&as->lock);
 	return 0;
@@ -1098,5 +1098,5 @@
 		return ENOENT;
 	}
-	
+
 	if (!src_area->backend->is_shareable(src_area)) {
 		/*
@@ -1107,14 +1107,14 @@
 		return ENOTSUP;
 	}
-	
+
 	size_t src_size = P2SZ(src_area->pages);
 	unsigned int src_flags = src_area->flags;
 	mem_backend_t *src_backend = src_area->backend;
 	mem_backend_data_t src_backend_data = src_area->backend_data;
-	
+
 	/* Share the cacheable flag from the original mapping */
 	if (src_flags & AS_AREA_CACHEABLE)
 		dst_flags_mask |= AS_AREA_CACHEABLE;
-	
+
 	if ((src_size != acc_size) ||
 	    ((src_flags & dst_flags_mask) != dst_flags_mask)) {
@@ -1123,5 +1123,5 @@
 		return EPERM;
 	}
-	
+
 	/*
 	 * Now we are committed to sharing the area.
@@ -1130,5 +1130,5 @@
 	 */
 	share_info_t *sh_info = src_area->sh_info;
-	
+
 	mutex_lock(&sh_info->lock);
 	sh_info->refcount++;
@@ -1144,8 +1144,8 @@
 		src_area->backend->share(src_area);
 	}
-	
+
 	mutex_unlock(&src_area->lock);
 	mutex_unlock(&src_as->lock);
-	
+
 	/*
 	 * Create copy of the source address space area.
@@ -1164,8 +1164,8 @@
 		 */
 		sh_info_remove_reference(sh_info);
-		
+
 		return ENOMEM;
 	}
-	
+
 	/*
 	 * Now the destination address space area has been
@@ -1179,5 +1179,5 @@
 	mutex_unlock(&dst_area->lock);
 	mutex_unlock(&dst_as->lock);
-	
+
 	return 0;
 }
@@ -1195,5 +1195,5 @@
 {
 	assert(mutex_locked(&area->lock));
-	
+
 	int flagmap[] = {
 		[PF_ACCESS_READ] = AS_AREA_READ,
@@ -1201,8 +1201,8 @@
 		[PF_ACCESS_EXEC] = AS_AREA_EXEC
 	};
-	
+
 	if (!(area->flags & flagmap[access]))
 		return false;
-	
+
 	return true;
 }
@@ -1218,17 +1218,17 @@
 {
 	unsigned int flags = PAGE_USER | PAGE_PRESENT;
-	
+
 	if (aflags & AS_AREA_READ)
 		flags |= PAGE_READ;
-		
+
 	if (aflags & AS_AREA_WRITE)
 		flags |= PAGE_WRITE;
-	
+
 	if (aflags & AS_AREA_EXEC)
 		flags |= PAGE_EXEC;
-	
+
 	if (aflags & AS_AREA_CACHEABLE)
 		flags |= PAGE_CACHEABLE;
-	
+
 	return flags;
 }
@@ -1252,7 +1252,7 @@
 	/* Flags for the new memory mapping */
 	unsigned int page_flags = area_flags_to_page_flags(flags);
-	
+
 	mutex_lock(&as->lock);
-	
+
 	as_area_t *area = find_area_and_lock(as, address);
 	if (!area) {
@@ -1260,5 +1260,5 @@
 		return ENOENT;
 	}
-	
+
 	if (area->backend != &anon_backend) {
 		/* Copying non-anonymous memory not supported yet */
@@ -1277,23 +1277,23 @@
 	}
 	mutex_unlock(&area->sh_info->lock);
-	
+
 	/*
 	 * Compute total number of used pages in the used_space B+tree
 	 */
 	size_t used_pages = 0;
-	
+
 	list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
 	    node) {
 		btree_key_t i;
-		
+
 		for (i = 0; i < node->keys; i++)
 			used_pages += (size_t) node->value[i];
 	}
-	
+
 	/* An array for storing frame numbers */
 	uintptr_t *old_frame = malloc(used_pages * sizeof(uintptr_t), 0);
-	
+
 	page_table_lock(as, false);
-	
+
 	/*
 	 * Start TLB shootdown sequence.
@@ -1301,5 +1301,5 @@
 	ipl_t ipl = tlb_shootdown_start(TLB_INVL_PAGES, as->asid, area->base,
 	    area->pages);
-	
+
 	/*
 	 * Remove used pages from page tables and remember their frame
@@ -1307,24 +1307,24 @@
 	 */
 	size_t frame_idx = 0;
-	
+
 	list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
 	    node) {
 		btree_key_t i;
-		
+
 		for (i = 0; i < node->keys; i++) {
 			uintptr_t ptr = node->key[i];
 			size_t size;
-			
+
 			for (size = 0; size < (size_t) node->value[i]; size++) {
 				pte_t pte;
 				bool found = page_mapping_find(as,
 				    ptr + P2SZ(size), false, &pte);
-				
+
 				assert(found);
 				assert(PTE_VALID(&pte));
 				assert(PTE_PRESENT(&pte));
-				
+
 				old_frame[frame_idx++] = PTE_GET_FRAME(&pte);
-				
+
 				/* Remove old mapping */
 				page_mapping_remove(as, ptr + P2SZ(size));
@@ -1332,11 +1332,11 @@
 		}
 	}
-	
+
 	/*
 	 * Finish TLB shootdown sequence.
 	 */
-	
+
 	tlb_invalidate_pages(as->asid, area->base, area->pages);
-	
+
 	/*
 	 * Invalidate potential software translation caches
@@ -1345,12 +1345,12 @@
 	as_invalidate_translation_cache(as, area->base, area->pages);
 	tlb_shootdown_finalize(ipl);
-	
+
 	page_table_unlock(as, false);
-	
+
 	/*
 	 * Set the new flags.
 	 */
 	area->flags = flags;
-	
+
 	/*
 	 * Map pages back in with new flags. This step is kept separate
@@ -1359,30 +1359,30 @@
 	 */
 	frame_idx = 0;
-	
+
 	list_foreach(area->used_space.leaf_list, leaf_link, btree_node_t,
 	    node) {
 		btree_key_t i;
-		
+
 		for (i = 0; i < node->keys; i++) {
 			uintptr_t ptr = node->key[i];
 			size_t size;
-			
+
 			for (size = 0; size < (size_t) node->value[i]; size++) {
 				page_table_lock(as, false);
-				
+
 				/* Insert the new mapping */
 				page_mapping_insert(as, ptr + P2SZ(size),
 				    old_frame[frame_idx++], page_flags);
-				
+
 				page_table_unlock(as, false);
 			}
 		}
 	}
-	
+
 	free(old_frame);
-	
+
 	mutex_unlock(&area->lock);
 	mutex_unlock(&as->lock);
-	
+
 	return 0;
 }
@@ -1414,8 +1414,8 @@
 	if (!THREAD)
 		goto page_fault;
-	
+
 	if (!AS)
 		goto page_fault;
-	
+
 	mutex_lock(&AS->lock);
 	as_area_t *area = find_area_and_lock(AS, page);
@@ -1428,5 +1428,5 @@
 		goto page_fault;
 	}
-	
+
 	if (area->attributes & AS_AREA_ATTR_PARTIAL) {
 		/*
@@ -1438,5 +1438,5 @@
 		goto page_fault;
 	}
-	
+
 	if ((!area->backend) || (!area->backend->page_fault)) {
 		/*
@@ -1448,7 +1448,7 @@
 		goto page_fault;
 	}
-	
+
 	page_table_lock(AS, false);
-	
+
 	/*
 	 * To avoid race condition between two page faults on the same address,
@@ -1467,5 +1467,5 @@
 		}
 	}
-	
+
 	/*
 	 * Resort to the backend page fault handler.
@@ -1478,10 +1478,10 @@
 		goto page_fault;
 	}
-	
+
 	page_table_unlock(AS, false);
 	mutex_unlock(&area->lock);
 	mutex_unlock(&AS->lock);
 	return AS_PF_OK;
-	
+
 page_fault:
 	if (THREAD->in_copy_from_uspace) {
@@ -1501,5 +1501,5 @@
 		panic_memtrap(istate, access, address, NULL);
 	}
-	
+
 	return AS_PF_DEFER;
 }
@@ -1521,5 +1521,5 @@
 	DEADLOCK_PROBE_INIT(p_asidlock);
 	preemption_disable();
-	
+
 retry:
 	(void) interrupts_disable();
@@ -1536,5 +1536,5 @@
 	}
 	preemption_enable();
-	
+
 	/*
 	 * First, take care of the old address space.
@@ -1542,5 +1542,5 @@
 	if (old_as) {
 		assert(old_as->cpu_refcount);
-		
+
 		if ((--old_as->cpu_refcount == 0) && (old_as != AS_KERNEL)) {
 			/*
@@ -1551,9 +1551,9 @@
 			 */
 			assert(old_as->asid != ASID_INVALID);
-			
+
 			list_append(&old_as->inactive_as_with_asid_link,
 			    &inactive_as_with_asid_list);
 		}
-		
+
 		/*
 		 * Perform architecture-specific tasks when the address space
@@ -1562,5 +1562,5 @@
 		as_deinstall_arch(old_as);
 	}
-	
+
 	/*
 	 * Second, prepare the new address space.
@@ -1572,9 +1572,9 @@
 			new_as->asid = asid_get();
 	}
-	
+
 #ifdef AS_PAGE_TABLE
 	SET_PTL0_ADDRESS(new_as->genarch.page_table);
 #endif
-	
+
 	/*
 	 * Perform architecture-specific steps.
@@ -1582,7 +1582,7 @@
 	 */
 	as_install_arch(new_as);
-	
+
 	spinlock_unlock(&asidlock);
-	
+
 	AS = new_as;
 }
@@ -1598,5 +1598,5 @@
 {
 	assert(mutex_locked(&area->lock));
-	
+
 	return area_flags_to_page_flags(area->flags);
 }
@@ -1617,5 +1617,5 @@
 	assert(as_operations);
 	assert(as_operations->page_table_create);
-	
+
 	return as_operations->page_table_create(flags);
 }
@@ -1632,5 +1632,5 @@
 	assert(as_operations);
 	assert(as_operations->page_table_destroy);
-	
+
 	as_operations->page_table_destroy(page_table);
 }
@@ -1653,5 +1653,5 @@
 	assert(as_operations);
 	assert(as_operations->page_table_lock);
-	
+
 	as_operations->page_table_lock(as, lock);
 }
@@ -1667,5 +1667,5 @@
 	assert(as_operations);
 	assert(as_operations->page_table_unlock);
-	
+
 	as_operations->page_table_unlock(as, unlock);
 }
@@ -1697,8 +1697,8 @@
 {
 	size_t size;
-	
+
 	page_table_lock(AS, true);
 	as_area_t *src_area = find_area_and_lock(AS, base);
-	
+
 	if (src_area) {
 		size = P2SZ(src_area->pages);
@@ -1706,5 +1706,5 @@
 	} else
 		size = 0;
-	
+
 	page_table_unlock(AS, true);
 	return size;
@@ -1727,5 +1727,5 @@
 	assert(IS_ALIGNED(page, PAGE_SIZE));
 	assert(count);
-	
+
 	btree_node_t *leaf = NULL;
 	size_t pages = (size_t) btree_search(&area->used_space, page, &leaf);
@@ -1738,10 +1738,10 @@
 
 	assert(leaf != NULL);
-	
+
 	if (!leaf->keys) {
 		btree_insert(&area->used_space, page, (void *) count, leaf);
 		goto success;
 	}
-	
+
 	btree_node_t *node = btree_leaf_node_left_neighbour(&area->used_space, leaf);
 	if (node) {
@@ -1750,5 +1750,5 @@
 		size_t left_cnt = (size_t) node->value[node->keys - 1];
 		size_t right_cnt = (size_t) leaf->value[0];
-		
+
 		/*
 		 * Examine the possibility that the interval fits
@@ -1756,5 +1756,5 @@
 		 * the left neigbour and the first interval of the leaf.
 		 */
-		
+
 		if (page >= right_pg) {
 			/* Do nothing. */
@@ -1804,10 +1804,10 @@
 		uintptr_t right_pg = leaf->key[0];
 		size_t right_cnt = (size_t) leaf->value[0];
-		
+
 		/*
 		 * Investigate the border case in which the left neighbour does
 		 * not exist but the interval fits from the left.
 		 */
-		
+
 		if (overlaps(page, P2SZ(count), right_pg, P2SZ(right_cnt))) {
 			/* The interval intersects with the right interval. */
@@ -1832,5 +1832,5 @@
 		}
 	}
-	
+
 	node = btree_leaf_node_right_neighbour(&area->used_space, leaf);
 	if (node) {
@@ -1839,5 +1839,5 @@
 		size_t left_cnt = (size_t) leaf->value[leaf->keys - 1];
 		size_t right_cnt = (size_t) node->value[0];
-		
+
 		/*
 		 * Examine the possibility that the interval fits
@@ -1845,5 +1845,5 @@
 		 * the right neigbour and the last interval of the leaf.
 		 */
-		
+
 		if (page < left_pg) {
 			/* Do nothing. */
@@ -1893,10 +1893,10 @@
 		uintptr_t left_pg = leaf->key[leaf->keys - 1];
 		size_t left_cnt = (size_t) leaf->value[leaf->keys - 1];
-		
+
 		/*
 		 * Investigate the border case in which the right neighbour
 		 * does not exist but the interval fits from the right.
 		 */
-		
+
 		if (overlaps(page, P2SZ(count), left_pg, P2SZ(left_cnt))) {
 			/* The interval intersects with the left interval. */
@@ -1919,5 +1919,5 @@
 		}
 	}
-	
+
 	/*
 	 * Note that if the algorithm made it thus far, the interval can fit
@@ -1932,9 +1932,9 @@
 			size_t left_cnt = (size_t) leaf->value[i - 1];
 			size_t right_cnt = (size_t) leaf->value[i];
-			
+
 			/*
 			 * The interval fits between left_pg and right_pg.
 			 */
-			
+
 			if (overlaps(page, P2SZ(count), left_pg,
 			    P2SZ(left_cnt))) {
@@ -1988,8 +1988,8 @@
 		}
 	}
-	
+
 	panic("Inconsistency detected while adding %zu pages of used "
 	    "space at %p.", count, (void *) page);
-	
+
 success:
 	area->resident += count;
@@ -2013,5 +2013,5 @@
 	assert(IS_ALIGNED(page, PAGE_SIZE));
 	assert(count);
-	
+
 	btree_node_t *leaf;
 	size_t pages = (size_t) btree_search(&area->used_space, page, &leaf);
@@ -2038,9 +2038,9 @@
 				}
 			}
-			
+
 			goto error;
 		}
 	}
-	
+
 	btree_node_t *node = btree_leaf_node_left_neighbour(&area->used_space,
 	    leaf);
@@ -2048,5 +2048,5 @@
 		uintptr_t left_pg = node->key[node->keys - 1];
 		size_t left_cnt = (size_t) node->value[node->keys - 1];
-		
+
 		if (overlaps(left_pg, P2SZ(left_cnt), page, P2SZ(count))) {
 			if (page + P2SZ(count) == left_pg + P2SZ(left_cnt)) {
@@ -2078,13 +2078,13 @@
 			}
 		}
-		
+
 		return false;
 	} else if (page < leaf->key[0])
 		return false;
-	
+
 	if (page > leaf->key[leaf->keys - 1]) {
 		uintptr_t left_pg = leaf->key[leaf->keys - 1];
 		size_t left_cnt = (size_t) leaf->value[leaf->keys - 1];
-		
+
 		if (overlaps(left_pg, P2SZ(left_cnt), page, P2SZ(count))) {
 			if (page + P2SZ(count) == left_pg + P2SZ(left_cnt)) {
@@ -2115,8 +2115,8 @@
 			}
 		}
-		
+
 		return false;
 	}
-	
+
 	/*
 	 * The border cases have been already resolved.
@@ -2128,5 +2128,5 @@
 			uintptr_t left_pg = leaf->key[i - 1];
 			size_t left_cnt = (size_t) leaf->value[i - 1];
-			
+
 			/*
 			 * Now the interval is between intervals corresponding
@@ -2166,13 +2166,13 @@
 				}
 			}
-			
+
 			return false;
 		}
 	}
-	
+
 error:
 	panic("Inconsistency detected while removing %zu pages of used "
 	    "space from %p.", count, (void *) page);
-	
+
 success:
 	area->resident -= count;
@@ -2204,5 +2204,5 @@
 	if (area == NULL)
 		return (sysarg_t) AS_MAP_FAILED;
-	
+
 	return (sysarg_t) virt;
 }
@@ -2233,42 +2233,42 @@
 {
 	mutex_lock(&as->lock);
-	
+
 	/* First pass, count number of areas. */
-	
+
 	size_t area_cnt = 0;
-	
+
 	list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
 	    node) {
 		area_cnt += node->keys;
 	}
-	
+
 	size_t isize = area_cnt * sizeof(as_area_info_t);
 	as_area_info_t *info = malloc(isize, 0);
-	
+
 	/* Second pass, record data. */
-	
+
 	size_t area_idx = 0;
-	
+
 	list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
 	    node) {
 		btree_key_t i;
-		
+
 		for (i = 0; i < node->keys; i++) {
 			as_area_t *area = node->value[i];
-			
+
 			assert(area_idx < area_cnt);
 			mutex_lock(&area->lock);
-			
+
 			info[area_idx].start_addr = area->base;
 			info[area_idx].size = P2SZ(area->pages);
 			info[area_idx].flags = area->flags;
 			++area_idx;
-			
+
 			mutex_unlock(&area->lock);
 		}
 	}
-	
+
 	mutex_unlock(&as->lock);
-	
+
 	*obuf = info;
 	*osize = isize;
@@ -2283,13 +2283,13 @@
 {
 	mutex_lock(&as->lock);
-	
+
 	/* Print out info about address space areas */
 	list_foreach(as->as_area_btree.leaf_list, leaf_link, btree_node_t,
 	    node) {
 		btree_key_t i;
-		
+
 		for (i = 0; i < node->keys; i++) {
 			as_area_t *area = node->value[i];
-			
+
 			mutex_lock(&area->lock);
 			printf("as_area: %p, base=%p, pages=%zu"
@@ -2300,5 +2300,5 @@
 		}
 	}
-	
+
 	mutex_unlock(&as->lock);
 }
