查看内核页表kernel_page_tables (aarch32)
作者
平台
概述
正文
一、配置内核
[root@vexpress debug]# cat kernel_page_tables
---[ Modules ]---
0xbfe01000-0xbfe1e000 116K RW NX SHD MEM/CACHED/WBWA
---[ Kernel Mapping ]---
0xc0000000-0xc0100000 1M RW NX SHD
0xc0100000-0xc0700000 6M ro x SHD
0xc0700000-0xc0900000 2M ro NX SHD
0xc0900000-0xf0000000 759M RW NX SHD
---[ vmalloc() Area ]---
0xf0800000-0xf0801000 4K RW NX SHD DEV/SHARED
0xf0802000-0xf0803000 4K RW NX SHD DEV/SHARED
0xf0804000-0xf0805000 4K RW NX SHD DEV/SHARED
0xf0806000-0xf0807000 4K RW NX SHD DEV/SHARED
0xf0808000-0xf0809000 4K RW NX SHD DEV/SHARED
0xf080a000-0xf080b000 4K RW NX SHD DEV/SHARED
0xf080c000-0xf080d000 4K RW NX SHD DEV/SHARED
0xf0814000-0xf0815000 4K RW NX SHD DEV/SHARED
0xf0816000-0xf0817000 4K RW NX SHD DEV/SHARED
0xf0818000-0xf0819000 4K RW NX SHD DEV/SHARED
0xf081a000-0xf081b000 4K RW NX SHD DEV/SHARED
0xf081c000-0xf085c000 256K RW NX SHD MEM/BUFFERABLE/WC
0xf085d000-0xf085e000 4K RW NX SHD DEV/SHARED
0xf085f000-0xf0860000 4K RW NX SHD DEV/SHARED
0xf0861000-0xf0862000 4K RW NX SHD DEV/SHARED
0xf0875000-0xf0876000 4K RW NX SHD DEV/SHARED
0xf0879000-0xf087a000 4K RW NX SHD DEV/SHARED
0xf087d000-0xf087e000 4K RW NX SHD DEV/SHARED
0xf0889000-0xf088a000 4K RW NX SHD DEV/SHARED
0xf088b000-0xf088c000 4K RW NX SHD DEV/SHARED
0xf088d000-0xf0898000 44K RW NX SHD MEM/CACHED/WBWA
0xf0899000-0xf08db000 264K RW NX SHD MEM/CACHED/WBWA
0xf08dc000-0xf08e7000 44K RW NX SHD MEM/CACHED/WBWA
0xf08e8000-0xf0908000 128K RW NX SHD MEM/CACHED/WBWA
0xf0909000-0xf0929000 128K RW NX SHD MEM/CACHED/WBWA
0xf092a000-0xf094a000 128K RW NX SHD MEM/CACHED/WBWA
0xf094b000-0xf096b000 128K RW NX SHD MEM/CACHED/WBWA
0xf096c000-0xf098c000 128K RW NX SHD MEM/CACHED/WBWA
0xf098d000-0xf09ad000 128K RW NX SHD MEM/CACHED/WBWA
0xf09ae000-0xf09ce000 128K RW NX SHD MEM/CACHED/WBWA
0xf09cf000-0xf09ef000 128K RW NX SHD MEM/CACHED/WBWA
0xf09f0000-0xf09f1000 4K RW NX SHD DEV/SHARED
0xf09f2000-0xf09f3000 4K RW NX SHD DEV/SHARED
0xf09f4000-0xf09f5000 4K RW NX SHD DEV/SHARED
0xf09f6000-0xf0b76000 1536K RW NX SHD MEM/BUFFERABLE/WC
0xf0b77000-0xf0b78000 4K RW NX SHD DEV/SHARED
0xf0b79000-0xf0b7a000 4K RW NX SHD DEV/SHARED
0xf0b80000-0xf1380000 8M RW NX SHD DEV/SHARED
0xf1385000-0xf1386000 4K RW NX SHD DEV/SHARED
0xf1387000-0xf1388000 4K RW NX SHD DEV/SHARED
0xf1389000-0xf138a000 4K RW NX SHD DEV/SHARED
0xf138b000-0xf138c000 4K RW NX SHD DEV/SHARED
0xf138d000-0xf138e000 4K RW NX SHD DEV/SHARED
0xf1390000-0xf13a0000 64K RW NX SHD DEV/SHARED
0xf13aa000-0xf13b5000 44K RW NX SHD MEM/CACHED/WBWA
0xf13b6000-0xf13b9000 12K RW NX SHD MEM/CACHED/WBWA
0xf1400000-0xf5400000 64M RW NX SHD DEV/SHARED
0xf5401000-0xf5425000 144K RW NX SHD MEM/CACHED/WBWA
0xf5480000-0xf7480000 32M RW NX SHD DEV/SHARED
0xf8009000-0xf800a000 4K RW NX SHD DEV/SHARED
0xf8080000-0xfc080000 64M RW NX SHD DEV/SHARED
---[ vmalloc() End ]---
---[ Fixmap Area ]---
0xffecd000-0xffecf000 8K RW NX SHD MEM/CACHED/WBWA
0xffedd000-0xffedf000 8K RW NX SHD MEM/CACHED/WBWA
0xffeed000-0xffeef000 8K RW NX SHD MEM/CACHED/WBWA
0xffefd000-0xffeff000 8K RW NX SHD MEM/CACHED/WBWA
---[ Vectors ]---
0xffff0000-0xffff1000 4K USR ro x SHD MEM/CACHED/WBWA
0xffff1000-0xffff2000 4K ro x SHD MEM/CACHED/WBWA
---[ Vectors End ]---
二、解释
参考文档:
static const struct prot_bits section_bits[] = {
{
.mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, // (1<<15) | (1<<11)|(1<<10)
.val = PMD_SECT_APX | PMD_SECT_AP_WRITE, // (1<<15) | (1<<10)
.set = " ro",
}, {
.mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, // (1<<15) | (1<<11)|(1<<10)
.val = PMD_SECT_AP_WRITE, // (1<<10)
.set = " RW",
}, {
.mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, // (1<<15) | (1<<11)|(1<<10)
.val = PMD_SECT_AP_READ, // (1<<11)
.set = "USR ro",
}, {
.mask = PMD_SECT_APX | PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, // (1<<15) | (1<<11)|(1<<10)
.val = PMD_SECT_AP_READ | PMD_SECT_AP_WRITE, // (1<<11)|(1<<10)
.set = "USR RW",
}, {
.mask = PMD_SECT_XN, // (1<<4)
.val = PMD_SECT_XN, // (1<<4)
.set = "NX",
.clear = "x ",
}, {
.mask = PMD_SECT_S, // (1<<16)
.val = PMD_SECT_S, // (1<<16)
.set = "SHD",
.clear = " ",
},
};
static const struct prot_bits pte_bits[] = {
{
.mask = L_PTE_USER,
.val = L_PTE_USER,
.set = "USR",
.clear = " ",
}, {
.mask = L_PTE_RDONLY,
.val = L_PTE_RDONLY,
.set = "ro",
.clear = "RW",
}, {
.mask = L_PTE_XN,
.val = L_PTE_XN,
.set = "NX",
.clear = "x ",
}, {
.mask = L_PTE_SHARED,
.val = L_PTE_SHARED,
.set = "SHD",
.clear = " ",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_UNCACHED,
.set = "SO/UNCACHED",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_BUFFERABLE,
.set = "MEM/BUFFERABLE/WC",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_WRITETHROUGH,
.set = "MEM/CACHED/WT",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_WRITEBACK,
.set = "MEM/CACHED/WBRA",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_MINICACHE,
.set = "MEM/MINICACHE",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_WRITEALLOC,
.set = "MEM/CACHED/WBWA",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_DEV_SHARED,
.set = "DEV/SHARED",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_DEV_NONSHARED,
.set = "DEV/NONSHARED",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_DEV_WC,
.set = "DEV/WC",
}, {
.mask = L_PTE_MT_MASK,
.val = L_PTE_MT_DEV_CACHED,
.set = "DEV/CACHED",
},
};
static struct pg_level pg_level[] = {
{
}, { /* pgd */
}, { /* pud */
}, { /* pmd */
.bits = section_bits,
.num = ARRAY_SIZE(section_bits),
}, { /* pte */
.bits = pte_bits,
.num = ARRAY_SIZE(pte_bits),
},
};
static int ptdump_init(void)
{
struct dentry *pe;
unsigned i, j; for (i = ; i < ARRAY_SIZE(pg_level); i++)
if (pg_level[i].bits)
for (j = ; j < pg_level[i].num; j++)
pg_level[i].mask |= pg_level[i].bits[j].mask; address_markers[].start_address = VMALLOC_START; pe = debugfs_create_file("kernel_page_tables", , NULL, NULL,
&ptdump_fops);
return pe ? : -ENOMEM;
}
__initcall(ptdump_init);
static struct addr_marker address_markers[] = {
{ MODULES_VADDR, "Modules" },
{ PAGE_OFFSET, "Kernel Mapping" },
{ , "vmalloc() Area" },
{ VMALLOC_END, "vmalloc() End" },
{ FIXADDR_START, "Fixmap Area" },
{ CONFIG_VECTORS_BASE, "Vectors" },
{ CONFIG_VECTORS_BASE + PAGE_SIZE * , "Vectors End" },
{ -, NULL },
};
Start | End | Use |
ffff8000 | ffffffff | copy_user_page / clear_user_page use. |
ffff4000 | ffffffff | cache aliasing on ARMv6 and later CPUs |
ffff1000 | ffff7fff | Reserved Platforms must not use this address range |
ffff0000 | ffff0fff | CPU vector page. The CPU vectors are mapped here if the CPU supports vector relocation (control register V bit.) |
fffe8000 | fffeffff | DTCM mapping area for platforms with DTCM mounted inside the CPU. |
fffe0000 | fffe7fff | ITCM mapping area for platforms with ITCM mounted inside the CPU |
ffc00000 | ffefffff | Fixmap mapping region. Addresses provided by fix_to_virt() will be located here |
VMALLOC_START | VMALLOC_END-1 | vmalloc() / ioremap() space. Memory returned by vmalloc/ioremap will be dynamically placed in this region.Machine specific static mappings are also located here through iotable_init().VMALLOC_START is based upon the value of the high_memory variable, and VMALLOC_END is equal to 0xff800000. |
PAGE_OFFSET | high_memory-1 | Kernel direct-mapped RAM region.This maps the platforms RAM, and typically maps all platform RAM in a 1:1 relationship |
PKMAP_BASE | PAGE_OFFSET-1 | Permanent kernel mappings One way of mapping HIGHMEM pages into kernel space. |
MODULES_VADDR | MODULES_END-1 | Kernel module space Kernel modules inserted via insmod are placed here using dynamic mappings. |
00001000 | TASK_SIZE-1 | User space mappings Per-thread mappings are placed here via the mmap() system call. |
00000000 | 00000fff | CPU vector page / null pointer trap CPUs which do not support vector remapping place their vector page here. NULL pointer dereferences by both the kernel and user space are also caught via this mapping. |
static void walk_pgd(struct seq_file *m)
{
pgd_t *pgd = swapper_pg_dir;
struct pg_state st;
unsigned long addr;
unsigned i; memset(&st, , sizeof(st));
st.seq = m;
st.marker = address_markers; for (i = ; i < PTRS_PER_PGD; i++, pgd++) {
addr = i * PGDIR_SIZE;
if (!pgd_none(*pgd)) {
walk_pud(&st, pgd, addr);
} else {
note_page(&st, addr, , pgd_val(*pgd));
}
} note_page(&st, , , );
}
typedef struct { pmdval_t pgd[]; } pgd_t;
static void walk_pud(struct pg_state *st, pgd_t *pgd, unsigned long start)
{
pud_t *pud = pud_offset(pgd, );
unsigned long addr;
unsigned i; for (i = ; i < PTRS_PER_PUD; i++, pud++) {
addr = start + i * PUD_SIZE;
if (!pud_none(*pud)) {
walk_pmd(st, pud, addr);
} else {
note_page(st, addr, , pud_val(*pud));
}
}
}
static void walk_pmd(struct pg_state *st, pud_t *pud, unsigned long start)
{
pmd_t *pmd = pmd_offset(pud, );
unsigned long addr;
unsigned i; for (i = ; i < PTRS_PER_PMD; i++, pmd++) {
addr = start + i * PMD_SIZE;
printk("%s: addr: 0x%lx, pmd: 0x%p, pmd[0]: 0x%x, pmd[1]: 0x%x\n",
__func__, addr, pmd, pmd[], pmd[]);
if (pmd_none(*pmd) || pmd_large(*pmd) || !pmd_present(*pmd))
note_page(st, addr, , pmd_val(*pmd));
else
walk_pte(st, pmd, addr); if (SECTION_SIZE < PMD_SIZE && pmd_large(pmd[]))
note_page(st, addr + SECTION_SIZE, , pmd_val(pmd[]));
}
}
static void walk_pte(struct pg_state *st, pmd_t *pmd, unsigned long start)
{
pte_t *pte = pte_offset_kernel(pmd, );
unsigned long addr;
unsigned i; for (i = ; i < PTRS_PER_PTE; i++, pte++) {
addr = start + i * PAGE_SIZE;
printk("-- %s: start: 0x%lx, pte: 0x%p, *pte: 0x%x\n", __func__, addr, pte, pte_val(*pte));
note_page(st, addr, , pte_val(*pte));
}
}
第7行的PTRS_PER_PTE是512。也就是这里遍历了pmd[0]和pmd[1]所指向的二级页表,如果pmd[0]是二级页表的第一级,那么pmd[1]也是二级页表的第一级
static void note_page(struct pg_state *st, unsigned long addr, unsigned level, u64 val)
{
static const char units[] = "KMGTPE";
u64 prot = val & pg_level[level].mask; if (!st->level) {
st->level = level;
st->current_prot = prot;
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
printk("---[ %s ]---\n", st->marker->name);
} else if (prot != st->current_prot || level != st->level ||
addr >= st->marker[].start_address) {
const char *unit = units;
unsigned long delta; if (st->current_prot) {
seq_printf(st->seq, "0x%08lx-0x%08lx ",
st->start_address, addr);
printk("0x%08lx-0x%08lx ",
st->start_address, addr); delta = (addr - st->start_address) >> ;
while (!(delta & ) && unit[]) {
delta >>= ;
unit++;
}
seq_printf(st->seq, "%9lu%c", delta, *unit);
if (pg_level[st->level].bits)
dump_prot(st, pg_level[st->level].bits, pg_level[st->level].num);
seq_printf(st->seq, "\n");
} if (addr >= st->marker[].start_address) {
st->marker++;
seq_printf(st->seq, "---[ %s ]---\n", st->marker->name);
printk("---[ %s ]---\n", st->marker->name);
}
st->start_address = addr;
st->current_prot = prot;
st->level = level;
}
}
static void dump_prot(struct pg_state *st, const struct prot_bits *bits, size_t num)
{
unsigned i; for (i = ; i < num; i++, bits++) {
const char *s; if ((st->current_prot & bits->mask) == bits->val)
s = bits->set;
else
s = bits->clear; if (s)
seq_printf(st->seq, " %s", s);
}
}
查看内核页表kernel_page_tables (aarch32)的更多相关文章
- swapper_pg_dir主内核页表、init和kthreadd、do_fork时新建子进程页表、vmalloc与kmalloc
都是以前看到一个点扯出的很多东西,当时做的总结,有问题欢迎讨论,现在来源难寻,侵删! 1.Init_task.idle.init和kthreadd的区别和联系 idle进程其pid=0,其前身是系统创 ...
- [linux系统]查看内核版本和系统版本方法
查看内核版本信息的两个命令: uname -a cat /proc/version 查看系统版本的命令: lsb_release -a more /etc/issue cat /etc/redhat- ...
- linux查看内核版本、系统版本、系统位数(32or64)
linux查看内核版本.系统版本.系统位数(32or64) 2011-05-01 22:05:12 标签:linux 内核版本 休闲 系统版本 系统位数 1. 查看内核版本命令: 1) [root@ ...
- 在linux下查看内核版本、gcc版本、操作系统多少位等参数
1. 查看linux版本 cat /etc/issue Ubuntu 11.04 \n \l 2. 查看内核版本 1)cat /proc/version Linux version 2.6.38-13 ...
- Linux下查看内核、CPU、内存及各组件版本的命令和方法
Linux下查看内核.CPU.内存及各组件版本的命令和方法 Linux查看内核版本: uname -a more /etc/*release ...
- Ubuntu 中查看内核版本和系统版本的三个命令
一.查看内核版本:cat /proc/version 二.查看内核版本:uname -a 三.查看系统版本:lsb_release -a 四.查看发行版类型:cat /etc/issue
- 使用kprobes查看内核内部信息
前言:使用printk打印变量等方法,是调试内核的有效方法之一,但是这种方法必须重新构建并用新内核启动,调试效率比较低.以内核模块的方式使用kprobes.jprobes,就可以在任意地址插入侦测器, ...
- Linux查看内核和系统版本
1. 查看内核版本命令: 1) [root@q1test01 ~]# cat /proc/version Linux version 2.6.9-22.ELsmp (bhcompile@crowe.d ...
- Linux查看内核信息或系统信息
先说说为什么会写这个.这是我去面试的时候面试官问的一个问题,我感觉是一个普遍会被问到的问题.为了让我自己记住,也便于收集下Linux运维方向考官的题目. 第一,查看内核信息 cat /proc/ver ...
随机推荐
- mysql主键的缺少导致备库hang
最近线上频繁的出现slave延时的情况,经排查发现为用户在删除数据的时候,由于表主键的主键的缺少,同时删除条件没有索引,或或者删除的条件过滤性极差,导致slave出现hang住,严重的影响了生产环境的 ...
- linux:查询软件是否安装以及删除
参考网址:http://blog.sina.com.cn/s/blog_6d59e57d0102x21u.html 查询java是否安装 rpm -qa |grep java 批量卸载所有带有Java ...
- pandas 合并数据
1. pandas 的merge,join 就不说了. 2. 神奇的: concat append 参考: PANDAS 数据合并与重塑(concat篇) 3.
- final在类和方法中的使用
package final0; //final修饰的类不能继承//final修饰的方法不能继承public class TestFinal3 { public static void main(Str ...
- Asp.Net Core WebAPI入门整理(一)
一.Asp.Net Core WebAPI 1.目前版本是v1.1 2.默认路由处理和Asp.Net WebAPI有些 区别了,现在使用的是控制器路由[Route("api/Menu&qu ...
- Simple Web API Server in Golang (2)
In this challenge, I tried to implement a simple OAuth2 server basing on Simple Web API Server in [1 ...
- bzoj [ZJOI2008]生日聚会Party
思路:dp, 用dp[ i ][ j ][ u ][ v ] 表示, 有n个人,其中有j个是男生,后缀区间中男生人数减去女生人数的最大值为u, 女生人数减去男生人数 的最大值为v, 然后就能写出状态转 ...
- 005 RequestMapping_HiddenHttpMethodFilter 过滤器
很郁闷,这个查了很多资料,就是put与delete还是不好用. 但是看了一个文档后解决了,有些感谢这篇文档:http://blog.csdn.net/tiberroot/article/details ...
- 022 StringTokenizer替换掉String的操作
一:说明 1.说明 String的操作特别消耗内存,所以可以考虑优化. 二:程序 1.程序修改 这部分程序属于Mapper端的程序,稍微优化一下. 2.程序 //Mapper public stati ...
- wdatepicker默认时间为当前时间
$(document).ready(function() { alert(today()); document.getElementById("serviceTime").valu ...