Skip to content

Conversation

@ymoog
Copy link
Contributor

@ymoog ymoog commented Sep 12, 2025

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8 GiB. optee_os should accept addresses up to the max possible address of the largest RAM board variant when communicating to non-secure os via shared DRAM, so CFG_DDR_SIZE is adjusted accordingly. Set CFG_TZDRAM_START explicitly now, since the goal is to support the reference optee_os with a single binary on all board variants. Thus optee_os must reside within the 1st GiB of DRAM.

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8
GiB. optee_os should accept addresses up to the max possible address of
the largest RAM board variant when communicating to non-secure os via
shared DRAM, so CFG_DDR_SIZE is adjusted accordingly.
Set CFG_TZDRAM_START explicitly now, since the goal is to support the
reference optee_os with a single binary on all board variants. Thus
optee_os must reside within the 1st GiB of DRAM.

Signed-off-by: Yannic Moog <[email protected]>
@jforissier
Copy link
Contributor

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8 GiB. optee_os should accept addresses up to the max possible address of the largest RAM board variant when communicating to non-secure os via shared DRAM, so CFG_DDR_SIZE is adjusted accordingly.

The drawback is that it weakens validation of addresses by secure world. If NS world passes an out-of-range address, SW will crash and the system is dead. Why not pass proper memory information via DT instead?

Set CFG_TZDRAM_START explicitly now, since the goal is to support the reference optee_os with a single binary on all board variants. Thus optee_os must reside within the 1st GiB of DRAM.

@ymoog
Copy link
Contributor Author

ymoog commented Sep 15, 2025

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8 GiB. optee_os should accept addresses up to the max possible address of the largest RAM board variant when communicating to non-secure os via shared DRAM, so CFG_DDR_SIZE is adjusted accordingly.

The drawback is that it weakens validation of addresses by secure world. If NS world passes an out-of-range address, SW will crash and the system is dead. Why not pass proper memory information via DT instead?

Okay. Just to verify, we assume that there is a bad actor passing bogus addresses to SW that are out of bounds of actual physical ram address space? (assume 4GiB actual RAM, while SW thinks it only has 1GiB. After all, NS shared memory will work fine for anything within 4GiB even though SW only knows of 1GiB)

Anyway, I'll work on your suggestion since we would end up with the proper main memory size in that case.
Thanks.

Set CFG_TZDRAM_START explicitly now, since the goal is to support the reference optee_os with a single binary on all board variants. Thus optee_os must reside within the 1st GiB of DRAM.

ifneq (,$(filter $(PLATFORM_FLAVOR),mx8mm_phygate_tauri_l))
CFG_DDR_SIZE ?= 0x80000000
CFG_DDR_SIZE ?= UL(0x100000000)
CFG_TZDRAM_START = 0xbe000000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ymoog

From commit message, shared memory address will be in first 1GB memory, but this address is not in first 1GB of memory, please check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @sahilnxp, thanks for calling that out. The phygate tauri does not exist as a 1GiB memory variant. I'll rework the commit message.


ifneq (,$(filter $(PLATFORM_FLAVOR),mx8mm_phygate_tauri_l))
CFG_DDR_SIZE ?= 0x80000000
CFG_DDR_SIZE ?= UL(0x100000000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test with these changes on all 8m phytec platforms ?
Since tzc380.c is enabled on 8MM and 8MP platforms, and it takes CFG_DDR_SIZE in account while configuring the regions, I am not sure what impact this will have on TZC programming.
Can you please check this also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested that all boards boot and xtest runs successfully. Is there a specific test you recommend me to run or what I should check? I'll take a closer look at how tzc-380 works.


ifneq (,$(filter $(PLATFORM_FLAVOR),mx8mm_phyboard_polis))
CFG_DDR_SIZE ?= 0x40000000
CFG_DDR_SIZE ?= UL(0x100000000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From 8MM and 8MP reference manual, DDR addresses are aligned as shown below:

Image

For the boards having more than, 3GB of memory, I think you need to define CFG_NSEC_DDR_1_BASE and CFG_NSEC_DDR_1_SIZE also.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot about that, thanks.

ifneq (,$(filter $(PLATFORM_FLAVOR),mx8mpevk))
CFG_DDR_SIZE ?= UL(0x180000000)
CFG_UART_BASE ?= UART2_BASE

Does the imx8mp evk have this problem as well, then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes imx8mp evk has same memory map like this one.

@ymoog
Copy link
Contributor Author

ymoog commented Sep 19, 2025

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8 GiB. optee_os should accept addresses up to the max possible address of the largest RAM board variant when communicating to non-secure os via shared DRAM, so CFG_DDR_SIZE is adjusted accordingly.

The drawback is that it weakens validation of addresses by secure world. If NS world passes an out-of-range address, SW will crash and the system is dead. Why not pass proper memory information via DT instead?

Hi @jforissier. I need some assistance on the dt topic.
In U-Boot spl, we read the actual memory size through rom data and could then configure/fixup the dtb. However, it is not clear to me through which mechanism this dtb is then passed to tf-a and then further to the tee.
I stumbled upon Firmware Handoff which appears to be supported by tf-a. Does optee_os and U-Boot support that, too?
Can you point me to the appropriate documentation?

Set CFG_TZDRAM_START explicitly now, since the goal is to support the reference optee_os with a single binary on all board variants. Thus optee_os must reside within the 1st GiB of DRAM.

@jforissier
Copy link
Contributor

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8 GiB. optee_os should accept addresses up to the max possible address of the largest RAM board variant when communicating to non-secure os via shared DRAM, so CFG_DDR_SIZE is adjusted accordingly.

The drawback is that it weakens validation of addresses by secure world. If NS world passes an out-of-range address, SW will crash and the system is dead. Why not pass proper memory information via DT instead?

Hi @jforissier. I need some assistance on the dt topic. In U-Boot spl, we read the actual memory size through rom data and could then configure/fixup the dtb. However, it is not clear to me through which mechanism this dtb is then passed to tf-a and then further to the tee. I stumbled upon Firmware Handoff which appears to be supported by tf-a. Does optee_os and U-Boot support that, too? Can you point me to the appropriate documentation?

Yes, OP-TEE and U-Boot do support Firmware Handoff. For U-Boot there is documentation at https://docs.u-boot.org/en/latest/develop/bloblist.html. For OP-TEE there is no formal documentation but you may want to check commit OP-TEE/build@0048f71dd59b which enabled Firmware Handoff in the QEMUv8 test config of OP-TEE. This configuration has TF-A, U-Boot and OP-TEE so it will hopefully be helpful. CC @raymo200915 who worked on this.

@raymo200915
Copy link
Contributor

PHYTEC imx8m boards have different RAM configurations, from 1 up to 8 GiB. optee_os should accept addresses up to the max possible address of the largest RAM board variant when communicating to non-secure os via shared DRAM, so CFG_DDR_SIZE is adjusted accordingly.

The drawback is that it weakens validation of addresses by secure world. If NS world passes an out-of-range address, SW will crash and the system is dead. Why not pass proper memory information via DT instead?

Hi @jforissier. I need some assistance on the dt topic. In U-Boot spl, we read the actual memory size through rom data and could then configure/fixup the dtb. However, it is not clear to me through which mechanism this dtb is then passed to tf-a and then further to the tee. I stumbled upon Firmware Handoff which appears to be supported by tf-a. Does optee_os and U-Boot support that, too? Can you point me to the appropriate documentation?

Yes, OP-TEE and U-Boot do support Firmware Handoff. For U-Boot there is documentation at https://docs.u-boot.org/en/latest/develop/bloblist.html. For OP-TEE there is no formal documentation but you may want to check commit OP-TEE/build@0048f71dd59b which enabled Firmware Handoff in the QEMUv8 test config of OP-TEE. This configuration has TF-A, U-Boot and OP-TEE so it will hopefully be helpful. CC @raymo200915 who worked on this.

Recently Firmware Handoff lib was migrated from TF-A to https://review.trustedfirmware.org/plugins/gitiles/shared/transfer-list-library/, I think you can get more information there.

@github-actions
Copy link

github-actions bot commented Nov 3, 2025

This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.

@github-actions github-actions bot added the Stale label Nov 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants