Page MenuHomeFreeBSD

arm64 pmap: introduce PTE_TO_PHYS macro
ClosedPublic

Authored by zachary.leaf_arm.com on Apr 26 2023, 12:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 24 2024, 11:35 PM
Unknown Object (File)
Jan 27 2024, 12:31 AM
Unknown Object (File)
Jan 27 2024, 12:31 AM
Unknown Object (File)
Jan 27 2024, 12:31 AM
Unknown Object (File)
Jan 23 2024, 3:27 AM
Unknown Object (File)
Jan 16 2024, 12:20 PM
Unknown Object (File)
Dec 23 2023, 12:38 AM
Unknown Object (File)
Nov 26 2023, 8:28 AM
Subscribers

Details

Summary

Introduce macro for PTE_TO_PHYS, setting the groundwork for future
support of various Arm VMSA extensions.

For extensions such as 52-bit VA/PA (FEAT_LPA2), the representation of
an address between a PTE and PA are not equivalent. This macro will
allow converting between the different representations.

Currently going from PTE to PA is achieved by masking off the upper and
lower attributes. Retain this behaviour but replace all instances with
the new macro instead.

Sponsored by: Arm Ltd

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This seems fine to me, just a question about naming.

setting the groundwork for future support of various Arm VMSA extensions.

Which extensions?

sys/arm64/include/pte.h
56

What exactly does "base" mean in this context? BASE_MASK and BASE_ADDR sound a bit too generic to me.

It's to help with FEAT_LPA2. This allows > 48 bit physical address space with a 4k and 16k PAGE_SIZE.

With this the shareability bits are moved to be per-ttbr and moved to tcr_el1.sh0 and tcr_el1.sh1. These bits are then used for bits 51 and 50 of the physical address.

sys/arm64/arm64/minidump_machdep.c
309

... and in all other places

zachary.leaf_arm.com marked an inline comment as done.
  • remove unnecessary brackets
sys/arm64/include/pte.h
56

Essentially the base VMSAv8-64 without any extensions. The idea is to use the BASE_MASK as a starting point for other extensions e.g. LPA2:

/* FEAT_LPA2: Bits 9:8 of IA are bits 51:50 of OA when TCR_ELx.DS=1 + 4KB pages */
#define LPA2_IA_BITS           UINT64_C(0x0000000000000300)
#define LPA2_IA_MASK           (BASE_MASK | LPA2_IA_BITS)
#define LPA2_OA_BITS           UINT64_C(0x000f000000000000)
#define LPA2_OA_MASK           (BASE_MASK | LPA2_OA_BITS)
#define LPA2_PTE_SHIFT(pte)    ((pte) | (((pte) & LPA2_IA_BITS) << (50-8)))
#define LPA2_PA_SHIFT(pa)      ((pa) | (((pa) & LPA2_OA_BITS) >> (50-8)))
#define LPA2_TO_PA(pte)        ((LPA2_PTE_SHIFT((pte) & LPA2_IA_MASK)) & LPA2_OA_MASK)
#define LPA2_TO_PTE(pa)        ((LPA2_PA_SHIFT((pa) & LPA2_OA_MASK)) & LPA2_IA_MASK)
sys/arm64/arm64/pmap.c
4198–4199

The riscv pmap names this macro PTE_TO_PHYS, and I will argue for using the same name both here and there. Whether that happens by renaming it here, or there, I don't care. I just don't want them to use different names for doing similar things.

zachary.leaf_arm.com retitled this revision from arm64 pmap: introduce PTE_TO_PA macro to arm64 pmap: introduce PTE_TO_PHYS macro.May 2 2023, 3:10 PM
zachary.leaf_arm.com edited the summary of this revision. (Show Details)
zachary.leaf_arm.com marked an inline comment as done.
  • rename PTE_TO_PA -> PTE_TO_PHYS
  • fix secondary indents + multi-line comments as per man style
sys/arm64/arm64/pmap.c
4146–4148

This is comment duplicating the last two lines of the existing comment above.

4198–4199

Here again, I would say that this comment is duplicating the comment above the loop.

4232

The indentation is incorrect.

4247

The indentation is incorrect.

7022

The indentation is incorrect.

zachary.leaf_arm.com marked 5 inline comments as done.
  • fix indents and comments
This revision is now accepted and ready to land.May 9 2023, 4:58 PM
This revision was automatically updated to reflect the committed changes.