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

core: fix panic with TEE_SDP_TEST_MEM #7273

Merged
merged 1 commit into from
Feb 14, 2025

Conversation

jenswi-linaro
Copy link
Contributor

The commit 2f2f69d ("core: mm: replace MEM_AREA_TA_RAM") uses MEM_AREA_SEC_RAM_OVERALL to map practically all secure memory. This conflicts with TEE_SDP_TEST_MEM:

  1. MEM_AREA_SEC_RAM_OVERALL covers TEE_SDP_TEST_MEM and triggers a panic in verify_special_mem_areas().
  2. TEE_SDP_TEST_MEM_BASE refers to physical memory only since it's only mapped in MEM_AREA_SEC_RAM_OVERALL.

So fix these problems.

Fixes: 2f2f69d ("core: mm: replace MEM_AREA_TA_RAM")

@@ -2776,7 +2782,7 @@ void core_mmu_init_phys_mem(void)
/* Carve out test SDP memory */
#ifdef TEE_SDP_TEST_MEM_BASE
if (TEE_SDP_TEST_MEM_SIZE) {
pa = vaddr_to_phys(TEE_SDP_TEST_MEM_BASE);
pa = TEE_SDP_TEST_MEM_BASE;
Copy link
Contributor

Choose a reason for hiding this comment

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

This fix rather relates to commit 1c1f8b6 that falsely considered SDP_TEST_MEM could be relocated whereas is it not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I'll update the commit message.

* cover all secure memory, even if it's special.
*/
if (mem_map->map[n].type == MEM_AREA_SEC_RAM_OVERALL)
continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is applicable when SDP_TEST_MEM that is inside the SEC_RAM_OVERALL. But not if the SDP memory is defined with CFG_TEE_SDP_MEM_BASE/_SIZE. Maybe specifically test here if mem->start == TEE_SDP_TEST_MEM_BASE && mem->size == TEE_SDP_TEST_MEM_SIZE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, it's getting a bit ugly. We should perhaps remove TEE_SDP_TEST_MEM someday.

@etienne-lms
Copy link
Contributor

Minor comment: prefix commit message header line with core: mm:.

@jenswi-linaro
Copy link
Contributor Author

Comments addressed and commit message updated.

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

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

Reviewed-by: Etienne Carriere <[email protected]>

The commit 2f2f69d ("core: mm: replace MEM_AREA_TA_RAM") uses
MEM_AREA_SEC_RAM_OVERALL to map practically all secure memory. This
conflicts with TEE_SDP_TEST_MEM where MEM_AREA_SEC_RAM_OVERALL covers
TEE_SDP_TEST_MEM and triggers a panic in verify_special_mem_areas().

The commit 1c1f8b6 ("core: mm: unify secure core and TA memory")
changed to use vaddr_to_phys() to find the physical address for
TEE_SDP_TEST_MEM_BASE. This isn't right since it refers to physical
memory only.

So fix these problems.

Fixes: 2f2f69d ("core: mm: replace MEM_AREA_TA_RAM")
Fixes: 1c1f8b6 ("core: mm: unify secure core and TA memory")
Signed-off-by: Jens Wiklander <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
@jenswi-linaro
Copy link
Contributor Author

Tag applied.

@jforissier jforissier merged commit a7aaad0 into OP-TEE:master Feb 14, 2025
11 checks passed
@jenswi-linaro jenswi-linaro deleted the test-sdp-fix branch February 14, 2025 10:16
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