|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
TrustZone Secure/Non-Secure seams for ra8_emulator. More...
Go to the source code of this file.
Functions | |
| void | emu_tz_install (uc_engine *uc, const emu_elf_source_t *elf) |
| Arm the TrustZone S->NS boot seams (SAU_TYPE seed + BLXNS hook). | |
| void | emu_tz_patch_cmse (uc_engine *uc, const emu_elf_source_t *elf) |
| Patch cmse_check_address_range to BX LR (flat-domain model). | |
| void | emu_tz_set_ns_vector_base (uint32_t base) |
| Track the NS image's actual vector base (–ns load path). | |
| uint32_t | emu_tz_ns_vector_base (void) |
| The tracked NS vector-table fallback base. | |
TrustZone Secure/Non-Secure seams for ra8_emulator.
Unicorn's emulated M33 is all-Secure with no IDAU, so the Armv8-M Security Extension paths a TrustZone app takes cannot run natively. This module closes the gap in ra8_emulator's single flat domain: it seeds SAU_TYPE with the M85's region count so the Secure boot's SAU programming runs, scans ra8_tz_secure_boot_jump_ns for its BLXNS site and hand-emulates the world switch there (NS MSP/reset fetched from the live VTOR_NS or the tracked NS vector base), and patches cmse_check_address_range to BX LR so the NSC veneers' pointer range checks pass in the flat address space.
Split out of the ra8_emulator main translation unit; behaviour unchanged.
Definition in file emu_tz.h.
| void emu_tz_install | ( | uc_engine * | uc, |
| const emu_elf_source_t * | elf ) |
Arm the TrustZone S->NS boot seams (SAU_TYPE seed + BLXNS hook).
Armed whenever the firmware links the secure boot's ra8_tz_secure_boot_jump_ns: a two-image –ns app, OR a single-image app whose NS half is embedded at its MRAM LMA. The Secure boot bails to its fallback main() unless SAU_TYPE.SREGION is implemented; ra8_emulator maps the PPB as plain RAM (SAU_TYPE reads 0), so the M85's 8-region count is seeded to let the real SAU programming + NS-image copy + BLXNS run. The BLXNS site is resolved by scanning the function body and hooked so the world switch is performed by hand. Firmware without the symbol keeps its current (all-Secure) path.
| [in,out] | uc | Active Unicorn engine. |
| [in] | elf | Open Secure ELF source used for symbol resolution. |
uc is initialised and the image is loaded. Arm the TrustZone S->NS boot seams (SAU_TYPE seed + BLXNS hook).
Definition at line 152 of file emu_tz.c.
References elf_sym_addr(), emu_mem_write(), internal_emu_tz_find_blxns(), internal_on_blxns(), k_sau_type_addr, k_sau_type_regs, k_thumb_hw_bytes, and priv_emu_io_errf().
Referenced by internal_main_install_core_seams().
| uint32_t emu_tz_ns_vector_base | ( | void | ) |
The tracked NS vector-table fallback base.
| 0x32100000 | The default RAM-resident NS run alias (never overridden). |
The tracked ns vector-table fallback base; this step is contained within the emu TrustZone model and uses bounded caller or module-owned storage.
The tracked NS vector-table fallback base.
Definition at line 228 of file emu_tz.c.
References s_ns_vector_base.
Referenced by internal_main_load_ns().
| void emu_tz_patch_cmse | ( | uc_engine * | uc, |
| const emu_elf_source_t * | elf ) |
Patch cmse_check_address_range to BX LR (flat-domain model).
The NSC veneers guard their pointer args with cmse_check_address_range(), whose TT/TTA instructions report every address as Secure on Unicorn's SAU-less core – failing the NS range check and stalling bring-up. ra8_emulator collapses the S/NS split into one flat, fully-accessible domain, so every veneer-passed pointer is valid; patching the routine's entry to BX LR returns r0 (the pointer) unchanged, i.e. "address OK". A one-time 2-byte memory patch with zero steady-state cost (a code hook would force single-stepping); absent in non-TZ firmware.
| [in,out] | uc | Active Unicorn engine. |
| [in] | elf | Open Secure ELF source used for symbol resolution. |
uc memory. elf remains open for symbol resolution. Patch cmse_check_address_range to BX LR (flat-domain model).
Definition at line 194 of file emu_tz.c.
References elf_sym_addr(), emu_mem_write(), and k_thumb_bx_lr.
Referenced by internal_main_run_loaded().
| void emu_tz_set_ns_vector_base | ( | uint32_t | base | ) |
Track the NS image's actual vector base (–ns load path).
| [in] | base | Lowest executable PT_LOAD VMA of the loaded NS image. |
base came from elf_vector_base() on the NS image (non-zero). base when VTOR_NS is unset. Track the ns image's actual vector base (–ns load path); this step is contained within the emu TrustZone model and uses bounded caller or module-owned storage.
Track the NS image's actual vector base (–ns load path).
Definition at line 222 of file emu_tz.c.
References s_ns_vector_base.
Referenced by internal_main_load_ns().