linux pte,PTE structure in the linux kernel

问题

I have been trying to look around in the linux source code for a structure/union that'd correspond to the PTE on x86 system with PAE disabled. So far I've found only the following in arch/x86/include/asm/page_32.h

typedef union {

pteval_t pte;

pteval_t pte_low;

} pte_t;

I'm a bit confused right now since I have the Intel Reference Manual Vol 3A open in front of me and nothing in that union corresponds to the dozen odd fields present in the PTE as the manual explains.

This might be a trivial question but for me it has become more like a stumbling block in the process of understanding memory management in the linux kernel.

EDIT: I have the 2.6.29 source with me

回答1:

The pteval_t just treats the page table entry as an opaque blob - on the architecture you're looking at, it's just a 32 bit unsigned value.

The fields within the PTE are accessed using bitwise operators and masks - in the source I have handy (Linux 2.6.24), these are defined in include/asm-x86/pgtable_32.h. The fields you see in the Intel Reference Manual (most of which are single-bit flags) are defined here - for example:

#define _PAGE_PRESENT 0x001

#define _PAGE_RW 0x002

#define _PAGE_USER 0x004

#define _PAGE_PWT 0x008

#define _PAGE_PCD 0x010

#define _PAGE_ACCESSED 0x020

#define _PAGE_DIRTY 0x040

#define _PAGE_PSE 0x080 /* 4 MB (or 2MB) page, Pentium+, if present.. */

#define _PAGE_GLOBAL 0x100 /* Global TLB entry PPro+ */

#define _PAGE_UNUSED1 0x200 /* available for programmer */

#define _PAGE_UNUSED2 0x400

#define _PAGE_UNUSED3 0x800

回答2:

I would recommend buying Understanding the Linux Kernel from O'REILLY, as well as Linux Device Drivers. And subscribing to LWN.net; though you can get a pretty good start from their kernel index page even without a subscription.

For the memory management, look on the index page for the "Memory management" section... and the "Large-memory systems" section. The latter has a few articles that talk about the move to four-level page tables that should be helpful in understanding this area of the code.

来源:https://stackoverflow.com/questions/1441353/pte-structure-in-the-linux-kernel

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值