[PATCH v2 0/3] Type correctness cleanup for ARM64 MMU initialization

Sam Edwards posted 3 patches 4 weeks, 1 day ago
arch/arm64/kernel/pi/map_kernel.c | 41 ++++++++++++++++---------------
arch/arm64/kernel/pi/map_range.c  | 20 +++++++++------
arch/arm64/kernel/pi/pi.h         |  9 ++++---
arch/arm64/mm/init.c              |  6 ++---
arch/arm64/mm/mmu.c               | 17 +++++++------
5 files changed, 50 insertions(+), 43 deletions(-)
[PATCH v2 0/3] Type correctness cleanup for ARM64 MMU initialization
Posted by Sam Edwards 4 weeks, 1 day ago
Hello list,

This is a small series of type correctness and readability improvements for
ARM64's MMU initialization code. When I first encountered this code, the heavy
use of u64 to represent both virtual and physical addresses made it difficult
to understand where the demarcations were. I made most of the changes in this
series while troubleshooting a different problem (fixed in a separate patch) to
make that boundary a little clearer. I am submitting it now in the hopes that
this will improve maintainability and readability for others.

While nothing in this series represents a change in behavior, it is not merely
cosmetic: I believe these changes better align with the kernel's code
standards, type discipline, and common C idioms.

Happy Thursday,
Sam

Changes v1->v2:
- Correct an incorrect comment in map_fdt(), which is only called when the MMU
  has an idmap installed; it casts a static array to a physical address
  ("Stack is idmapped" -> "We're idmapped when called")

Sam Edwards (3):
  arm64: mm: Cast start/end markers to char *, not u64
  arm64: mm: Make map_fdt() return mapped pointer
  arm64: mm: Represent physical memory with phys_addr_t and
    resource_size_t

 arch/arm64/kernel/pi/map_kernel.c | 41 ++++++++++++++++---------------
 arch/arm64/kernel/pi/map_range.c  | 20 +++++++++------
 arch/arm64/kernel/pi/pi.h         |  9 ++++---
 arch/arm64/mm/init.c              |  6 ++---
 arch/arm64/mm/mmu.c               | 17 +++++++------
 5 files changed, 50 insertions(+), 43 deletions(-)

-- 
2.49.1
Re: [PATCH v2 0/3] Type correctness cleanup for ARM64 MMU initialization
Posted by Will Deacon 2 weeks, 2 days ago
On Wed, 03 Sep 2025 17:52:06 -0700, Sam Edwards wrote:
> This is a small series of type correctness and readability improvements for
> ARM64's MMU initialization code. When I first encountered this code, the heavy
> use of u64 to represent both virtual and physical addresses made it difficult
> to understand where the demarcations were. I made most of the changes in this
> series while troubleshooting a different problem (fixed in a separate patch) to
> make that boundary a little clearer. I am submitting it now in the hopes that
> this will improve maintainability and readability for others.
> 
> [...]

I must confess, I don't personally see a huge amount of value from these
changes. However, I've probably just got used to things and so if this
would've helped you understand the code when you first came across it
recently then I think it's worth having.

Applied to arm64 (for-next/mm), thanks!

[1/3] arm64: mm: Cast start/end markers to char *, not u64
      https://git.kernel.org/arm64/c/030b3ffbdac7
[2/3] arm64: mm: Make map_fdt() return mapped pointer
      https://git.kernel.org/arm64/c/c56aa9a67a08
[3/3] arm64: mm: Represent physical memory with phys_addr_t and resource_size_t
      https://git.kernel.org/arm64/c/b868fff5b10b

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev