Questions tagged [page-tables]
A page table is a data structure used by the virtual memory in the operating system to store the mapping between virtual addresses and physical addresses.
237
questions
0
votes
1
answer
19
views
Am I reading the virtual addresses correctly?
I have been given a page table for a system with 12-bit virtual ad physical addresses and 256-byte pages.
Say I am given an virtual address (in hexadecimal) that reads 0x3E5.
Am I reading this ...
1
vote
0
answers
28
views
3rd level page table indirection source code differs from assembly in x86 Linux Kernel
I'm using 4 levels page table (LA57 disabled) and tried to understand the implementation of getting virtual address of the 3rd level page. But encountered difference between source code and it's ...
0
votes
1
answer
28
views
Getting size of the page table for a system with a tiny amount of memory, only a few total pages
I'm asked to make a Page Table inside Memory under these conditions.
We have 16 bits Virtual Address
Memory size is 512 words
page size is 128 Bytes
So I tried doing this :
2^16 / 2^7 = 2^9 Pages
...
0
votes
0
answers
31
views
How does supervisor mode address translation get done? [duplicate]
Intel System Programming manual vol. 3 clearly documents that 4-level paging uses the first 48 bits of the virtual address to get the actual physical address.
When connecting to the Linux Kernel with ...
0
votes
0
answers
34
views
How can i access the page table of a process from kernel using a custom syscall?
I am using Ubuntu 16.04, kernel: 4.17.4
I want to access the page table of a process. The idea is, inside a c code I will call a custom Syscall and the syscall will be able to access the page table of ...
0
votes
0
answers
24
views
How can i access the page table of a process using a custom syscall?
I am using Ubuntu 16.04, kernel: 4.17.4
I want to access the page table of a process. The idea is, inside a c code I will call a custom Syscall and the syscall will be able to access the page table of ...
0
votes
0
answers
30
views
swapper_pg_dir in kernel page table bootstrapping
I am going through the book "Understanding the Linux Virtual Memory Management" by Gorman, and this section of Kernel Page Table really confuses me.
He says that an array called ...
0
votes
0
answers
16
views
Calculating number of page table entries given bits of virtual & physical memory addresses & each virtual page?
Is there any sort of formula to calculate the number of page table entries if I am given:
number of bits in address of virutal memory
number of bits in address of physical memory
size of each virtual ...
1
vote
1
answer
110
views
Why 4-level paging can only cover 64 TiB of physical address
There are the words in linux/Documentation/x86/x86_64/5level-paging.rst
Original x86-64 was limited by 4-level paging to 256 TiB of virtual address space and 64 TiB of physical address space.
I know ...
0
votes
0
answers
42
views
Mapping virtual pages from different page directories to the same physical page
I'm working on a kernel for i386 and want to do the following:
Write data to a virtual 4MB page in the current page directory ("current" as in it's loaded to cr3).
Make a separate page ...
0
votes
1
answer
52
views
How does linux implement PROT_NONE mode of mprotect on x64 platform?
The method mprotect have a PROT_NONE option to disable memory access. It means "The memory cannot be accessed at all"
I wonder how it is implemented on x86/x64 platform.
According to the ...
0
votes
1
answer
56
views
Page table look-up vs TLB look-up
From https://cs.stackexchange.com/questions/119744/how-does-a-tlb-lookup-compare-all-keys-simultaneously and https://en.wikipedia.org/wiki/Content-addressable_memory, look-up a key in TLB could be ...
3
votes
0
answers
43
views
How to update the PMD and PTE tables of page-table by allocating or relocating memory?
I have a requirement of forcing the PTE and PMD levels of the page-table to be updated or in other words, to make the process frequently hold the PMD and PTE locks. This is for research purposes.
I ...
0
votes
1
answer
46
views
x86 address space calculation PAE to 36 bits
I'm having some hard time understanding PAE. I know it creates a 3rd level of indirection via the PDPT, so that the address translation goes from CR3 -> PDPT(4 entries) -> PD(512 entries) -> ...
0
votes
0
answers
42
views
The reset of page table [duplicate]
In arch/arm/kernel/head.S,I found following code
__create_page_tables:
pgtbl r4, r8
mov r0, r4
mov r3, #0
add r6, r0, #PG_DIR_SIZE
1: str r3, [r0], #4
str r3, [r0], #4
...
1
vote
1
answer
66
views
Does virt_to_pfn checks whether the page table exists or not
Does virt_to_pfn checks whether the page table is present or not. Below is the code which is failing with page fault.
#include <linux/module.h>
#define address 0xf0000000
int init_module(void)
{...
1
vote
0
answers
140
views
How to know if a page table entry has been modified in XV6?
I'm trying to implement On Demand paging with NRU (not recently used) algorithm.
It picks a page table entry based on two factors:
If it has been referenced recently.
If it has been modified at all.
...
1
vote
1
answer
356
views
How to loop through all page table entries of a process in xv6?
I'm trying to loop through all pages for a process in xv6.
I've looked at this diagram to understand how it works:
but my code is getting:
unexpected trap 14 from cpu 0 eip 801045ff (cr2=0xdfbb000)
...
2
votes
1
answer
151
views
Splitting kernel huge page (THP) returned by alloc_pages()
I am looking for a way to split the kernel's huge page (2MiB) mappings into the smaller (4KiB) page table entries. So far, I only encountered the function set_memory_4k, which only works during the ...
3
votes
1
answer
111
views
Dirty page accounting in Linux kernel through /proc/$PID/smaps
TL;DR: how exactly is the kernel able to do dirty page accounting in /proc/$PID/smaps?
Consider the following program statement in C:
static char page1[PAGE_SIZE] __attribute__ ((aligned (PAGE_SIZE)));...
1
vote
1
answer
83
views
Does a page table entry only contain metadata?
I'm trying to understand how OS does the swapping between the disk and RAM when a page fault occurs. For instance, assume the page table of a process is full and a swap needs to happen.
Does the frame ...
1
vote
1
answer
104
views
Understanding Page Tables in Linux/seL4
Why are entries in the Page Global Directory offset? What is the significance of the offset, if any?
Page Global Directory
Address
Entry 1
Entry 2
0000000080036000:
0x0000000000000000
...
0
votes
0
answers
32
views
How to move page table of a process to another NUMA node?
I'm looking for a way to move the page table of a process to an arbitrary NUMA node. There are some ways to move the process or the memory related to it, but I couldn't find a way to migrate the ...
0
votes
0
answers
24
views
Why is the tag bit needed in the TLB structure?
In cache memory, I understood that multiple address values have one cache value, and a tag bit is needed to distinguish these addresses.
But why is tag bit needed in TLB? Is it because multiple ...
0
votes
1
answer
48
views
Why there is no pagetable_init in init_64.c of linux kernel
I am currently learning the kernel page table initialization process in Linux. As I am reading the codes, I found out that there is a function pagetable_init() in init_32() to initialize the kernel ...
2
votes
1
answer
218
views
What is in the PTE address field for an anonymously zero-fill-on-demand mapped page?
When a program calls mmap to allocate an anonymous page, also known as a demand-zero page, what appears in the address field of the corresponding page table entry (PTE)? I am assuming that the kernel ...
0
votes
1
answer
198
views
Operating Systems: Page table on context switch
I have a question: if a context switch occurs, why the page table of the new process has to be reloaded?
0
votes
1
answer
81
views
Get address of object cast to arithmetic type at compile time
I'm trying to implement x86 page tables/page directories in C++ and I would like to be able to construct these at compile time. In order to do this I need to be able to obtain the address of static ...
0
votes
0
answers
38
views
Resident vs non-resident page in page table
In virtual memory management, what differentiates a resident from a non-resident page in a page table, i.e. what does page residency mean?
0
votes
1
answer
108
views
Hardware support for valid / invalid bit in page table
While reading about demand paging, I can see it mentioned in several sources (e.g. http://www.expertsmind.com/questions/name-the-hardware-to-support-demand-paging-30176232.aspx) that we need hardware ...
0
votes
0
answers
36
views
Minimum Page Table Size for Process?
I was learning about Page Table and Virtual Memory, My professor showed the following image:
and asked what's the minimum size for the page table where L1=L2=256
I answered it's 256 since L1 is ...
0
votes
0
answers
43
views
How do I register nonconsecutive pages in i386 paging directory?
I'm trying to write a simple OS with context switching, including mapping a separate virtual address space for each process (eg. each process gets its own page directory). If say a process's data ...
0
votes
0
answers
130
views
When is the user process's page table first updated during the program start stage
I am recently studying Linux kernel and I have a question regarding how user process's page table is first updated by the kernel. Let's consider X86 architecture as an example.
When a binary is first ...
1
vote
1
answer
231
views
linear address space x86 - bits segmentation calculation
I have a problem which I am not sure how to solve correctly based on the final answer I have.
Given that :
Page Size is 4KB (2^12).
Virtual address space is 32 bit.
Physical memory size is 16TB (2^...
1
vote
1
answer
80
views
Updating the PTE bits from multiple cores - how do they avoid stepping on each other?
I've got a question regarding an SMP system with multiple threads belonging to the same process:
Do all these threads share a single page-tree and the accessed and dirty bits of the PTEs in the tree ...
0
votes
1
answer
121
views
Why are my page tables not mapping the right physical addresses?
I am writing a small x86-64 kernel booted with UEFI. I think there is something I overlook in the code and I can't figure out what it is. I am trying to page the xHCI BAR in my higher half kernel. I'...
0
votes
1
answer
139
views
Why does QEMU return the wrong addresses when filling the higher half of the PML4?
I'm writing a small x86-64 OS I boot with UEFI. I am trying to make the kernel a higher half kernel by shifting the executable of the kernel to 0x800000000000. This address should be halfway through ...
1
vote
0
answers
45
views
How do I find the base address of a Translation Table for initial lookup?
I'm working on code that is able to perform at Stage 1 Address Translation at EL2 in an AArch64-based system.
According to the documentation I need to store the base address of the first level of the ...
1
vote
0
answers
65
views
Reference bit synchronization for TLB and page table
If a PTE is in the TLB, then in the page table, it is not recently accessed, does that mean when NRU replacement policy is used, it is very likely for this PTE to be replaced? Or is there any kind of ...
0
votes
1
answer
87
views
Does every Process have its own Page directory?
(In 2-Level Paging)
If so: Does every process have multiple Page Tables?
If not: How is it ensured that a process doesn't point to a Page Directory Entry from a different process?
1
vote
1
answer
42
views
Virtual Memory To Physical Translation?
My book had the following image:
And a question of how many PTE's are there in L2 (or L1), the answer was 16 = 2^4 but why is that?
In the question it's given that each PTE size is 2 bytes so the ...
1
vote
1
answer
90
views
How to determine instruction fetches are allowed or not by page table and EPT in x86-64?
Format of a Page-Table Entry that Maps a 4-KByte Page
Bit
Format of an EPT Page-Table Entry that Maps a 4-KByte Page
Bit
It seems EPT.bit2 and EPT.bit10 are used to determine whether instruction ...
-1
votes
1
answer
63
views
calculating page table levels requires to support x virtual address bits
I am trying to calculate the number of page table levels that are required to support 35 virtual address bits.
The input is giving me:
The paging unit uses 16B page descriptors and page size is 2KiB. ...
1
vote
1
answer
399
views
The size of a Page Table entry
Is the size of a Page Table Entry is dependent on the total size of the logical / virtual memory space of a process?
3
votes
2
answers
229
views
How to switch from 32-bit to PAE paging directly?
I'm developing a microkernel for my personal research. I have chosen to run my kernel at 0xf0000000, leaving 3.75 GiB for user space programs. When my kernel starts up, it sets up 32-bit paging (with ...
3
votes
1
answer
69
views
How do AMD64 page entry base address fields encode a 52-bit address in 40 bits?
I'm trying to manually walk the paging structures in order to convert a virtual address into its physical address. I have a question about the physical base address fields stored in the PML4E, PDPE, ...
1
vote
1
answer
651
views
What is paging exactly? OSDEV
I am trying to write my own operating system and I came to the point where I need to set up paging. I wrote some code that seems to be working but I realized I don't understand how paging works. Now I'...
0
votes
1
answer
895
views
Valid Bit and Dirty Bit in page tables
Is there any reason that the Valid-Bit in a page table would ever be turned off (set to invalid)? Also when working with the dirty bit, I know that the dirty bit is supposed to be set whenever there ...
0
votes
1
answer
85
views
modify page table read/write bits to modify system call table
I want to modify the address of the __NR_fork entry is the system call table
So i will make something like: sys_call_table_addr[__NR_fork] = newaddress;
But I want to change the read/write bits in the ...
1
vote
0
answers
273
views
Do kernel threads have their own page table in Linux?
User-space processes have their own page table created by the kernel.
I understood that kernel threads do not create virtual memory space for them. I have two questions:
Do kernel threads have their ...