1

So i always thought MMU is part of the unix kernel that translates addresses to physical addresses but in the MMU wiki page it says its a computer hardware that usually have its own memory, but that page doesn't talk much about Unix/Linux operating systems

So I'm confused, does the all the translation happen in hardware and kernel doesn't do any translation? and basically the operating system doesn't know anything about the real physical address?

I'm asking about Unix based operating systems, but if you know about other operating systems as well like windows or if its a general thing in modern computers let me know, thanks.

4

The MMU (memory management unit) is a physical component of the computer system, typically part of the CPU (but not necessarily). It translates virtual addresses (also known as linear addresses in the x86 world) to physical addresses; it can also enforce memory access control, cache control, and bus arbitration. It doesn’t usually have its own memory, it relies on data in the system’s main memory to operate.

The MMU performs this translation by using information stored in data structures such as page tables; these specify which physical address ranges correspond to linear address ranges (if any — a page can be “not present”). The page tables are set up by the kernel, and the kernel determines what the mappings should be — so the ultimate authority on physical addresses is the kernel, however it always operates with the help of the MMU. Put another way, the CPU always operates on linear addresses, which are translated to physical addresses by the MMU, but the kernel is aware of the translations and programs the MMU to perform them.

User-space processes are oblivious to all this and aren’t (normally) aware of the physical addresses corresponding to the linear addresses they use, and typically can’t access the mappings either. There are some cases where physical mappings leak, but those are usually considered to be security vulnerabilities and quickly addressed. However, in Linux, processes with sufficient privileges can see their physical map in /proc/<pid>/pagemap.

For Linux specifically, see the memory management documentation, and in particular the section on examining page tables.

  • So which functions in Unix/Linux are used to access page table of a specific process? and can other processes access this or part of this page table with system calls? side question: Unix/Linux uses multi level page tables right? – John P Oct 4 '18 at 15:50
  • @John “which functions”, at what level? In the kernel? – Stephen Kitt Oct 4 '18 at 15:59
  • Yes, Linux uses multi-level page tables; see How does the CPU knows which physical address is mapped to which virtual address? (which I need to update to take into account four- and five-level page tables). – Stephen Kitt Oct 4 '18 at 16:00
  • Yes at the kernel level, Doesn't the kernel have some sort of function where it gives the PID of that process as input and returns the starting physical address of the page table? if so, can a process access his own page table using a system call? – John P Oct 4 '18 at 16:48
2

The Memory Management Unit (MMU) is a piece of hardware that translates virtual addresses to physical addresses. For example, when the CPU emits an address to read, the MMU translates that virtual address to a physical address and then emits the physical address to the memory bus.

The MMU is programmed by the operating system. The operating system manages memory (both physical and virtual) and manages the virtual-to-physical mapping.

  • so operating systems have access to MMU and page tables to see physical address of pages right? if so, which kernel function can map the virtual addresses to physical or give us the page table? and can normal processes somehow use this by using syscalls? thanks – John P Oct 4 '18 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.