arch/arm64: implement up_addrenv_va_to_pa() - #20192
Conversation
3f74621 to
02e7819
Compare
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>
02e7819 to
fc50a34
Compare
|
Ran it, rather than only building it.
The kernel mapping on this board is flat, so the first two lines on their own would also pass for an implementation that just returned its argument. The third is what separates them: Not covered: a mapping where the virtual and physical addresses differ. That needs a user address environment, which needs a root filesystem this boot does not have. |
|
@acassis @xiaoxiang781216 thanks both. Green and mergeable, ready when one of you has a moment. |
The kernel build could not link imx9_ele.c without apache/nuttx#20192, which the current pin predates; the flat build hides it. Also stops the board forcing MAVLink on USB so a console is reachable.
Why
https://github.com/apache/nuttx/blob/master/include/nuttx/arch.h declares
up_addrenv_va_to_pa(), but only armv7-a implements it. A driver whose device addresses memory physically has nothing to call on arm64.How
AT S1E1R, so the answer comes from the MMU rather than a software walk: any granule, block or page, at any level, and it cannot drift from the tables in use.PAR_EL1is one register per CPUCONFIG_DEV_SIMPLE_ADDRENVis offqemu-armv8aconfigs select itup_addrenv_pa_to_va()is untouched: there is no reverse ofAT.Tested
Booted
qemu-armv8a:knsh, the config closest to this:BUILD_KERNEL,ARCH_ADDRENV,ARCH_USE_MMU.That board maps flat, so the first two would also pass for a stub returning its argument. The third is what separates them.