Page MenuHomeFreeBSD

arm64: Use the DMAP region in pmap_mapbios
ClosedPublic

Authored by andrew on Nov 23 2023, 2:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Oct 14, 7:25 PM
Unknown Object (File)
Tue, Oct 14, 2:06 AM
Unknown Object (File)
Tue, Oct 14, 2:06 AM
Unknown Object (File)
Tue, Oct 14, 2:05 AM
Unknown Object (File)
Tue, Oct 14, 2:05 AM
Unknown Object (File)
Tue, Oct 14, 2:05 AM
Unknown Object (File)
Mon, Oct 13, 12:34 PM
Unknown Object (File)
Thu, Oct 9, 5:18 AM
Subscribers

Details

Summary

As pmap_mapbios is used to map a physical address with a default memory
attribute we can try to use the DMAP region. For now check if all pages
are mapped, however it is expected this check can be removed later
after testing on more hardware.

Sponsored by: Arm Ltd

Diff Detail

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

Event Timeline

I expect most of the calls to pmap_mapbios to be mapping firmware tables that are in RAM and covered by the direct map.

This revision is now accepted and ready to land.Nov 28 2023, 5:41 PM
sys/arm64/arm64/pmap.c
7845

Using pmap_pte() would be faster because it would tell you that the virtual address is mapped by an L1 or L2 block, allowing you to advance by 2M or 1G in a single iteration.

sys/arm64/arm64/pmap.c
7845

I expect this is mostly used for small mappings as it's mostly used for ACPI to map in its tables.

I'm planning on moving pmap_mapbios to subr_devmap.c so won't be able to use pmap_pte. We could add a function to check if a range of memory is mapped that could use pmap_pte.

markj added inline comments.
sys/arm64/arm64/pmap.c
7844
7845

I expect this is mostly used for small mappings as it's mostly used for ACPI to map in its tables.

On its own this isn't a great argument: someone might copy and paste this code elsewhere, so all else being equal it's better to use a faster implementation.

7963

What if the caller called pmap_change_attr() or pmap_change_prot() on the mapped range? We would want to restore the old mapping attributes.

Hmm, pmap_unmapdev() on amd64 ignores this possibility. I suppose that the worst case, surrounding regions of the direct map might be using a smaller page size than necessary.

  • Add pmap_kmapped_range to check if a range is mapped & use it in pmap_mapbios
  • Reset memory attribute and protections on unmap
This revision now requires review to proceed.Apr 22 2025, 1:20 PM
sys/arm64/arm64/pmap.c
2153

When can this condition be false?

2154

If ATTR_CONTIGUOUS is set, you could skip more than a page.

7964

Assert that the end of the range is also in the DMAP region?

  • MPASS on ATTR_DESCR_TYPE_PAGE
  • Check for ATTR_CONTIGUOUS
  • Add a KASERT for the end in the DMAP in pmap_unmapbios
This revision is now accepted and ready to land.Apr 29 2025, 1:02 AM
alc added inline comments.
sys/arm64/arm64/pmap.c
2114
This revision was automatically updated to reflect the committed changes.