查看内核页表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 ...
随机推荐
- 在Docker中运行EOS(MAC版)
在Docker中运行EOS(MAC版) 在Docker中也可以简单快速的构建EOS.IO.笔者在Mac平台下参考官方文档躺了一次河.记录如下: 安装依赖 Docker 版本 17.05或者更高 tes ...
- webRTC视频通话,https协议,录制端和播放端
最近做视频直播模块,在网上也看到很多大神写的代码,写的都不错,但不是我想要的,有的可能比较老,不支持https协议,有的又将直播端和显示端放在一个程序中,不利于我使用,则本篇着重添加了https协议( ...
- Kafka 集群配置SASL+ACL
一.简介 在Kafka0.9版本之前,Kafka集群时没有安全机制的.Kafka Client应用可以通过连接Zookeeper地址,例如zk1:2181:zk2:2181,zk3:2181等.来获取 ...
- centos redis 自动重启
配置init脚本 对于Centos,有一份https://gist.github.com/1335694 经过修改,如下: ########################## PATH=/usr/l ...
- HDU 4348 To the moon(主席树区间修改)
题意 给你一个区间,支持如下操作: 在一段区间内加上一个值,并生成一个历史版本 查询某个版本下一段区间内的和 回到一个历史版本上并舍弃之后的版本 做法 这就是主席树区间修改裸题啦QwQ 上一篇博客我讲 ...
- PHP 导出简单文本内容(word txt等)
PHP导出word文件,简单拓展可导出其他文本类文件 /** * PHP 导出简单文本内容(word txt等) * @param $content mixed 导出内容 (文本string / ht ...
- 014 再次整理关于hadoop中yarn的原理及运行
一:对yarn的理解 1.关于yarn的组成 大约分成主要的四个. Resourcemanager,Nodemanager,Applicationmaster,container 2.Resource ...
- 怎么去除移动端点击a标签链接时的背景色
在手机端点击链接时会发现有一个背景色,有时候需要改变这个颜色,或者去除这个颜色,有时候a标签做成按钮时这个颜色的存在会很丑,像这样: 可以通过 -webkit-tap-highlight-color: ...
- MIT-6.828-JOS-lab5:File system, Spawn and Shell
Lab 5: File system, Spawn and Shell tags: mit-6.828 os 概述 本lab将实现JOS的文件系统,只要包括如下四部分: 引入一个文件系统进程(FS进程 ...
- 多线程学习笔记三之ReentrantLock与AQS实现分析
目录 简介 AQS同步状态 AQS同步队列 ReentrantLock数据结构 公平锁的获取 tryAcquire(arg) addWaiter(Node mode) acquireQueued(fi ...