Skip to content

OP-TEE changes to run in DomA (Android) - #11

Merged
lorc merged 4 commits into
xen-troops:renesas/rcar-gen5_4.4.0-android-xtfrom
andrew2311:rcar-gen5_4.4.0-xt-android
Jul 23, 2026
Merged

OP-TEE changes to run in DomA (Android)#11
lorc merged 4 commits into
xen-troops:renesas/rcar-gen5_4.4.0-android-xtfrom
andrew2311:rcar-gen5_4.4.0-xt-android

Conversation

@andrew2311

@andrew2311 andrew2311 commented Jul 16, 2026

Copy link
Copy Markdown

Changes:

  • basic optee bring-up for x5h (same as for domd)
  • backport fix for python cmd line
  • backport fix for signed ta prebuilts
  • fix race condition during clang optee build

@andrew2311
andrew2311 force-pushed the rcar-gen5_4.4.0-xt-android branch from 52cef6e to a3b83f0 Compare July 17, 2026 11:08
@andrew2311

Copy link
Copy Markdown
Author

Updated commit message and comments in files to have max 75 characters in one line

@lorc

lorc commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

CFG_LPAE_ADDR_SPACE_BITS change needs to be clearly marked as hack/workaround

And it is better to implement a proper fix (or plan it, at least).

But, for time being, we can live with this, I guess. So, please add proper markings and with that:

Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>

@andrew2311
andrew2311 force-pushed the rcar-gen5_4.4.0-xt-android branch from a3b83f0 to df311f0 Compare July 17, 2026 13:57
@andrew2311

Copy link
Copy Markdown
Author

Added workaround comment about CFG_LPAE_ADDR_SPACE_BITS and Reviewed-by

@andrew2311
andrew2311 marked this pull request as draft July 19, 2026 14:50
@lorc

lorc commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

I can't merge it because it is in draft state. Are you going to make more changes?

@andrew2311

Copy link
Copy Markdown
Author

Yes, I've added commit to fix clang build (wrong dependencies)

  • will switch to android 17 and check any changes required here (probably no)

@LKomaryanskiy

Copy link
Copy Markdown

@lorc and @andrew2311 FYI, probably the CFG_LPAE_ADDR_SPACE_BITS issue that Andrii encountered was fixed by these commits: OP-TEE@a28e4a0 and OP-TEE@1871575 . At least COMPILE_ASSERT was removed :) I understand that it will be very painful to backport such changes from the master to 4.4 OPTEE, which is used by Renesas for now, but at least we need to pay attention that this patch should be reworked after upgrading Gen5 OPTEE to a newer version with such fixes. This is just a comment; no need to change anything :)

Thus, please add my Reviewed-by: Leonid Komarianskyi <leonid_komarianskyi@epam.com>

Andrii Shtompel and others added 4 commits July 21, 2026 11:28
OP-TEE on gen5 advertised no dynamic SHM, so the Xen OP-TEE mediator
rejected EXCHANGE_CAPABILITIES and the Linux optee driver failed probe
in dom0 and DomD ("optee: capabilities mismatch" / -22)
Three reasons, all of them are fixed here:

1) plat-rcar_gen5 never called register_ddr() (CFG_DT=n), so
   phys_ddr_overall was empty, core_mmu_nsec_ddr_is_defined() was false and
   tee_entry_exchange_capabilities() did not set
   OPTEE_SMC_SEC_CAP_DYNAMIC_SHM. Register the board non-secure DDR.
   core_mmu_set_discovered_nsec_ddr() panics if a range overlaps a
   non-secure_only OP-TEE map, and the low bank (0x40000000-0xC0000000) is
   full of them (TZDRAM/TEE RAM @0x8C400000, SoC reg block, ...) plus
   firmware-reserved areas, so only the clean high banks (>=0x10_80000000,
   per r8a78000-ironhide-common.dtsi) are registered. DomD (8 GiB) does not
   fit in the low bank anyway and is placed by Xen in these high banks, so
   guest SHM buffers are covered.
2) CFG_CORE_ARM64_PA_BITS is forced to 36 (64GB), so OP-TEE could neither
   address nor register the high banks (core_mmu_check_end_pa() panic).
   Enable CFG_AUTO_MAX_PA_BITS=y to use the runtime HW PARange (>=40 bits
   here), like plat-vexpress does for virtualization.
3) Under CFG_NS_VIRTUALIZATION the per-guest MMU partition base translation
   table must fit one 4KB page; with 32 cores at 36-bit VA it is 32KB and
   trips a COMPILE_TIME_ASSERT in core_alloc_mmu_prtn(). Narrow the
   virtualization build to a 33-bit address space (still covers every
   static map; the high banks are reached via PA width and the on-demand
   SHM window, not VA). Non-virtualization builds keep the 36-bit address
   space.

Signed-off-by: Andrii Shtompel <andrii_shtompel@epam.com>
Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
Reviewed-by: Leonid Komarianskyi <leonid_komarianskyi@epam.com>
Fix typo for python command line
$(q)scripts/gen_tee_bin.py => $(q)$(PYTHON3) scripts/gen_tee_bin.py

Signed-off-by: guan-gm.lin <guan-gm.lin@mediatek.com>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
(cherry picked from commit 0365a94)
In mk/aosp_optee.mk the signed TA (.ta) is registered as an
EXECUTABLES prebuilt, so AOSP runs check_elf_file on it. A signed TA
is an ELF binary wrapped in a signed header and does not start with
the ELF magic. On Android 17 the build no longer passes
--skip-bad-elf-magic to check_elf_file, so this is now fatal:

  error: File "<uuid>.ta" must have a valid ELF magic word.

Set LOCAL_CHECK_ELF_FILES := false for the .ta module in
mk/aosp_optee.mk to skip this check.

Signed-off-by: ming-jen.chang <ming-jen.chang@mediatek.com>
Signed-off-by: Leo Chen <shf.chen@mediatek.com>
Acked-by: Jens Wiklander <jenswi@kernel.org>
Acked-by: Tadd Kao <tadd.kao@mediatek.com>

(cherry picked from commit a8ac329662c0ecf4be2a01d0af9d0182aa1eee39)
Make the exported ta_dev_kit.mk depend on tee.bin so the dev kit
sub-make only starts after the core build has finished.

Signed-off-by: Andrii Shtompel <andrii_shtompel@epam.com>
Reviewed-by: Leonid Komarianskyi <leonid_komarianskyi@epam.com>
@andrew2311
andrew2311 force-pushed the rcar-gen5_4.4.0-xt-android branch from d43308c to 4b94284 Compare July 21, 2026 09:30
@LKomaryanskiy

Copy link
Copy Markdown

@andrew2311 could you please unmark the PR as a draft and set it ready for review? Without that, Volodymyr will not be able to merge it.

@andrew2311
andrew2311 marked this pull request as ready for review July 21, 2026 17:11
@lorc
lorc merged commit 9cf0feb into xen-troops:renesas/rcar-gen5_4.4.0-android-xt Jul 23, 2026
1 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants