Architecture: ARM64
[Intro]
Fixmap是固定一直指到physical addr的特定位址[Intro]
Kernel會一次配一塊4K的virtual memory mapping 到physical addr
[Usage of Fix-Mapped Linear Address]
Kernel linear address的第四個GB中至少會有一塊128MB的memory mapping到physical address
這一塊memory 可以讓kernel implement
(1) noncontiguous memory allocation (2) fix-mapped linear address
[Fix-Mapped Linear Address VS. Physical Address]
Fix-Mapped Linear Address 是一個constant address. 例如 0xffffc000
每一個Fix-Mapped Linear Address maps到一個page frame(4K) 的physical memory
Fix-Mapped Linear Address 跟 linear address that map the first 896MB of RAM 很像
但Fix-Mapped Linear Address可以mapping到任何physical address
[Data Structure enum fixed_addresses]
每一個fix-mapped linear address都有一個專用的integer index defined 在 enum fixed_addresses中
36 enum fixed_addresses { 37 FIX_HOLE, 38 39 /* 40 * Reserve a virtual window for the FDT that is 2 MB larger than the 41 * maximum supported size, and put it at the top of the fixmap region. 42 * The additional space ensures that any FDT that does not exceed 43 * MAX_FDT_SIZE can be mapped regardless of whether it crosses any 44 * 2 MB alignment boundaries. 45 * 46 * Keep this at the top so it remains 2 MB aligned. 47 */ 48 #define FIX_FDT_SIZE (MAX_FDT_SIZE + SZ_2M) 49 FIX_FDT_END, 50 FIX_FDT = FIX_FDT_END + FIX_FDT_SIZE / PAGE_SIZE - 1, 51 52 FIX_EARLYCON_MEM_BASE, 53 FIX_TEXT_POKE0, 54 __end_of_permanent_fixed_addresses, 55 56 /* 57 * Temporary boot-time mappings, used by early_ioremap(), 58 * before ioremap() is functional. 59 */ 60 #define NR_FIX_BTMAPS (SZ_256K / PAGE_SIZE) 61 #define FIX_BTMAPS_SLOTS 7 62 #define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) 63 64 FIX_BTMAP_END = __end_of_permanent_fixed_addresses, 65 FIX_BTMAP_BEGIN = FIX_BTMAP_END + TOTAL_FIX_BTMAPS - 1, 66 67 /* 68 * Used for kernel page table creation, so unmapped memory may be used 69 * for tables. 70 */ 71 FIX_PTE, 72 FIX_PMD, 73 FIX_PUD, 74 FIX_PGD, 75 76 __end_of_fixed_addresses 77 };
[How to Obtain the Linear Address Set of a Fix-Mapped Linear Address]
23 #ifndef __ASSEMBLY__ 24 /* 25 * 'index to address' translation. If anyone tries to use the idx 26 * directly without translation, we catch the bug with a NULL-deference 27 * kernel oops. Illegal ranges of incoming indices are caught too. 28 */ 29 static __always_inline unsigned long fix_to_virt(const unsigned int idx) 30 { 31 BUILD_BUG_ON(idx >= __end_of_fixed_addresses); 32 return __fix_to_virt(idx); 33 }
fix_to_virt -> __fix_to_virt: 能夠根據index找到 constant linear address
如下, PAGE_SHIFT = 12
所以每一個index 對應到的linear address是從FIXADDR_TOP開始減 4K 的倍數
20 #define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
目前畫出的memory layout不一定正確, 若有誤會再修正
[Reference]
Fixmap:
http://palliatory66.rssing.com/chan-60693167/latest.php
ARM64 memory
http://blog.csdn.net/qianlong4526888/article/details/9058221
Linux doc about arm64 memory
http://lxr.free-electrons.com/source/Documentation/arm64/memory.txt?v=4.4
Linux kernel memory management
https://0xax.gitbooks.io/linux-insides/content/mm/linux-mm-2.html
Windows7 memory layout
http://www.codemachine.com/article_x64kvas.html
沒有留言:
張貼留言