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

MMU engine — transactional, type-safe DAT table mapper. More...

import std;
import lib.error;
import zxfoundation.memory.pmm.types;
import zxfoundation.base.transaction;
import zxfoundation.base.types;
import arch.s390x.mmu.tlb;
import arch.s390x.mmu.consts;
import zxfoundation.memory.pmm;
import arch.s390x.mmu.types;
Include dependency graph for core.cxxm:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

class  arch::s390x::mmu::mmu_transaction
 Transactional wrapper for batched MMU operations. More...

Functions

template<dat_level Root>
requires (Root != dat_level::page)
auto arch::s390x::mmu::asce_build (dat_table< Root > root) noexcept -> typed_asce< Root >
 Build a typed ASCE for a kernel address space.
template<dat_level Level>
requires (Level != dat_level::page)
auto arch::s390x::mmu::crst_alloc () noexcept -> ::std::expected< dat_table< Level >, ::lib::kernel_error >
 Allocate and initialize a CRST table for the given level.
auto arch::s390x::mmu::detail::default_table_request () noexcept -> pmm::allocation_request
 Build the default PMM request used for DAT table pages.
 arch::s390x::mmu::detail::from_global (reference) bool g_has_edat1
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.
template<dat_level Root>
auto arch::s390x::mmu::map_page (dat_table< Root > root, u64 virt, u64 phys, page_prot prot) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Map a single 4 KiB page. Side-effect-free on failure.
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.
template<dat_level Root>
auto arch::s390x::mmu::map_page_with_policy (dat_table< Root > root, u64 virt, u64 phys, page_prot prot, const zxfoundation::memory::pmm::allocation_request &table_policy) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Map a single 4 KiB page with explicit page-table allocation placement.
template<dat_level Root>
auto arch::s390x::mmu::map_range (dat_table< Root > root, u64 virt, u64 phys, u64 len, page_prot prot) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Map a contiguous range [virt, virt+len) → [phys, phys+len).
template<dat_level Root>
auto arch::s390x::mmu::protect (dat_table< Root > root, u64 virt, page_prot new_prot) noexcept -> ::std::expected< void, ::lib::kernel_error >
 Change protection bits on an existing mapping.
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.
template<dat_level Level>
auto arch::s390x::mmu::table_free (dat_table< Level > tbl) noexcept -> void
 Free a previously allocated table.
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).
template<dat_level Root>
auto arch::s390x::mmu::unmap_page (dat_table< Root > root, u64 virt) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Unmap a single page/large-page at virt.
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.
template<dat_level Root>
auto arch::s390x::mmu::unmap_range (dat_table< Root > root, u64 virt, u64 len) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Unmap a contiguous range [virt, virt+len).
template<dat_level Root>
auto arch::s390x::mmu::walk (dat_table< Root > root, u64 virt) noexcept -> ::std::expected< u64, ::lib::kernel_error >
 Walk the page tables to resolve virt → phys.
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.

Detailed Description

MMU engine — transactional, type-safe DAT table mapper.

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()

template<dat_level Root>
auto arch::s390x::mmu::map_page ( dat_table< Root > root,
u64 virt,
u64 phys,
page_prot prot )->::std::expected< void,::lib::kernel_error >
nodiscardexportnoexcept

Map a single 4 KiB page. Side-effect-free on failure.

Precondition
Caller holds exclusive access to the root table.

◆ 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.

◆ map_page_with_policy()

template<dat_level Root>
auto arch::s390x::mmu::map_page_with_policy ( dat_table< Root > root,
u64 virt,
u64 phys,
page_prot prot,
const zxfoundation::memory::pmm::allocation_request & table_policy )->::std::expected< void,::lib::kernel_error >
nodiscardexportnoexcept

Map a single 4 KiB page with explicit page-table allocation placement.

Parameters
[in]rootRoot DAT table.
[in]virtVirtual address to map.
[in]physPhysical frame to install.
[in]protHardware protection bits.
[in]table_policyPMM allocation request used for newly allocated DAT tables.
Returns
Success or kernel error.
Note
Existing child tables are reused; the policy applies only to tables allocated during this map walk.

◆ map_range()

template<dat_level Root>
auto arch::s390x::mmu::map_range ( dat_table< Root > root,
u64 virt,
u64 phys,
u64 len,
page_prot prot )->::std::expected< u64,::lib::kernel_error >
nodiscardexportnoexcept

Map a contiguous range [virt, virt+len) → [phys, phys+len).

Returns
Total bytes mapped on success, or kernel_error.
Precondition
Caller holds exclusive access to the root table.
virt and phys are PAGE_SIZE_4K-aligned.
len is PAGE_SIZE_4K-aligned and > 0.

◆ protect()

template<dat_level Root>
auto arch::s390x::mmu::protect ( dat_table< Root > root,
u64 virt,
page_prot new_prot )->::std::expected< void,::lib::kernel_error >
nodiscardexportnoexcept

Change protection bits on an existing mapping.

Precondition
Caller holds exclusive access to the root table.

◆ 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()

template<dat_level Root>
auto arch::s390x::mmu::unmap_page ( dat_table< Root > root,
u64 virt )->::std::expected< u64,::lib::kernel_error >
nodiscardexportnoexcept

Unmap a single page/large-page at virt.

Returns
Physical address of the unmapped frame, or kernel_error.
Precondition
Caller holds exclusive access to the root table.

◆ 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).

◆ unmap_range()

template<dat_level Root>
auto arch::s390x::mmu::unmap_range ( dat_table< Root > root,
u64 virt,
u64 len )->::std::expected< u64,::lib::kernel_error >
nodiscardexportnoexcept

Unmap a contiguous range [virt, virt+len).

Returns
Total bytes unmapped, or kernel_error.
Precondition
Caller holds exclusive access to the root table.

◆ walk()

template<dat_level Root>
auto arch::s390x::mmu::walk ( dat_table< Root > root,
u64 virt )->::std::expected< u64,::lib::kernel_error >
nodiscardexportnoexcept

Walk the page tables to resolve virt → phys.

Returns
Physical address corresponding to virt, or kernel_error.