On Fri, 25 Mar 2022 at 07:14, Bin Meng <bmeng...@gmail.com> wrote: > > On Sun, Mar 20, 2022 at 7:42 PM Andrew Scull <asc...@google.com> wrote: > > > > Add a function to convert a PCI address range to a physical address > > range. The address range is validated to ensure it is contained within > > one of the PCI address regions and that the whole range can be indexed > > from the resulting physical address. > > I am not sure if we need to provide such an API given there is already > dm_pci_bus_to_phys() and friends. Not sure we really need this new API > to add a check against the range. ... > If we really need this, I believe we can do some refactoring on the > existing _dm_pci_bus_to_phys() to provide the new capability you > wanted.
A big reason is to check the range fits in the region, not just a single pointer. It looks like evolving the existing API might not be too tricky for that. The bit that really caused me trouble was that the PCI driver adds system memory as identity mapped regions. But that system memory hasn't been declared as part of the PCI bus so why is it being added? I want to remove that but don't know the background, or have the ability to test PCI will still work properly. We can't allow a virtio device to claim it has buffers in the middle of system memory and then have the driver blindly corrupt that region of memory, so there'll need to be a way to prevent that. > > + * @size: Size of the addressrange > > need a space before 'range' Ack. > Please add a test case in test/dm/pci.c to cover this new API. I was just learning about the sandbox testing, I'll take a look.