For Kernel_Newbies By a Kernel_Newbie
Memory, by allocating a PTE pointer (the PMD is folded into a PGD in 32
bit.)which can in turn hold 1024 Pages,as it has space to accomodate 1024
entries.(Each entry,containing a page.) Hence with each PGD entry holding 4 MB (
1 << 22 ) of address space,(a.k.a PGDIR_SIZE), you touch the upper limit
of 4 GB with 1024 PGD entries. Now let us look at how a Processor actually
converts a 32 Bit Virtual Address into a Physical Address.As I have said
before,the Processor has the PGD pointer changed to the corresponding tasks PGD
pointer during a switch_mm call in schedule. Now it remains to be seen,as to how
the processor resolves the 32 bit address into a physical one. This will be
illustrated on viewing the definitions of the pgd_offset, pmd_offset, and
pte_offset macros, in include/asm/pgtable.Also try looking at the various Page
Table headers,like page.h,pgtable-2level.h for INTEL. The processor takes the
last 10 bits (obvious as you can have 1024 or 1 << 10 pgdir entries) of a
32 bit Virt. address,to index into the page directory entry. It then
dereferences the value at that entry, (which is a PTE pointer,as the PMD is
folded for 32 Bit.) and uses that as a pointer to a page table entry to index
into the Page table entry which contains the physical page address.It takes 10
bits from Bit #: 12 through Bit #: 22 ,leaving room for a 1 page offset.This way
it obtains the physical page address. Example: Bit equivalent:
PGD 10 bits PTE 10 BITS (PMD folded in 32 bit)
0000 0000 00 00 1000 0000 1100 0000 1111 -> (0x00080c0f)
pgd index(0) pte_index(1 << 7 , pmd is folded to pgd)
I hope the translation is clear now. Before we go on to copy_on_write pages
(COW pages), page_faults, etc,let us have a look at the virtual abstraction of
the physical space. Each process has a Virtual Memory area,which is represented
by the vm_area_struct structure.A process can have many such virtual memory
areas,sorted out by address. For example, a text segment of a process would be
constituting a virtual memory area, a data segment will constitute another,and
mapped segments would constitute another,and so on. The Virtual Address bounds
of a Process cannot exceed 3 GB (TASK_SIZE),as from then on,its into Kernel
Space, which is at offset __PAGE_OFFSET ( 3 GB in virtual memory, and has an
identity mapping with the physical memory, as represented by the swapper_pg_dir
- « first
- ‹ previous
- of 24
- next ›
- last »