ZXFoundation™ 26h2
Loading...
Searching...
No Matches
core.cxx File Reference

MMU engine implementation — DAT table walk/map internals. More...

import arch.s390x.mmu.types;
import zxfoundation.memory.pmm.types;
import std;
import arch.s390x.mmu.consts;
import arch.s390x.cpu.ctlreg;
import zxfoundation.base.types;
import arch.s390x.mmu.tlb;
import zxfoundation.memory.pmm;
import arch.s390x.cpu.psw;
import zxfoundation.memory.hhdm;
import arch.s390x.cpu.features;
import zxfoundation.base.transaction;
import lib.error;
Include dependency graph for core.cxx:

Data Structures

struct  arch::s390x::mmu::detail::alloc_record
 Record of one intermediate table allocated during a walk. More...
struct  arch::s390x::mmu::detail::alloc_stack
 Stack of allocations made during a single map_page walk. Maximum depth: 4 (R2, R3, Seg, PTE from an R1 root). More...
struct  arch::s390x::mmu::detail::level_state
 Per-level state captured during Phase 1. More...

Functions

auto arch::s390x::mmu::detail::alloc_table_with_policy (dat_level lvl, const pmm::allocation_request &policy) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Allocate one DAT table using a caller-supplied placement policy.
auto arch::s390x::mmu::detail::default_table_request () noexcept -> pmm::allocation_request
 Build the default PMM request used for DAT table pages.
auto arch::s390x::mmu::has_edat1 () noexcept -> bool
 Query EDAT-1 (1 MiB large page) availability.
auto arch::s390x::mmu::has_edat2 () noexcept -> bool
 Query EDAT-2 (2 GiB large page) availability.
auto arch::s390x::mmu::init () noexcept -> void
 Initialize the MMU engine. Must be called after PMM init and arch::s390x::cpu::features::init().
auto arch::s390x::mmu::detail::init_table (dat_level lvl, u64 phys) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Fill a freshly-allocated table with empty (invalid) entries.
auto arch::s390x::mmu::detail::map_large_1m_impl (u64 root_phys, dat_level root_level, u64 virt, u64 phys, page_prot prot) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Map a 1 MiB large page (EDAT-1) via segment entry.
auto arch::s390x::mmu::detail::map_large_2g_impl (u64 root_phys, dat_level root_level, u64 virt, u64 phys, page_prot prot) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Map a 2 GiB large page (EDAT-2) via region-3 entry.
auto arch::s390x::mmu::detail::map_page_impl (u64 root_phys, dat_level root_level, u64 virt, u64 phys, page_prot prot, const pmm::allocation_request &table_policy) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Map a single 4 KiB page using the two-phase protocol.
auto arch::s390x::mmu::detail::protect_impl (u64 root_phys, dat_level root_level, u64 virt, page_prot new_prot) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Change protection bits on an existing mapping.
auto arch::s390x::mmu::pte_table_alloc () noexcept -> ::std::expected< dat_table< dat_level::page >, ::lib::kernel_error >
 Allocate and initialize a page table.
auto arch::s390x::mmu::detail::table_free_level (dat_level level, u64 phys) noexcept -> void
auto arch::s390x::mmu::detail::table_is_empty (dat_level level, u64 phys) noexcept -> bool
auto arch::s390x::mmu::detail::table_is_mapped (u64 phys, dat_level lvl) noexcept -> bool
 Fail-closed check that a DAT table physical page is backed by the HHDM before it is read or written through hhdm::phys_to_virt().
auto arch::s390x::mmu::detail::unmap_at_impl (u64 root_phys, dat_level root_level, u64 virt) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Unmap whatever exists at virt (4 KiB, 1 MiB, or 2 GiB).
auto arch::s390x::mmu::unmap_page_dispatch (u64 asce_val, u64 virt) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Runtime-dispatched unmap keyed on an ASCE value.
auto arch::s390x::mmu::detail::validate_table_walk (u64 table_phys, dat_level lvl, u64 hhdm_start, u64 hhdm_end) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Walk one DAT table level and recurse into child tables.
auto arch::s390x::mmu::detail::walk_impl (u64 root_phys, dat_level root_level, u64 virt) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Walk the page tables to resolve virt → phys.

Variables

bool arch::s390x::mmu::detail::g_has_edat1 {false}
bool arch::s390x::mmu::detail::g_has_edat2 {false}
bool arch::s390x::mmu::detail::g_initialized {false}
u32 arch::s390x::mmu::detail::g_preinit_table_count {0}
u64 arch::s390x::mmu::detail::g_preinit_table_phys [PREINIT_MAX_TABLES] {}
constexpr u32 arch::s390x::mmu::detail::PREINIT_MAX_TABLES = 2048
 Maximum depth of recursive DAT table walk for pre-init validation.

Detailed Description

MMU engine implementation — DAT table walk/map internals.

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ init()

auto arch::s390x::mmu::init ( ) ->void
exportnoexcept

Initialize the MMU engine. Must be called after PMM init and arch::s390x::cpu::features::init().

Initialize the MMU engine.

◆ map_page_impl()

auto arch::s390x::mmu::detail::map_page_impl ( u64 root_phys,
dat_level root_level,
u64 virt,
u64 phys,
page_prot prot,
const pmm::allocation_request & table_policy )->::std::expected< void,::lib::kernel_error >
noexcept

Map a single 4 KiB page using the two-phase protocol.

Returns
On success, empty expected. On failure, kernel_error; NO side effects.
On success, empty expected.

◆ table_is_mapped()

auto arch::s390x::mmu::detail::table_is_mapped ( u64 phys,
dat_level lvl )->bool
nodiscardnoexcept

Fail-closed check that a DAT table physical page is backed by the HHDM before it is read or written through hhdm::phys_to_virt().

Parameters
[in]physPhysical base of the table (CRST = 16 KiB, page = 2 KiB).
[in]lvlLevel whose table size is being validated.

◆ unmap_at_impl()

auto arch::s390x::mmu::detail::unmap_at_impl ( u64 root_phys,
dat_level root_level,
u64 virt )->::std::expected< u64,::lib::kernel_error >
noexcept

Unmap whatever exists at virt (4 KiB, 1 MiB, or 2 GiB).

Returns
Size of the mapping removed, or kernel_error if nothing was mapped.

◆ unmap_page_dispatch()

auto arch::s390x::mmu::unmap_page_dispatch ( u64 asce_val,
u64 virt )->::std::expected< u64,::lib::kernel_error >
nodiscardexportnoexcept

Runtime-dispatched unmap keyed on an ASCE value.

Parameters
[in]asce_valASCE value (root table + type + length).
[in]virtVirtual address whose PTE to invalidate.
Returns
The physical address of the unmapped frame, or kernel_error (not_present if the address was already unmapped, invalid_address if the root level is bogus).