博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ARM32 Linux kernel virtual address space
阅读量:4482 次
发布时间:2019-06-08

本文共 2776 字,大约阅读时间需要 9 分钟。

 http://thinkiii.blogspot.jp/2014/02/arm32-linux-kernel-virtual-address-space.html

 
The 32-bit ARM CPU can address up to 2^32 = 4GB address*. It's not big enough in present days, since the size of available DRAM on computing devices is growing fast and the memory usage of application is growing as well.
In Linux kernel implementation, user space and kernel must coexist in the same 4GB virtual address space. It means both user space and kernel can use less than 4GB virtual address space. 
Linux kernel provides 3 different split of virtual address spaces: VMSPLIT_3G, VMSPLIT_2G, VMSPLIT_1G.

 

Linux virtual address space options
 The default configuration is VMSPLIT_3G, as you can see, kernel space starts from 0xC0000000 to 0xFFFFFFFF and user space starts from 0x00000000 to 0xC0000000.
Let's take a closer look of the VMSPLIT_3G mapping:
 
kernel space
We can observe the kernel virtual address by checking the boot log (dmesg) or take a look at arch/arm/mm/init.c.
lowmem: The memory that have 1-to-1 mapping between virtual and physical address. It means the virtual and physical address are both configuous, and this good property makes the virtual to physical address translation very easy. If we have a virtual address from lowmem, we can find out its physical address by simple shift. (see __pa() and __va()).
vmalloc: The vmalloc memory is only virtually contiguous.
fixmap/pkmap: create fast mapping of a single page for kernel. Most used in file system.
modules: The virtual address for module loading and executing. kernel modules are loaded into this part of virtual memory.
user space
The code for deterring user space virtual address is in arch/arm/mm/mmap.c
The user space have two different kind of mmap layout: legacy and non-legacy. Legacy layout sets the base of mmap(TASK_UNMAPPED_BASE) and the mmap grows in bottom-up manner; on the other case, non-legacy set the mmap base from TASK_SIZE - 128MB with some random shift for security reasons).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void
arch_pick_mmap_layout(
struct
mm_struct *mm)
{
        
unsigned
long
random_factor = 0UL;
 
        
/* 8 bits of randomness in 20 address space bits */
        
if
((current->flags & PF_RANDOMIZE) &&
            
!(current->personality & ADDR_NO_RANDOMIZE))
                
random_factor = (get_random_int() % (1 << 8)) << PAGE_SHIFT;
        
if
(mmap_is_legacy()) {
                
mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
                
mm->get_unmapped_area = arch_get_unmapped_area;
        
}
else
{
                
mm->mmap_base = mmap_base(random_factor);
                
mm->get_unmapped_area = arch_get_unmapped_area_topdown;
        
}
The user space virtual address layout looks like:

 

32-bit user virtual address space layout
*ARM has LPAE (Large Physical Address Extension) mode that can address up to 1TB.
 

转载于:https://www.cnblogs.com/zengkefu/p/6783466.html

你可能感兴趣的文章
006——修改tomacat的编码
查看>>
《C程序设计语言》笔记 (八) UNIX系统接口
查看>>
git常用命令
查看>>
Android必知必会-获取视频文件的截图、缩略图
查看>>
(转)理解Bitblt、StretchBlt与SetDIBitsToDevice、StretchDibits
查看>>
ViurtualBox配置虚拟机Linux的网络环境
查看>>
VLC 媒体播放器
查看>>
\n ^ \t的使用
查看>>
css盒模型
查看>>
探索式测试:测试自动化
查看>>
make install fping
查看>>
面试笔试题
查看>>
MySql可视化工具MySQL Workbench使用教程
查看>>
个人站立会议第二阶段07
查看>>
云时代架构阅读笔记五——Web应用安全
查看>>
IOS 单击手势和cell点击冲突
查看>>
学习_HTML5_day3
查看>>
计算机网络与应用第二次笔记
查看>>
Django之ORM查询
查看>>
学习python第七天
查看>>