Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boot mem handling #7039

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open

Boot mem handling #7039

wants to merge 24 commits into from

Commits on Sep 30, 2024

  1. mk/clang.mk: -Wno-gnu-alignof-expression

    Add -Wno-gnu-alignof-expression to the warnings flag for Clang in order to
    avoid warnings like:
    '_Alignof' applied to an expression is a GNU extension [-Werror,-Wgnu-alignof-expression]
    when alignof() is applied on an expression like dereferencing a pointer
    to get the alignment of type.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Jerome Forissier <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    c85ab4c View commit details
    Browse the repository at this point in the history
  2. core: arm64: increase thread stack size for debug

    Increase STACK_THREAD_SIZE when CFG_CORE_DEBUG_CHECK_STACKS=y.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Jerome Forissier <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    d2abc41 View commit details
    Browse the repository at this point in the history
  3. core: mm: add vaddr_to_phys()

    Add a wrapper function for virt_to_phys() using vaddr_t instead of a
    void pointer.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Jerome Forissier <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    b4d4eea View commit details
    Browse the repository at this point in the history
  4. core: remove CORE_MEM_TA_RAM

    The buffer attribute CORE_MEM_TA_RAM isn't used to query the status of a
    buffer anywhere. So remove the attribute to allow future
    simplifications.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Jerome Forissier <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    131e90d View commit details
    Browse the repository at this point in the history
  5. core: add VCORE_FREE_{PA,SZ,END_PA}

    Add VCORE_FREE_{PA,SZ,END_PA} defines to identify the unused and free
    memory range at the end of TEE_RAM_START..(TEE_RAM_START +
    TEE_RAM_VA_SIZE).
    
    VCORE_FREE_SZ is 0 in a pager configuration since all the memory is
    used by the pager.
    
    The VCORE_FREE range is excluded from the TEE_RAM_RW area for
    CFG_NS_VIRTUALIZATION=y and instead put in a separate NEX_RAM_RW area.
    This makes each partition use a bit less memory and leaves the
    VCORE_FREE range available for the Nexus.
    
    The VCORE_FREE range is added to the TEE_RAM_RW area for the normal
    configuration with CFG_NS_VIRTUALIZATION=n and CFG_WITH_PAGER=n. It's in
    practice unchanged behaviour in this configuration.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Acked-by: Jerome Forissier <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    58c0db4 View commit details
    Browse the repository at this point in the history
  6. core: mm: allow unmapping VCORE_FREE

    Allow unmapping core memory in the VCORE_FREE range when the original
    boot mapping isn't needed any more.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Jerome Forissier <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    7f674c1 View commit details
    Browse the repository at this point in the history
  7. core: mm: replace MEM_AREA_TA_RAM

    Replace MEM_AREA_TA_RAM with MEM_AREA_SEC_RAM_OVERALL.
    
    All read/write secure memory is covered by MEM_AREA_SEC_RAM_OVERALL,
    sometimes using an aliased map. But secure read-only or execute core
    memory is not covered as that would defeat the purpose of
    CFG_CORE_RWDATA_NOEXEC.
    
    Since the partition TA memory isn't accessed via MEM_AREA_TA_RAM any
    longer, don't map it using the partition specific map.
    
    This is needed later where unification of OP-TEE core and physical TA
    memory is possible.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    85789fc View commit details
    Browse the repository at this point in the history
  8. core: mm: unify secure core and TA memory

    In configurations where secure core and TA memory is allocated from the
    same contiguous physical memory block, carve out the memory needed by
    OP-TEE core and make the rest available as TA memory.
    
    This is needed by later patches where more core memory is allocated as
    needed from the pool of TA memory.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    ad3a65e View commit details
    Browse the repository at this point in the history
  9. core: virt: phys_mem_core_alloc() use both pools

    With CFG_NS_VIRTUALIZATION=y let phys_mem_core_alloc() allocate from
    both the core_pool and ta_pool since both pools keep equally secure
    memory. This is needed in later patches when some translation tables are
    dynamically allocated from spare physical core memory.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    9b5af7b View commit details
    Browse the repository at this point in the history
  10. core: arm: core_mmu_v7.c: increase MAX_XLAT_TABLES by 2

    Increase MAX_XLAT_TABLES by 2 to be able to map all TEE memory with 4k
    pages.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    2554780 View commit details
    Browse the repository at this point in the history
  11. core: mm: map memory using requested block size

    TEE memory is always supposed to be mapped with 4k pages for maximum
    flexibility, but can_map_at_level() doesn't check the requested block
    size for a region, so fix that. However, assign_mem_granularity()
    assigns smaller than necessary block sizes on page aligned regions, so
    fix that by only requesting 4k granularity for TEE memory and PGDIR
    granularity for the rest.
    
    This is needed in later patches where some TEE memory is unmapped.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    0bbdf91 View commit details
    Browse the repository at this point in the history
  12. core: arm,pager: make __vcore_init_ro_start follow __vcore_init_rx_end

    This concerns configurations with CFG_WITH_PAGER=y. Until this patch,
    even if __vcore_init_ro_size (VCORE_INIT_RO_SZ) is 0 for
    CFG_CORE_RODATA_NOEXEC=n, __vcore_init_ro_start was using some value
    smaller than __vcore_init_rx_end. To simplify code trying to find the
    end of VCORE_INIT_RX and VCORE_INIT_RO parts of the binary, make sure
    that __vcore_init_ro_start follows right after __vcore_init_rx_end.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Etienne Carriere <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    0e1de01 View commit details
    Browse the repository at this point in the history
  13. core: mm,pager: map remaining physical memory

    For CFG_WITH_PAGER=y map the remaining memory following the
    VCORE_INIT_RO memory to make sure that all physical TEE memory is mapped
    even if VCORE_INIT_RO doesn't cover it entirely.
    
    This will be used in later patches to use the temporarily unused memory
    while booting.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    db65607 View commit details
    Browse the repository at this point in the history
  14. core: add CFG_BOOT_MEM and boot_mem_*() functions

    Adds CFG_BOOT_MEM to support stack-like memory allocations during boot
    before a heap has been configured.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    c0f389f View commit details
    Browse the repository at this point in the history
  15. core: arm: add boot_cached_mem_end

    Add boot_cached_mem_end in C code, replacing the previous read-only
    mapped cached_mem_end. This allows updates to boot_cached_mem_end after
    MMU has been enabled.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    585fe39 View commit details
    Browse the repository at this point in the history
  16. core: arm: enable CFG_BOOT_MEM unconditionally

    Enable CFG_BOOT_MEM unconditionally and call the boot_mem_*() functions
    as needed from entry_*.S and boot.c.
    
    The pager will reuse all boot_mem memory internally when configured.
    The non-pager configuration will unmap the memory and make it available
    for TAs if needed.
    
    __FLATMAP_PAGER_TRAILING_SPACE is removed from the link script,
    collect_mem_ranges() in core/mm/core_mmu.c maps the memory following
    VCORE_INIT_RO automatically.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    8469b37 View commit details
    Browse the repository at this point in the history
  17. core: mm: allocate temporary memory map array

    With CFG_BOOT_MEM enabled, allocate a temporary memory map array using
    boot_mem_alloc_tmp() instead of using the global static_mmap_regions[].
    core_mmu_save_mem_map() is added and called from
    boot_init_primary_late() before the temporary memory is reused.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    8488ae8 View commit details
    Browse the repository at this point in the history
  18. core: initialize guest physical memory early

    Initialize guest physical memory in virt_guest_created() before the
    first entry into the guest from normal world. This replaces the call to
    core_mmu_init_phys_mem() in init_tee_runtime().
    
    Remove unused code in core_mmu_init_phys_mem() and the now unused
    functions core_mmu_get_ta_range() and virt_get_ta_ram().
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    9adee80 View commit details
    Browse the repository at this point in the history
  19. core: merge core_mmu_init_phys_mem() and core_mmu_init_virtualization()

    Moves the implementation of core_mmu_init_virtualization() into
    core_mmu_init_phys_mem().
    
    This simplifies init_primary() in core/arch/arm/kernel/boot.c.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    8517692 View commit details
    Browse the repository at this point in the history
  20. core: arm: add CFG_NS_VIRTUALIZATION boot log

    Add a log entry when CFG_NS_VIRTUALIZATION is enabled, for example:
    D/TC:0 0   boot_init_primary_late:1028 NS-Virtualization enabled, supporting 2 guests
    
    Signed-off-by: Jens Wiklander <[email protected]>
    Reviewed-by: Jerome Forissier <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    5cc4816 View commit details
    Browse the repository at this point in the history
  21. [fix] core: mm: map memory using requested block size

    dump_mmap_table() is updated to use map->va directly as it's always the
    start of the mapping regardless of map->region_size.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    643bb7c View commit details
    Browse the repository at this point in the history
  22. [review] core: mm: replace MEM_AREA_TA_RAM

    Add missing ADD_PHYS_MEM(MEM_AREA_SEC_RAM_OVERALL,...) for
    CFG_CORE_RWDATA_NOEXEC=n.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    50d754b View commit details
    Browse the repository at this point in the history
  23. [review] core: mm: replace MEM_AREA_TA_RAM

    Addressing a comment.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    6eff1c9 View commit details
    Browse the repository at this point in the history
  24. [review] core: mm: replace MEM_AREA_TA_RAM

    Remove the read-only mapping between TEE_RAM_START and TEE_LOAD_ADDR.
    
    Signed-off-by: Jens Wiklander <[email protected]>
    jenswi-linaro committed Sep 30, 2024
    Configuration menu
    Copy the full SHA
    a6a21d1 View commit details
    Browse the repository at this point in the history