Hello, my name is Duck.
Continuing from the previous article, we will continue with the MMU's function of memory translation.
We will look at what address translation is and what is good about having an MMU.
Basics of Address Translation
Let's start with a simple mechanism. Address translation requires a table (Page table) that contrasts before and after translation.
The MMU has a buffer called TLB ( translation lookaside buffer ) in which the page table is stored, and the MMU refers to the TLB to translate memory.
Conversion Method
Let's look at this in more detail. As an example, let's say we want to convert a 32-bit address.
The virtual address is divided into upper bits (virtual page number) and lower bits (intra-page offset).
The upper bits of the physical page address matching the virtual page number are called. The lower bits are used without conversion.
The data of the converted physical address is accessed.
The respective bit widths vary depending on the device and system settings.
Memory Protection
In fact, there is one more advantage of MMU. It is the protection function.
This function prevents data from being read or written to the wrong memory area.
If Program B is running and you try to access Program A's memory by mistake, the MMU will throw an exception.
The TLBs are replaced for each program, and the MMU detects and informs the CPU if an address translation is attempted in the wrong area by preparing a page list of only the range of pages used by the current program.
The protection function is usually not used for each detailed program, but is mainly used to separate the kernel area used by the OS and other user areas.
This is to prevent the memory used by the OS from being accidentally rewritten.
There are also MPUs (memory protection units) with independent memory protection functions.
A few things to keep in mind +α
In fact, the TLB does not have a memory large enough to cover all address translations in a program.
Therefore, exceptions without a TLB match (page faults) can occur even within the same program.
Therefore, the program must be designed to handle page faults differently depending on the cause of the fault.
Duck's "Also Active in SoCs! What is the Role of the MMU? Series
The MMU is indispensable for advanced embedded systems!
What is an MMU? What is Address Space? First, let's start with the basics of address translation!
Explanation of the actual address translation mechanism using TLB!
New Engineer's Blush Blog Article List