Changeset f8ddd17 in mainline for kernel/generic/src/mm/as.c


Ignore:
Timestamp:
2006-12-09T20:20:50Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b82a13c
Parents:
9ab9c2ec
Message:

Rework support for virtually indexed cache.
Instead of repeatedly flushing the data cache, which was a huge overkill, refuse to create an illegal address alias
in the kernel (again) and allocate appropriate page color in userspace instead. Extend the detection also to
SYS_PHYSMEM_MAP syscall.

Add support for tracking physical memory areas mappable by SYS_PHYSMEM_MAP.

Lots of coding style changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/as.c

    r9ab9c2ec rf8ddd17  
    167167        as->page_table = page_table_create(flags);
    168168
    169 #ifdef CONFIG_VIRT_IDX_DCACHE
    170         as->dcache_flush_on_install = false;
    171         as->dcache_flush_on_deinstall = false;
    172 #endif  /* CONFIG_VIRT_IDX_DCACHE */
    173 
    174169        return as;
    175170}
     
    278273        else
    279274                memsetb((uintptr_t) &a->backend_data, sizeof(a->backend_data), 0);
    280 
    281 #ifdef CONFIG_VIRT_IDX_DCACHE
    282         /*
    283          * When the area is being created with the AS_AREA_ATTR_PARTIAL flag, the
    284          * orig_color is probably wrong until the flag is reset. In other words, it is
    285          * initialized with the color of the area being created and not with the color
    286          * of the original address space area at the beginning of the share chain. Of
    287          * course, the correct color is set by as_area_share() before the flag is
    288          * reset.
    289          */
    290         a->orig_color = PAGE_COLOR(base);
    291 #endif /* CONFIG_VIRT_IDX_DCACHE */
    292275
    293276        btree_create(&a->used_space);
     
    576559 * or ENOMEM if there was a problem in allocating destination address space
    577560 * area. ENOTSUP is returned if the address space area backend does not support
    578  * sharing.
     561 * sharing or if the kernel detects an attempt to create an illegal address
     562 * alias.
    579563 */
    580564int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size,
     
    584568        int src_flags;
    585569        size_t src_size;
    586         int src_orig_color;
    587570        as_area_t *src_area, *dst_area;
    588571        share_info_t *sh_info;
     
    601584                return ENOENT;
    602585        }
    603        
    604586
    605587        if (!src_area->backend || !src_area->backend->share) {
     
    618600        src_backend = src_area->backend;
    619601        src_backend_data = src_area->backend_data;
    620         src_orig_color = src_area->orig_color;
    621602
    622603        /* Share the cacheable flag from the original mapping */
     
    630611                return EPERM;
    631612        }
     613
     614#ifdef CONFIG_VIRT_IDX_DCACHE
     615        if (!(dst_flags_mask & AS_AREA_EXEC)) {
     616                if (PAGE_COLOR(src_area->base) != PAGE_COLOR(dst_base)) {
     617                        /*
     618                         * Refuse to create an illegal address alias.
     619                         */
     620                        mutex_unlock(&src_area->lock);
     621                        mutex_unlock(&src_as->lock);
     622                        interrupts_restore(ipl);
     623                        return ENOTSUP;
     624                }
     625        }
     626#endif /* CONFIG_VIRT_IDX_DCACHE */
    632627
    633628        /*
     
    683678        dst_area->attributes &= ~AS_AREA_ATTR_PARTIAL;
    684679        dst_area->sh_info = sh_info;
    685         dst_area->orig_color = src_orig_color;
    686 #ifdef CONFIG_VIRT_IDX_DCACHE
    687         if (src_orig_color != PAGE_COLOR(dst_base)) {
    688                 /*
    689                  * We have just detected an attempt to create an invalid address
    690                  * alias. We allow this and set a special flag that tells the
    691                  * architecture specific code to flush the D-cache when the
    692                  * offending address space is installed and deinstalled
    693                  * (cleanup).
    694                  *
    695                  * In order for the flags to take effect immediately, we also
    696                  * perform a global D-cache shootdown.
    697                  */
    698                 dcache_shootdown_start();
    699                 dst_as->dcache_flush_on_install = true;
    700                 dst_as->dcache_flush_on_deinstall = true;
    701                 dcache_flush();
    702                 dcache_shootdown_finalize();
    703         }
    704 #endif /* CONFIG_VIRT_IDX_DCACHE */
    705680        mutex_unlock(&dst_area->lock);
    706681        mutex_unlock(&dst_as->lock);   
Note: See TracChangeset for help on using the changeset viewer.