kernelmmufuchsia

What is a PMM arena in the context of MMU in a kernel (zircon/fuchsia)


I'm trying to understand how the Zircon's (Fuchsia OS kernel) allocs page in ARM64, so I found mmu.cpp https://fuchsia.googlesource.com/fuchsia/+/4277d3203daa0fc5e4dd1625cf96891dd9882f44/zircon/kernel/arch/arm64/mmu.cc#328

But it simply does:

  if (likely(!test_page_alloc_func_)) {
    status = pmm_alloc_page(0, &page, paddrp);
  }

where pmm_alloc_page is from here: https://fuchsia.googlesource.com/fuchsia/+/4277d3203daa0fc5e4dd1625cf96891dd9882f44/zircon/kernel/vm/pmm.cc#61

Where a pmm node, defined here: https://fuchsia.googlesource.com/fuchsia/+/4277d3203daa0fc5e4dd1625cf96891dd9882f44/zircon/kernel/vm/pmm_node.h says:

// per numa node collection of pmm arenas and worker threads
class PmmNode {

I couldn't find what a PMM area is on google neither on Fuchsia documentation. Can somebody clarify to me these concepts?

I'd like to understand how MMU is handled in ARM64 on Zircon kernel


Solution

  • The PMM Arenas describe regions of contiguous physical memory. You need to somehow know which physical pages you have available to use, as some ranges might be reserved for BIOS memory for example.

    This information is passed by the bootloader to Zircon via the ZBI (Zircon Boot Image). From there, you can see how the arenas are initialized in mem_arena_init.

    The PMM is only used to handle out physical memory. There's a freelist of physical pages that are available, and you use it with the pmm_alloc and pmm_free functions. There's also an API to get contiguous ranges of physical memory, aligned to certain boundaries (useful for drivers).