Page MenuHomeFreeBSD

pmap_enter_{l2,pde}: correct the handling of an error case
ClosedPublic

Authored by alc on Jul 16 2025, 4:58 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 16, 3:14 AM
Unknown Object (File)
Fri, Oct 10, 5:37 PM
Unknown Object (File)
Fri, Oct 10, 5:37 PM
Unknown Object (File)
Fri, Oct 10, 5:37 PM
Unknown Object (File)
Fri, Oct 10, 5:37 PM
Unknown Object (File)
Fri, Oct 10, 12:28 PM
Unknown Object (File)
Sep 17 2025, 1:38 AM
Unknown Object (File)
Sep 12 2025, 8:47 AM
Subscribers

Details

Summary

When pmap_enter_object()'s call to pmap_enter_{l2,pde}() fails to create a managed mapping within the kernel address space due to the inability to allocate a PV entry, it needs to remove the kernel page table page from the pmap's trie of idle page table pages. Previously, it did not.

Diff Detail

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

Event Timeline

alc requested review of this revision.Jul 16 2025, 4:58 PM
sys/arm64/arm64/pmap.c
5835

Can you use ADDR_IS_KERNEL here?

alc marked an inline comment as done.Jul 16 2025, 7:08 PM
This revision is now accepted and ready to land.Jul 16 2025, 10:07 PM

Is my reading of the code correct where uwptpg == NULL in the new else case because it's only set for userspace maps? If so it means we will call pmap_remove_pt_page.

Is my reading of the code correct where uwptpg == NULL in the new else case because it's only set for userspace maps?

That's my understanding.

I have two related observations:

  1. !ADDR_IS_KERNEL() appears more frequently than ADDR_IS_KERNEL(). @andrew What would you think about adding ADDR_IS_USER()?
  2. @kib @markj What do you think about adding these macros to amd64 to eliminate trivial differences between the pmap implementations?
In D51353#1173408, @alc wrote:
  1. @kib @markj What do you think about adding these macros to amd64 to eliminate trivial differences between the pmap implementations?

I do not see why not. It is trivial macro, although I prefer a different way to write it for amd64, like

#define ADDR_IS_KERNEL(va) ((vm_offset_t)(va) >= kva_layout.kva_min)