Changeset c520034 in mainline for kernel/arch/amd64/src/mm/page.c


Ignore:
Timestamp:
2011-12-31T18:19:35Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
295f658, 77c2b02, 96cd5b4
Parents:
852052d (diff), 22f0561 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Support for kernel non-identity mappings, phase I.

  • identity/non-identity kernel memory split on all architectures
  • low/high physical memory split on all architectures
  • frame allocator understands low/high memory
  • high physical memory currently unused (Phase II)
  • more compact frame_t
  • zone conf frames, pte_t, kernel stacks allocated from low memory
  • lockless TLB-miss handlers everywhere (newly sparc64, ia64)
  • preallocate PTL1 page tables for non-identity and prevent their deallocation
  • hw_map() unification
  • new resource allocator used for allocating kernel virtual addresses

Breakage:

  • sparc64/sun4v creates too large kernel identity; not fixed because of lack of testing hw
  • ppc32's tlb_refill() seems wrong as it creates too large kernel identity, but appears unused and the architecture works normally

Not implemented yet (phase II):

  • allow high memory to be used for common kernel allocations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/src/mm/page.c

    r852052d rc520034  
    4646#include <panic.h>
    4747#include <align.h>
     48#include <macros.h>
    4849
    4950void page_arch_init(void)
    5051{
    51         if (config.cpu_active == 1) {
    52                 uintptr_t cur;
    53                 unsigned int identity_flags =
    54                     PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL | PAGE_WRITE;
     52        if (config.cpu_active > 1) {
     53                write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
     54                return;
     55        }
     56
     57        uintptr_t cur;
     58        unsigned int identity_flags =
     59            PAGE_CACHEABLE | PAGE_EXEC | PAGE_GLOBAL | PAGE_WRITE;
    5560               
    56                 page_mapping_operations = &pt_mapping_operations;
     61        page_mapping_operations = &pt_mapping_operations;
    5762               
    58                 page_table_lock(AS_KERNEL, true);
     63        page_table_lock(AS_KERNEL, true);
    5964               
    60                 /*
    61                  * PA2KA(identity) mapping for all frames.
    62                  */
    63                 for (cur = 0; cur < last_frame; cur += FRAME_SIZE)
    64                         page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, identity_flags);
     65        /*
     66         * PA2KA(identity) mapping for all low-memory frames.
     67         */
     68        for (cur = 0; cur < min(config.identity_size, config.physmem_end);
     69            cur += FRAME_SIZE)
     70                page_mapping_insert(AS_KERNEL, PA2KA(cur), cur, identity_flags);
    6571               
    66                 page_table_unlock(AS_KERNEL, true);
     72        page_table_unlock(AS_KERNEL, true);
    6773               
    68                 exc_register(14, "page_fault", true, (iroutine_t) page_fault);
    69                 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    70         } else
    71                 write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
     74        exc_register(14, "page_fault", true, (iroutine_t) page_fault);
     75        write_cr3((uintptr_t) AS_KERNEL->genarch.page_table);
    7276}
    7377
     
    9498}
    9599
    96 uintptr_t hw_map(uintptr_t physaddr, size_t size)
    97 {
    98         if (last_frame + ALIGN_UP(size, PAGE_SIZE) > KA2PA(KERNEL_ADDRESS_SPACE_END_ARCH))
    99                 panic("Unable to map physical memory %p (%zu bytes).",
    100                     (void *) physaddr, size);
    101        
    102         uintptr_t virtaddr = PA2KA(last_frame);
    103         pfn_t i;
    104        
    105         page_table_lock(AS_KERNEL, true);
    106        
    107         for (i = 0; i < ADDR2PFN(ALIGN_UP(size, PAGE_SIZE)); i++)
    108                 page_mapping_insert(AS_KERNEL, virtaddr + PFN2ADDR(i), physaddr + PFN2ADDR(i), PAGE_NOT_CACHEABLE | PAGE_WRITE);
    109        
    110         page_table_unlock(AS_KERNEL, true);
    111        
    112         last_frame = ALIGN_UP(last_frame + size, FRAME_SIZE);
    113        
    114         return virtaddr;
    115 }
    116 
    117100/** @}
    118101 */
Note: See TracChangeset for help on using the changeset viewer.