Hi, Dan, Dan Williams <dan.j.williams@xxxxxxxxx> writes: > Hi Bjorn, > > Ying is out for the next week or so, so I will address your comments and > resubmit as I think this is a potentially urgent fix. Just come back. Thank you very much for your kind help! > Bjorn Helgaas wrote: >> On Mon, Aug 19, 2024 at 10:34:13AM +0800, Huang Ying wrote: >> > On a system with CXL memory installed, the resource tree (/proc/iomem) [snip] >> > In the above resource tree, "System RAM" is a descendant of "CXL >> > Window 0" instead of a top level resource. So, region_intersects() >> > will report no System RAM resources in the CXL memory region >> > incorrectly, because it only checks the top level resources. >> > Consequently, devmem_is_allowed() will return 1 (allow access via >> > /dev/mem) for CXL memory region incorrectly. Fortunately, ioremap() >> > doesn't allow to map System RAM and reject the access. >> > >> > However, region_intersects() needs to be fixed to work correctly with >> > the resources tree with CXL Window as above. To fix it, if we found a >> > unmatched resource in the top level, we will continue to search >> > matched resources in its descendant resources. So, we will not miss >> > any matched resources in resource tree anymore. In the new >> > implementation, >> > >> > |------------- "CXL Window 0" ------------| >> > |-- "System RAM" --| >> > >> > will look as if >> > >> > |-- "System RAM" --||-- "CXL Window 0a" --| >> >> Where did "0a" come from? The /proc/iomem above mentioned >> "CXL Window 0"; is the "a" spurious? Same question applies to the >> code comment below. > > Not sure where that came from, will clean up and provide a test that can > upstreammed as well. Sorry for confusing! >> > |-- "System RAM" --||-- "CXL Window 0a" --| This isn't the real resource tree. The real resource tree is still >> > |------------- "CXL Window 0" ------------| >> > |-- "System RAM" --| While, >> > |-- "System RAM" --||-- "CXL Window 0a" --| is just used to demonstrate the effect of the algorithm. That is, a part of "CXL Window 0" is covered (or masked) by "System RAM" now. The remaining effective part of "CXL Window 0" is smaller, I used "CXL Window 0a" to designate that it comes from "CXL Window 0", but it's not exactly "CXL Window 0". -- Best Regards, Huang, Ying