ARM Linux 页表条目格式——未使用的位? [英] ARM Linux Page Table Entry format -- unused bits?
问题描述
我需要使用 PTE 的两位来存储我的内核模块在拦截页面保护错误时将使用的自定义状态"值.
I need to use two bits of the PTE to store a custom "state" value that my kernel module will use when intercepting page protection faults.
我正在开发具有 ARM Cortex A9(我相信是 ARM v7)的 Galaxy Nexus.Linux 内核版本 3.0.31.Linux PTE定义如下(来自arch/arm/include/asm/pgtable.h
:
I am developing on a Galaxy Nexus which has an ARM Cortex A9 (ARM v7, I believe). Linux kernel version 3.0.31. The Linux PTE definitions are as follows (from arch/arm/include/asm/pgtable.h
:
/*
* "Linux" PTE definitions.
*
* We keep two sets of PTEs - the hardware and the linux version.
* This allows greater flexibility in the way we map the Linux bits
* onto the hardware tables, and allows us to have YOUNG and DIRTY
* bits.
*
* The PTE table pointer refers to the hardware entries; the "Linux"
* entries are stored 1024 bytes below.
*/
#define L_PTE_PRESENT (_AT(pteval_t, 1) << 0)
#define L_PTE_YOUNG (_AT(pteval_t, 1) << 1)
#define L_PTE_FILE (_AT(pteval_t, 1) << 2) /* only when !PRESENT */
#define L_PTE_DIRTY (_AT(pteval_t, 1) << 6)
#define L_PTE_RDONLY (_AT(pteval_t, 1) << 7)
#define L_PTE_USER (_AT(pteval_t, 1) << 8)
#define L_PTE_XN (_AT(pteval_t, 1) << 9)
#define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
仅通过查看此定义列表,似乎第 3、4、5 位以及第 11 位及更高位可用.但是,我知道 20 个最高有效位 [31:12] 用于页码(PFN,我相信),所以我不能使用其中任何一个.
Just by looking at this list of definitions, it appears that bits 3,4,5 are available, as well as bits 11 and up. However, I know that the 20 most significant bits [31:12] are used for the page number (PFN, I believe), so I can't use any of those.
我可以自由使用位 [5:3] 还是会产生问题?我花了几个小时寻找这个问题的答案,但我只能找到关于 Linux 如何使用 PTE 位的文档x86 架构.
Can I freely use bits [5:3] or will that create problems? I've spent hours searching for the answer to this but I can only find documentation on how Linux uses PTE bits for x86 architecture.
我已经编制了一份我认为每个 PTE 位的列表.
I have compiled a list of what I believe each PTE bit to be.
bit 0 PRESENT
bit 1 YOUNG
bit 2 MEMORY TYPES 0 B FILE (only when not PRESENT)
bit 3 MEMORY TYPES 1 C
bit 4 AP0
bit 5 AP1
bit 6 DIRTY
bit 7 RD_ONLY
bit 8 USER
bit 9 XN
bit 10 SHARED
bit 11 EXT_NG (no idea what this is)
bit 12 |---|
... |PFN|
bit 31 |---|
不幸的是,我没有看到指定无读或写权限的方法,但不知何故mmap
和PROT_NONE
似乎仍然有效.我知道如何指定读取或 R/W 权限,但我仍然需要知道如何将页面设置为没有权限.
Unfortunately I don't see a way to specify no read or write permissions, but somehow mmap
with PROT_NONE
still seems to work. I know how to specify read or R/W permissions, but I still need to know how to set a page to have no permissions.
推荐答案
你可以尝试清除 pte 中的当前位,这样会导致页面错误吗?
You can try to clear the present bit in the pte, will that force a page fault?
这篇关于ARM Linux 页表条目格式——未使用的位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!