rem: if ((newProtection & (B_EXECUTE_AREA | B_KERNEL_EXECUTE_AREA)) != 0 && (newProtection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0) {  return B_NOT_ALLOWED; }
add: if (!arch_vm_supports_protection(newProtection)) return B_NOT_SUPPORTED;
context: vm_set_area_protection(aspace_id aspaceID, area_id areaID, uint32 newProtection){	vm_cache_ref *cacheRef;	vm_cache *cache;	vm_area *area;	status_t status = B_OK;	TRACE(("vm_set_area_protection(aspace = %#lx, area = %#lx, protection = %#lx)\n",		aspaceID, areaID, newProtection));	if ((newProtection & (B_EXECUTE_AREA | B_KERNEL_EXECUTE_AREA)) != 0		&& (newProtection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0) {		// executable areas must not be writable		return B_NOT_ALLOWED;	}	area = vm_get_area(areaID);	if (area == NULL)		return B_BAD_VALUE;	if (aspaceID != vm_get_kernel_aspace_id() && area->aspace->id != aspaceID) {		// unless you're the kernel, you are only allowed to set		// the protection of your own areas		vm_put_area(area);		return B_NOT_ALLOWED;	}	cacheRef = area->cache_ref;	cache = cacheRef->cache;	mutex_lock(&cacheRef->lock);	if ((area->protection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0		&& (newProtection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) == 0) {		// change from read/write to read-only		if (cache->source != NULL && cache->temporary) {			if (count_writable_areas(cacheRef, area) == 0) {				// Since this cache now lives from the pages in its source cache,				// we can change the cache's commitment to take only those pages				// into account that really are in this cache.				// count existing pages in this cache				struct vm_page *page = cache->page_list;				uint32 count = 0;				for (; page != NULL; page = page->cache_next) {					count++;				}				status = cache->store->ops->commit(cache->store, count * B_PAGE_SIZE);				// ToDo: we may be able to join with our source cache, if count == 0			}		}	} else if ((area->protection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) == 0		&& (newProtection & (B_WRITE_AREA | B_KERNEL_WRITE_AREA)) != 0) {		// change from read-only to read/write		// ToDo: if this is a shared cache, insert new cache (we only know about other		//	areas in this cache yet, though, not about child areas)		//	-> use this call with care, it might currently have unwanted consequences		//	   because of this. It should always be safe though, if there are no other		//	   (child) areas referencing this area's cache (you just might not know).		if (count_writable_areas(cacheRef, area) == 0			&& (cacheRef->areas != area || area->cache_next)) {			// ToDo: child areas are not tested for yet			dprintf("set_area_protection(): warning, would need to insert a new cache_ref (not yet implemented)!\n");			status = B_NOT_ALLOWED;		} else			dprintf("set_area_protection() may not work correctly yet in this direction!\n");		if (status == B_OK && cache->source != NULL && cache->temporary) {			// the cache's commitment must contain all possible pages			status = cache->store->ops->commit(cache->store, cache->virtual_size);		}	} else {		// we don't have anything special to do in all other cases	}	if (status == B_OK && area->protection != newProtection) {		// remap existing pages in this cache		struct vm_translation_map *map = &area->aspace->translation_map;		map->ops->lock(map);		map->ops->protect(map, area->base, area->base + area->size, newProtection);		map->ops->unlock(map);		area->protection = newProtection;	}	mutex_unlock(&cacheRef->lock);	vm_put_area(area);	return status;}