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

HiKey960, pager: SDP test hangs (xtest 1014.3) #4499

Open
jforissier opened this issue Mar 24, 2021 · 4 comments
Open

HiKey960, pager: SDP test hangs (xtest 1014.3) #4499

jforissier opened this issue Mar 24, 2021 · 4 comments
Labels

Comments

@jforissier
Copy link
Contributor

Building for HiKey960 with command: make -j10 CFG_WITH_PAGER=y CFG_TEE_CORE_EMBED_INTERNAL_TESTS=y CFG_TEE_CORE_LOG_LEVEL=2
SDP test 1014.3 hangs and cannot be interrupted with Ctrl+C:

buildroot login: test
$ xtest 1014
[...]
o regression_1014.3 SDP: SDP TA invokes a test pTA (invoke_tests.pta)
^C^C^C

Bisected down to commit d6ad67f ("core: mm: change vm_pa2va() to return a virtual address").

@jforissier jforissier added the bug label Mar 24, 2021
@jforissier
Copy link
Contributor Author

So apparently commit d6ad67f ("core: mm: change vm_pa2va() to return a virtual address") did not only change the return type, it changed the logic too. The following patches fixes the issue for me, @etienne-lms can you please check if that makes sense? Thanks.

diff --git a/core/mm/vm.c b/core/mm/vm.c
index a6c59861..4cd491c5 100644
--- a/core/mm/vm.c
+++ b/core/mm/vm.c
@@ -1198,8 +1198,6 @@ void *vm_pa2va(const struct user_mode_ctx *uctx, paddr_t pa)
 		assert(!granule || IS_POWER_OF_TWO(granule));
 
 		for (ofs = region->offset; ofs < region->size; ofs += size) {
-			if (mobj_get_pa(region->mobj, ofs, granule, &p))
-				continue;
 
 			if (granule) {
 				/* From current offset to buffer/granule end */
@@ -1211,6 +1209,9 @@ void *vm_pa2va(const struct user_mode_ctx *uctx, paddr_t pa)
 				size = region->size;
 			}
 
+			if (mobj_get_pa(region->mobj, ofs, granule, &p))
+				return NULL;
+
 			if (core_is_buffer_inside(pa, 1, p, size)) {
 				/* Remove region offset (mobj phys offset) */
 				ofs -= region->offset;

@etienne-lms
Copy link
Contributor

thanks for the report. Indeed, i was too quick on moving if (mobj_get_pa(...)) before size update.
However

			if (mobj_get_pa(region->mobj, ofs, granule, &p))
				return NULL;

should be replaced with:

			if (mobj_get_pa(region->mobj, ofs, granule, &p))
				continue;

I think, since since phys address can be found for the area, the loop should try next areas, eventually not find any suitable one and ending with the final return NULL; at function bottom.
Makes sense to you?

I'll test that on Qemu with SDP.

@jforissier
Copy link
Contributor Author

@etienne-lms yes that makes sense and works in my tests too.

@jforissier
Copy link
Contributor Author

#4508

I have tested xtest 1014 on QEMU too (with CFG_WITH_PAGER=y CFG_TEE_CORE_EMBED_INTERNAL_TESTS=y CFG_SECURE_DATA_PATH=y).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants