Skip to content

arch/arm64/imx9: give the ELE a physical address and the cache a virtual one - #20196

Merged
acassis merged 1 commit into
apache:masterfrom
royzah:imx9-ele-va
Sep 24, 2026
Merged

acassis merged 1 commit into
apache:masterfrom
royzah:imx9-ele-va

Conversation

@royzah

@royzah royzah commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

The ELE addresses memory physically. Cache maintenance takes a virtual address. Each buffer call supplies one and uses it for both, in opposite directions.

cache maintenance address given to the enclave
imx9_ele_get_random() a physical address correct
imx9_ele_get_key() correct a virtual address

up_flush_dcache() and up_invalidate_dcache() document their arguments as virtual. So imx9_ele_get_random() maintains whatever lines its physical values happen to name, and a caller reads back what its own line still holds rather than what the ELE wrote, with nothing reported.

Correct only while the two addresses are equal. True of every config in tree today; not true of a kernel build with address environments.

How

Both take the virtual address, maintain the cache on it, and translate for the message. imx9_ele_get_random() gains the cache line check imx9_ele_get_key() already has, because a line shared with live data can be written back over the transfer.

imx9_ele_get_random() changes prototype. Neither function has an in-tree caller.

Depends on

#20192

Tested

Compiles for imx93-evk:nsh. tools/nxstyle reports only the two diagnostics already on master, neither in changed lines.

@royzah
royzah force-pushed the imx9-ele-va branch 2 times, most recently from 7da388a to 7d7827c Compare September 20, 2026 13:44
@github-actions github-actions Bot added Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: M The size of the change in this PR is medium labels Sep 20, 2026
@github-actions

github-actions Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

…ual one.

The ELE addresses memory physically; cache maintenance takes a virtual
address. Both buffer calls supply one and use it for both, in opposite
directions: get_random() runs up_flush_dcache() on a physical address,
get_key() hands the enclave a virtual one. Both fail silently, and both
are correct only while the two are equal.

Take the virtual address in both, maintain the cache on it, and translate
for the message. get_random() also gains the alignment check get_key()
already has.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
@github-actions github-actions Bot added Size: S The size of the change in this PR is small and removed Size: M The size of the change in this PR is medium labels Sep 21, 2026
@royzah

royzah commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Run on hardware alongside #20191: i.MX93 Cortex-A55, PX4 kernel build, NuttX 12.11.0.

hexdump /dev/random -c 32
/dev/random at 00000000:
0000: 7c 9a f9 b0 fb 89 be 9d 23 bf 17 28 88 43 67 10
0010: c5 79 10 9e d7 be ca 42 2f 51 00 bd bc ce 77 54

Note this depends on #20192: imx9_ele.c calls up_addrenv_va_to_pa(), so on a base predating that commit a kernel-mode build fails to link with undefined reference to 'up_addrenv_va_to_pa'. A flat build hides it because addrenv compiles out there. Both are merged now, so it only affects backports.

@royzah
royzah marked this pull request as ready for review September 23, 2026 12:31
@royzah

royzah commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

@acassis @xiaoxiang781216 this one is out of draft too, it is the small ELE address fix that #20191 needs. Hardware log is in the comment above.

No rush, just flagging it is ready.

@acassis
acassis merged commit 026f77d into apache:master Sep 24, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Arch: arm64 Issues related to ARM64 (64-bit) architecture Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants