Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 17af882 in mainline


Ignore:
Timestamp:
2014-06-16T11:32:05Z (6 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
master
Children:
2cb32f9
Parents:
334bf28
Message:

Switch the amd64 kernel (back) from 'large' to 'kernel' memory model.

  • This makes the amd64 kernel 6% smaller and more comfortable to debug.
  • Unlike in the original 'kernel' memory model implementation, KA2PA(PA2KA(x)) == x; for x from kernel identity.
  • Memory outside of the kernel identity region continues to be available by the standard means.
Location:
kernel
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/Makefile.inc

    r334bf28 r17af882  
    3232
    3333FPU_NO_CFLAGS = -mno-sse -mno-sse2
    34 CMN1 = -m64 -mcmodel=large -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
     34CMN1 = -m64 -mcmodel=kernel -mno-red-zone -fno-unwind-tables -fno-omit-frame-pointer
    3535GCC_CFLAGS += $(CMN1)
    3636ICC_CFLAGS += $(CMN1)
  • kernel/arch/amd64/include/arch/mm/km.h

    r334bf28 r17af882  
    3838#include <typedefs.h>
    3939
    40 #define KM_AMD64_IDENTITY_START         UINT64_C(0xffff800000000000)
    41 #define KM_AMD64_IDENTITY_SIZE          UINT64_C(0x0000400000000000)
     40#define KM_AMD64_IDENTITY_START         UINT64_C(0xffffffff80000000)
     41#define KM_AMD64_IDENTITY_SIZE          UINT64_C(0x0000000080000000)
    4242
    43 #define KM_AMD64_NON_IDENTITY_START     UINT64_C(0xffffc00000000000)
    44 #define KM_AMD64_NON_IDENTITY_SIZE      UINT64_C(0x0000400000000000)
     43#define KM_AMD64_NON_IDENTITY_START     UINT64_C(0xffff800000000000)
     44#define KM_AMD64_NON_IDENTITY_SIZE      UINT64_C(0x00007fff80000000)
    4545
    4646extern void km_identity_arch_init(void);
  • kernel/arch/amd64/include/arch/mm/page.h

    r334bf28 r17af882  
    4444#ifndef __ASM__
    4545
    46 #define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffff800000000000))
    47 #define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffff800000000000))
     46#define KA2PA(x)  (((uintptr_t) (x)) - UINT64_C(0xffffffff80000000))
     47#define PA2KA(x)  (((uintptr_t) (x)) + UINT64_C(0xffffffff80000000))
    4848
    4949#else /* __ASM__ */
    5050
    51 #define KA2PA(x)  ((x) - 0xffff800000000000)
    52 #define PA2KA(x)  ((x) + 0xffff800000000000)
     51#define KA2PA(x)  ((x) - 0xffffffff80000000)
     52#define PA2KA(x)  ((x) + 0xffffffff80000000)
    5353
    5454#endif /* __ASM__ */
  • kernel/arch/amd64/src/boot/multiboot.S

    r334bf28 r17af882  
    428428       
    429429        /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
    430         xorq %rdi, %rdi
    431430        movl multiboot_eax, %edi
    432         xorq %rsi, %rsi
    433431        movl multiboot_ebx, %esi
    434        
    435         movabsq $arch_pre_main, %rax
    436         callq *%rax
    437        
     432        callq arch_pre_main
     433
    438434        long_status $status_main
    439435       
    440436        /* Call main_bsp() */
    441         movabsq $main_bsp, %rax
    442         call *%rax
     437        callq main_bsp
    443438       
    444439        /* Not reached */
     
    638633        .quad ptl_2_6g + (PTL_WRITABLE | PTL_PRESENT)
    639634        .quad ptl_2_7g + (PTL_WRITABLE | PTL_PRESENT)
    640         .fill 504, 8, 0
     635        .fill 502, 8, 0
     636        /* Mapping of [0; 2G) at -2G */
     637        .quad ptl_2_0g + (PTL_WRITABLE | PTL_PRESENT)
     638        .quad ptl_2_1g + (PTL_WRITABLE | PTL_PRESENT)
     639
    641640
    642641.align 4096
     
    644643ptl_0:
    645644        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    646         .fill 255, 8, 0
     645        .fill 510, 8, 0
    647646        .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT)
    648         .fill 255, 8, 0
    649647
    650648.section K_DATA_START, "aw", @progbits
  • kernel/arch/amd64/src/boot/multiboot2.S

    r334bf28 r17af882  
    244244       
    245245        /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */
    246         xorq %rdi, %rdi
    247246        movl multiboot_eax, %edi
    248         xorq %rsi, %rsi
    249247        movl multiboot_ebx, %esi
    250        
    251         movabsq $arch_pre_main, %rax
    252         callq *%rax
     248        callq arch_pre_main
    253249       
    254250        /* Call main_bsp() */
    255         movabsq $main_bsp, %rax
    256         call *%rax
     251        callq main_bsp
    257252       
    258253        /* Not reached */
  • kernel/arch/amd64/src/mm/km.c

    r334bf28 r17af882  
    4040{
    4141        config.identity_base = KM_AMD64_IDENTITY_START;
    42         config.identity_size = KM_AMD64_IDENTITY_SIZE; 
     42        config.identity_size = KM_AMD64_IDENTITY_SIZE;
    4343}
    4444
  • kernel/genarch/src/mm/page_pt.c

    r334bf28 r17af882  
    384384            addr - 1 < base + size - 1;
    385385            addr += ptl0_step) {
     386                if (GET_PTL1_ADDRESS(ptl0, PTL0_INDEX(addr))) {
     387                        ASSERT(overlaps(addr, ptl0_step,
     388                            config.identity_base, config.identity_size));
     389
     390                        /*
     391                         * This PTL0 entry also maps the kernel identity region,
     392                         * so it is already global and initialized.
     393                         */
     394                        continue;
     395                }
     396
    386397                uintptr_t l1 = PA2KA(frame_alloc(frames, FRAME_LOWMEM, 0));
    387398                memsetb((void *) l1, FRAMES2SIZE(frames), 0);
Note: See TracChangeset for help on using the changeset viewer.