Changeset 20d50a1 in mainline for arch


Ignore:
Timestamp:
2006-01-13T13:02:45Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f9425006
Parents:
0369911
Message:

Memory management work.

  • vm.* → as.* (as like address space is, imho, more fitting)
  • Don't do TLB shootdown on vm_install(). Some architectures only need to call tlb_invalidate_asid().
  • Don't allocate all frames for as_area in as_area_create(), but let them be allocated on-demand by as_page_fault().
  • Add high-level page fault handler as_page_fault().
  • Add as_area_load_mapping().
Location:
arch
Files:
8 edited
7 moved

Legend:

Unmodified
Added
Removed
  • arch/amd64/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __amd64_VM_H__
    30 #define __amd64_VM_H__
     29#ifndef __amd64_AS_H__
     30#define __amd64_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x21000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/amd64/src/interrupt.c

    r0369911 r20d50a1  
    3636#include <arch/asm.h>
    3737#include <mm/tlb.h>
     38#include <mm/as.h>
    3839#include <arch.h>
    3940#include <symtab.h>
     
    125126}
    126127
    127 
    128 
    129128void page_fault(int n, void *stack)
    130129{
    131         print_info_errcode(n,stack);
    132         printf("Page fault address: %Q\n", read_cr2());
    133         panic("page fault\n");
     130        __address page;
     131       
     132        page = read_cr2();
     133        if (!as_page_fault(page)) {
     134                print_info_errcode(n,stack);
     135                printf("Page fault address: %Q\n", page);
     136                panic("page fault\n");
     137        }
    134138}
    135139
  • arch/amd64/src/userspace.c

    r0369911 r20d50a1  
    3232#include <arch.h>
    3333#include <proc/thread.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535
    3636
  • arch/ia32/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __ia32_VM_H__
    30 #define __ia32_VM_H__
     29#ifndef __ia32_AS_H__
     30#define __ia32_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x21000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/ia32/src/interrupt.c

    r0369911 r20d50a1  
    3636#include <arch/asm.h>
    3737#include <mm/tlb.h>
     38#include <mm/as.h>
    3839#include <arch.h>
    3940#include <symtab.h>
     
    100101void page_fault(int n, void *stack)
    101102{
    102         PRINT_INFO_ERRCODE(stack);
    103         printf("page fault address: %X\n", read_cr2());
    104         panic("page fault\n");
     103        __address page;
     104
     105        page = read_cr2();
     106        if (!as_page_fault(page)) {
     107                PRINT_INFO_ERRCODE(stack);
     108                printf("page fault address: %X\n", page);
     109                panic("page fault\n");
     110        }
    105111}
    106112
  • arch/ia32/src/mm/frame.c

    r0369911 r20d50a1  
    2929#include <mm/frame.h>
    3030#include <arch/mm/frame.h>
    31 #include <mm/vm.h>
     31#include <mm/as.h>
    3232#include <config.h>
    3333#include <arch/boot/boot.h>
  • arch/ia32/src/userspace.c

    r0369911 r20d50a1  
    3232#include <arch.h>
    3333#include <proc/thread.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535
    3636
     
    4848        __asm__ volatile (
    4949                /* CLNT */
    50                 "pushfl;"
    51                 "pop %%eax;"
    52                 "and $0xFFFFBFFF,%%eax;"
    53                 "push %%eax;"
    54                 "popfl;"
     50                "pushfl\n"
     51                "pop %%eax\n"
     52                "and $0xffffbfff,%%eax\n"
     53                "push %%eax\n"
     54                "popfl\n"
    5555
    5656                "pushl %0\n"
     
    6565       
    6666        /* Unreachable */
    67         for(;;);
     67        for(;;)
     68                ;
    6869}
  • arch/ia64/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __ia64_VM_H__
    30 #define __ia64_VM_H__
     29#ifndef __ia64_AS_H__
     30#define __ia64_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x0000000001001000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/mips32/Makefile.inc

    r0369911 r20d50a1  
    113113        arch/$(ARCH)/src/mm/page.c \
    114114        arch/$(ARCH)/src/mm/tlb.c \
    115         arch/$(ARCH)/src/mm/vm.c \
     115        arch/$(ARCH)/src/mm/as.c \
    116116        arch/$(ARCH)/src/fpu_context.c \
    117117        arch/$(ARCH)/src/drivers/arc.c \
  • arch/mips32/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __mips32_VM_H__
    30 #define __mips32_VM_H__
     29#ifndef __mips32_AS_H__
     30#define __mips32_AS_H__
    3131
    3232#include <arch/types.h>
     
    4242#define UDATA_ADDRESS_ARCH      0x01001000
    4343
    44 extern void vm_install_arch(vm_t *vm);
    45 
    4644#endif
  • arch/mips32/src/mips32.c

    r0369911 r20d50a1  
    3232#include <arch/exception.h>
    3333#include <arch/asm.h>
    34 #include <mm/vm.h>
     34#include <mm/as.h>
    3535
    3636#include <userspace.h>
  • arch/mips32/src/mm/as.c

    r0369911 r20d50a1  
    2727 */
    2828
    29 #include <arch/mm/vm.h>
     29#include <arch/mm/as.h>
    3030#include <arch/mm/tlb.h>
    31 #include <mm/vm.h>
     31#include <mm/tlb.h>
     32#include <mm/as.h>
    3233#include <arch/cp0.h>
    3334#include <arch.h>
    3435
    35 /** Install ASID of the current VM
     36/** Install address space.
    3637 *
    37  * Install ASID of the current VM.
     38 * Install ASID and if necessary, purge TLB.
    3839 *
    39  * @param vm VM structure.
     40 * @param as Address space structure.
    4041 */
    41 void vm_install_arch(vm_t *vm)
     42void as_install_arch(as_t *as)
    4243{
    4344        entry_hi_t hi;
    4445        ipl_t ipl;
    45        
     46
     47        /*
     48         * If necessary, purge TLB.
     49         */
     50        tlb_invalidate_asid(as->asid);  /* TODO: do it only if necessary */
     51
     52        /*
     53         * Install ASID.
     54         */     
    4655        hi.value = cp0_entry_hi_read();
    4756
    4857        ipl = interrupts_disable();
    49         spinlock_lock(&vm->lock);
    50         hi.asid = vm->asid;
     58        spinlock_lock(&as->lock);
     59        hi.asid = as->asid;
    5160        cp0_entry_hi_write(hi.value);   
    52         spinlock_unlock(&vm->lock);
     61        spinlock_unlock(&as->lock);
    5362        interrupts_restore(ipl);
    5463}
  • arch/mips32/src/mm/tlb.c

    r0369911 r20d50a1  
    3131#include <mm/tlb.h>
    3232#include <mm/page.h>
    33 #include <mm/vm.h>
     33#include <mm/as.h>
    3434#include <arch/cp0.h>
    3535#include <panic.h>
     
    9393        badvaddr = cp0_badvaddr_read();
    9494
    95         spinlock_lock(&VM->lock);               
     95        spinlock_lock(&AS->lock);               
    9696
    9797        pte = find_mapping_and_check(badvaddr);
     
    104104        pte->a = 1;
    105105
    106         prepare_entry_hi(&hi, VM->asid, badvaddr);
     106        prepare_entry_hi(&hi, AS->asid, badvaddr);
    107107        prepare_entry_lo(&lo, pte->lo.g, pte->lo.v, pte->lo.d, pte->lo.c, pte->lo.pfn);
    108108
     
    122122        tlbwr();
    123123
    124         spinlock_unlock(&VM->lock);
     124        spinlock_unlock(&AS->lock);
    125125        return;
    126126       
    127127fail:
    128         spinlock_unlock(&VM->lock);
     128        spinlock_unlock(&AS->lock);
    129129        tlb_refill_fail(pstate);
    130130}
     
    155155        index.value = cp0_index_read();
    156156       
    157         spinlock_lock(&VM->lock);       
     157        spinlock_lock(&AS->lock);       
    158158       
    159159        /*
     
    191191        tlbwi();
    192192
    193         spinlock_unlock(&VM->lock);     
     193        spinlock_unlock(&AS->lock);     
    194194        return;
    195195       
    196196fail:
    197         spinlock_unlock(&VM->lock);
     197        spinlock_unlock(&AS->lock);
    198198        tlb_invalid_fail(pstate);
    199199}
     
    224224        index.value = cp0_index_read();
    225225       
    226         spinlock_lock(&VM->lock);       
     226        spinlock_lock(&AS->lock);       
    227227       
    228228        /*
     
    267267        tlbwi();
    268268
    269         spinlock_unlock(&VM->lock);     
     269        spinlock_unlock(&AS->lock);     
    270270        return;
    271271       
    272272fail:
    273         spinlock_unlock(&VM->lock);
     273        spinlock_unlock(&AS->lock);
    274274        tlb_modified_fail(pstate);
    275275}
     
    313313 *
    314314 * Try to find PTE for faulting address.
    315  * The VM->lock must be held on entry to this function.
     315 * The AS->lock must be held on entry to this function.
    316316 *
    317317 * @param badvaddr Faulting virtual address.
     
    329329         * Handler cannot succeed if the ASIDs don't match.
    330330         */
    331         if (hi.asid != VM->asid) {
    332                 printf("EntryHi.asid=%d, VM->asid=%d\n", hi.asid, VM->asid);
     331        if (hi.asid != AS->asid) {
     332                printf("EntryHi.asid=%d, AS->asid=%d\n", hi.asid, AS->asid);
    333333                return NULL;
    334334        }
    335        
     335
     336        /*
     337         * Check if the mapping exists in page tables.
     338         */     
     339        pte = page_mapping_find(badvaddr, AS->asid, 0);
     340        if (pte && pte->lo.v) {
     341                /*
     342                 * Mapping found in page tables.
     343                 * Immediately succeed.
     344                 */
     345                return pte;
     346        } else {
     347                /*
     348                 * Mapping not found in page tables.
     349                 * Resort to higher-level page fault handler.
     350                 */
     351                if (as_page_fault(badvaddr)) {
     352                        /*
     353                         * The higher-level page fault handler succeeded,
     354                         * The mapping ought to be in place.
     355                         */
     356                        pte = page_mapping_find(badvaddr, AS->asid, 0);
     357                        ASSERT(pte && pte->lo.v);
     358                        return pte;
     359                }
     360        }
     361
    336362        /*
    337363         * Handler cannot succeed if badvaddr has no mapping.
    338364         */
    339         pte = page_mapping_find(badvaddr, VM->asid, 0);
    340365        if (!pte) {
    341366                printf("No such mapping.\n");
  • arch/ppc32/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __ppc32_VM_H__
    30 #define __ppc32_VM_H__
     29#ifndef __ppc32_AS_H__
     30#define __ppc32_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x21000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
  • arch/sparc64/include/mm/as.h

    r0369911 r20d50a1  
    2727 */
    2828
    29 #ifndef __sparc64_VM_H__
    30 #define __sparc64_VM_H__
     29#ifndef __sparc64_AS_H__
     30#define __sparc64_AS_H__
    3131
    3232#include <arch/types.h>
     
    4141#define UDATA_ADDRESS_ARCH      0x8000000000000000
    4242
    43 #define vm_install_arch(vm)
     43#define as_install_arch(as)
    4444
    4545#endif
Note: See TracChangeset for help on using the changeset viewer.