logo

MMU vs IOMMU

To understand the difference between an MMU and an IOMMU, you first have to understand that they both do the exact same job: they act as translators and gatekeepers for memory.

The only difference is who they are working for. The MMU works for the CPU, while the IOMMU works for Peripheral Devices (like your GPU, Network Card, or Disk Controller).

MMU (Memory Management Unit)

The MMU is a hardware component inside the CPU. It sits between the software (the programs you run) and the physical RAM.

  • The Problem: In modern computing, we run many programs at once. If every program tried to access the physical RAM directly, they would overwrite each other’s data and crash the system.
  • The MMU’s Job (Virtual Memory): The MMU gives every program its own "Virtual Address Space." A program thinks it has access to a huge, continuous block of memory starting at address zero.
  • Translation: When the program asks to read "Virtual Address 500," the MMU looks at a "Page Table" and translates that to the actual "Physical Address" (e.g., Physical Slot 8,422,100).
  • Protection: Because the MMU handles the translation, it can block a program from accessing memory that doesn't belong to it. This is why one crashing app doesn't take down your whole computer.

IOMMU (Input-Output Memory Management Unit)

The IOMMU (sometimes called VT-d by Intel or AMD-Vi by AMD) sits between the I/O bus (where hardware devices connect) and the physical RAM.

  • The Problem: Many hardware devices use DMA (Direct Memory Access). This allows a device (like a high-speed Network Card) to write data directly into the RAM without bothering the CPU. However, this is dangerous. Without a "manager," a buggy or malicious device could write data over critical OS memory.
  • The IOMMU’s Job (Device Isolation): The IOMMU does for hardware exactly what the MMU does for software. It intercepts memory access requests from hardware devices.
  • Translation: It translates the device’s "bus address" into a physical RAM address.
  • Protection: It ensures that a device can only see and modify the specific chunk of RAM that the OS has explicitly assigned to it.

To check if IOMMU is enabled:

sudo dmesg | grep -e DMAR -e IOMMU

If you see a message like "DMAR: Scalable mode is disallowed", it indicates that the system is defaulting to a standard, legacy memory management mode rather than the newer Scalable Mode defined in the VT-d 3.0 specification.

Key Comparison Table

Feature MMU (Memory Management Unit) IOMMU (I/O Memory Management Unit)
Who it manages Software (Applications/Processes) Hardware (GPUs, NICs, USB controllers)
Location Inside the CPU On the Motherboard/Chipset
Main Goal Provides Virtual Memory for apps. Provides isolation for hardware devices.
Translation Virtual Address \to Physical Address Device Address \to Physical Address
Security Role Prevents apps from spying on each other. Prevents hardware from spying on the OS.

Why do we need both?

The MMU is for Multitasking

Without an MMU, you couldn't run Spotify, a Web Browser, and a Word document at the same time safely. The MMU is what allows an operating system to manage multiple "isolated" processes.

The IOMMU is for Virtualization and Security

The IOMMU became famous because of Virtual Machines (VMs).

  • GPU Passthrough: If you want a Virtual Machine to use your "real" graphics card at full speed, you use the IOMMU. It allows the VM to control the hardware directly while ensuring that the hardware can't "break out" of the VM and access the host computer's memory.
  • Hardware Security: If you plug in a malicious USB device that tries to steal your encryption keys from RAM (a DMA attack), the IOMMU sees that the USB device isn't authorized to look at those memory addresses and blocks the request.