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
F152962559: D55534.id172777.diff
Sat, Apr 18, 8:48 AM
Unknown Object (File)
Wed, Apr 8, 5:13 AM
Unknown Object (File)
Mon, Apr 6, 6:56 PM
Unknown Object (File)
Sun, Apr 5, 4:57 AM
Unknown Object (File)
Thu, Apr 2, 7:57 PM
Unknown Object (File)
Mar 18 2026, 8:52 AM
Unknown Object (File)
Mar 18 2026, 4:08 AM
Unknown Object (File)
Mar 11 2026, 5:19 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.