Page MenuHomeFreeBSD

Extract the logic from pmap_kextract
ClosedPublic

Authored by andrew on Dec 15 2020, 2:57 PM.
Tags
None
Referenced Files
F102768889: D27621.diff
Sat, Nov 16, 10:21 PM
Unknown Object (File)
Fri, Nov 1, 3:35 PM
Unknown Object (File)
Fri, Nov 1, 4:53 AM
Unknown Object (File)
Tue, Oct 22, 6:06 PM
Unknown Object (File)
Oct 1 2024, 1:09 PM
Unknown Object (File)
Sep 30 2024, 9:48 AM
Unknown Object (File)
Sep 21 2024, 4:57 AM
Unknown Object (File)
Sep 18 2024, 10:07 PM
Subscribers

Details

Summary

This allows us to use it when we only need to check if the virtual address
is valid. For example when checking if an address in the DMAP region is
mapped.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 36219
Build 33108: arc lint + arc unit

Event Timeline

This is untested, I just moved the code to a new function as a proof of concept.

Fix the build and boot tested on N1SDP

I was always envy for aarch64 AT instructions. AT S1E0R (or W) seems to do exactly what you want, and avoid manual parsing of the page tables. Why not use the instruction?

Use an AT instruction with a fallback on walking the page table.

sys/arm64/arm64/pmap.c
1381

Why do we need to disable interrupts around AT ?

sys/arm64/arm64/pmap.c
1381

It's two instructions. The at instruction stores the result in par_el1 so we then need the following to get the result in x1:

at      s1e1r, x0
mrs     x1, par_el1

If a interrupt happens after the at, but before the mrs we may have an invalid value in par_el, e.g. if the thread is moved to a new CPU. We could handle this by restarting the instruction, however disabling interrupts on arm64 is cheap so there is no need.

kib added inline comments.
sys/arm64/arm64/pmap.c
1381

May be add a comment there noting that operation is not atomic?

This revision is now accepted and ready to land.Jan 15 2021, 12:42 PM

BTW would it make sense to use AT in pmap_extract()?

Add a comment explaining why interrupts are disabled

This revision now requires review to proceed.Jan 15 2021, 3:10 PM
sys/arm64/arm64/pmap.c
1368–1375

Extra newline.

1381

Or perhaps disable interrupts in the implementation rather than the caller.

6861

I think pmap_klookup() might be a better name. kva_to_pa is a bit confusing since 1) translating KVAs to PAs is ostensibly pmap_kextract()'s job, and 2) the function is used here only to see if the address is valid.

I expect we could do something similar in pmap_extract. We would need to limit it to stage 1 pmaps (i.e. non-hypervisor pmaps), and need to check if it's a userspace or kernel pmap.

It looks like we would only need the page table walking code for stage 2 pmaps as we only modify them with the pmap lock that pmap_extract holds.

Update based on feedback from markj

This revision is now accepted and ready to land.Jan 15 2021, 4:25 PM
This revision was automatically updated to reflect the committed changes.