Skip to content

arch/arm64: implement up_addrenv_va_to_pa() - #20192

Draft
royzah wants to merge 1 commit into
apache:masterfrom
royzah:arm64-va-to-pa
Draft

royzah wants to merge 1 commit into
apache:masterfrom
royzah:arm64-va-to-pa

Conversation

@royzah

@royzah royzah commented Sep 19, 2026

Copy link
Copy Markdown

Summary

up_addrenv_va_to_pa() is declared in https://github.com/apache/nuttx/blob/master/include/nuttx/arch.h but implemented only by armv7-a, so no arm64 port can map a virtual address to a physical one. A driver whose device addresses memory physically has nothing to call.

Asked of the MMU with AT S1E1R rather than walked in software, so it answers for whatever is actually mapped: any granule, block or page, at any level, and it cannot drift from the tables in use.

Two points for review:

  • PAR_EL1 is one register per CPU, so nothing may run between the translation and reading it. Interrupts are banked with it, so masking locally is enough and SMP needs nothing further.
  • Returns zero when the address is not mapped for a privileged read, per the declaration. https://github.com/apache/nuttx/blob/master/arch/arm/src/armv7-a/arm_physpgaddr.c returns the virtual address unchanged instead. Worth settling which is right.

up_addrenv_pa_to_va() is untouched: there is no reverse of AT.

Impact

arm64 with CONFIG_ARCH_HAVE_MMU. New file, no existing behaviour changes.

Testing

Draft: not yet on hardware. Built for imx93-evk:nsh: arm64_physpgaddr.o compiles with no diagnostics, and tools/nxstyle is clean. The disassembly is 12 branchless instructions, with interrupts masked across only the five that touch PAR_EL1. Linking needs a bare-metal aarch64 toolchain, which this machine does not have.

Owed before ready: a runtime log on an i.MX93 translating a known mapping.

Comment thread arch/arm64/src/common/arm64_physpgaddr.c
@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 19, 2026
@github-actions

github-actions Bot commented Sep 19, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

up_addrenv_va_to_pa() is declared in include/nuttx/arch.h but implemented
only by armv7-a, so no arm64 port can map a virtual address to a physical
one. A driver whose device addresses memory physically has nothing to call.

The translation is asked of the MMU with AT S1E1R rather than walked in
software, so it answers for whatever is actually mapped: any granule size,
block or page, at any level, and it cannot drift from the tables in use.

PAR_EL1 is one register per CPU, so nothing may run between the translation
and reading the result. Interrupts are banked with it, so masking them
locally is sufficient and SMP needs nothing further.

Returns zero for an address that is not mapped for a privileged read, which
is what the declaration in arch.h specifies. Note this differs from the
armv7-a implementation, which returns the virtual address unchanged.

Signed-off-by: Royyan Zahir <royzah@gmail.com>
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: M The size of the change in this PR is medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants