Help with head_64.S

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The same problem I asked before.  I want to modify kernel image's page table from 2M to 4K. 

In arch/x86/kernel/head_64.S, I add another level page table, make pmd point to the new page table. However, after compile and boot it, the kernel cannot work and always reboot.

I try many kind of port, it still cannot work normally.


Here is the context of my modified code :
-----------------------------------------------------
/* Automate the creation of 1 to 1 mapping pmd entries */
#define PMDS(START, PERM, COUNT)            \
    i = 0 ;                     \
    .rept (COUNT) ;                 \
    .quad   (START) + (i << PMD_SHIFT) + (PERM) ;   \
    i = i + 1 ;                 \
    .endr

#define PTDS(START, PERM, COUNT)            \
    i = 0 ;                     \
    .rept (COUNT) ;                 \
    .quad   (START) + (i << PAGE_SHIFT) + (PERM) ;  \
    i = i + 1 ;                 \
    .endr

    .data
    /*  
     * This default setting generates an ident mapping at address 0x100000
     * and a mapping for the kernel that precisely maps virtual address
     * 0xffffffff80000000 to physical address 0x000000. (always using
     * 2Mbyte large pages provided by PAE mode)
     */
NEXT_PAGE(init_level4_pgt)
    .quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
    .org    init_level4_pgt + L4_PAGE_OFFSET*8, 0
    .quad   level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
    .org    init_level4_pgt + L4_START_KERNEL*8, 0
    /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
    .quad   level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE

NEXT_PAGE(level3_ident_pgt)
    .quad   level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
    .fill   511,8,0

NEXT_PAGE(level3_kernel_pgt)
    .fill   L3_START_KERNEL,8,0
    /* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
    .quad   level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
    .quad   level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE

NEXT_PAGE(level2_fixmap_pgt)
    .fill   506,8,0
    .quad   level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
    /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
    .fill   5,8,0

NEXT_PAGE(level1_fixmap_pgt)
    .fill   512,8,0

NEXT_PAGE(level2_ident_pgt)
    /* Since I easily can, map the first 1G.
     * Don't set NX because code runs from these pages.
     */
    PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)

NEXT_PAGE(level2_kernel_pgt)
    /*  
     * 512 MB kernel mapping. We spend a full page on this pagetable
     * anyway.
     *
     * The kernel code+data+bss must not be bigger than that.
     *
     * (NOTE: at +512MB starts the module area, see MODULES_VADDR.
     *  If you want to increase this then increase MODULES_VADDR
     *  too.)
     */
/*  PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
        KERNEL_IMAGE_SIZE/PMD_SIZE)*/
#define NEW_PMD_PORT (0x0 | _PAGE_PRESENT | _PAGE_RW |  _PAGE_ACCESSED)
    PMDS(level1_kernel_pgt - __START_KERNEL_map, NEW_PMD_PORT, PTRS_PER_PMD)

NEXT_PAGE(level1_kernel_pgt)
#define NEW_PTD_PORT (0x0 | _PAGE_PRESENT | _PAGE_RW | |_PAGE_USER | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
    PTDS(0, NEW_PTD_PORT, KERNEL_IMAGE_SIZE/PAGE_SIZE)

NEXT_PAGE(level2_spare_pgt)
    .fill   512, 8, 0
----------------------------------------------------------------------------------------------
_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux