Page MenuHomeFreeBSD

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

Authored by timo.voelker_fh-muenster.de on Thu, Feb 26, 4:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Mar 18, 8:52 AM
Unknown Object (File)
Wed, Mar 18, 4:08 AM
Unknown Object (File)
Wed, Mar 11, 5:19 PM
Unknown Object (File)
Wed, Mar 11, 12:18 PM
Unknown Object (File)
Wed, Mar 11, 9:31 AM
Unknown Object (File)
Mon, Mar 9, 10:38 PM
Unknown Object (File)
Mon, Mar 9, 7:44 PM
Unknown Object (File)
Thu, Mar 5, 4:52 AM
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.Mon, Mar 2, 11:40 AM
This revision was automatically updated to reflect the committed changes.