Page MenuHomeFreeBSD

arm64/pmap: Modify condition of valid_memattr that cannot be true
ClosedPublic

Authored by timo.voelker_fh-muenster.de on Feb 26 2026, 4:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Aug 3, 12:07 AM
Unknown Object (File)
Sun, Aug 2, 1:25 AM
Unknown Object (File)
Sat, Aug 1, 10:46 AM
Unknown Object (File)
Sat, Aug 1, 6:44 AM
Unknown Object (File)
Sun, Jul 26, 12:30 PM
Unknown Object (File)
Sat, Jul 25, 12:30 PM
Unknown Object (File)
Thu, Jul 23, 6:27 AM
Unknown Object (File)
Mon, Jul 20, 10:09 PM
Subscribers

Details

Summary

The function pmap_is_valid_memattr(pmap, mode) checks whether the given variable mode is between the two constant values VM_MEMATTR_DEVICE and VM_MEMATTR_WRITE_THROUGH. After the code for this function was written, the value of VM_MEMATTR_DEVICE changed from 0 to 4. Since VM_MEMATTR_WRITE_THROUGH is still 3, the condition is always false.

This patch changes the condition to check whether mode is equal to any of the VM_MEMATTR* constants.

Diff Detail

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

Event Timeline

Does this patch solve any problem?

Does this patch solve any problem?

Yes. I tried to dump the content of a PCI BAR with:

pciconf -D pci0:0:10:0 0x18 | hexdump

This command failed with EINVAL. It calls pci_bar_mmap(pcidev, pbm) in sys/dev/pci/pci_user.c, which returns EINVAL if pmap_is_valid_memattr(pmap, mode) returns false. With this patch, I was able to dump the content of the PCI BAR.

Does this patch solve any problem?

Yes. I tried to dump the content of a PCI BAR with:

pciconf -D pci0:0:10:0 0x18 | hexdump

This command failed with EINVAL. It calls pci_bar_mmap(pcidev, pbm) in sys/dev/pci/pci_user.c, which returns EINVAL if pmap_is_valid_memattr(pmap, mode) returns false. With this patch, I was able to dump the content of the PCI BAR.

Thanks for pointing that out. The patch looks good to me, but I will give the other reviewers a chance to look at it.

This revision is now accepted and ready to land.Mar 2 2026, 11:40 AM
This revision was automatically updated to reflect the committed changes.