On 2/12/26 13:49, Laine Stump wrote:
> I took a look through that code and saw that it's using a very 
> inefficient method of traversing the PCI topology to visit all the 
> parents of the device being assigned and have an idea for simplifying it 
> that I want to try out (unless someone else beats me to it) - basically 
> instead of iterating through every singe PCI device each time we look 
> for the parent of the current device, we can just resolve the symlink 
> for the device directory, e.g.
> 
>   /sys/bus/pci/devices/0000:08:00.3
> which will give us something like:
> 
>   
> /sys/devices/pci0000:00/0000:00:01.2/0000:02:00.0/0000:03:08.0/0000:08:00.3
> 
> (an example from one of my machines. Sorry for any line breaks - stupid 
> email client :-/)
> 
> Once you have that path, you just break it down into the individual 
> components, and that is the entire tree of "ancestors" for the endpoint 
> device that need to be checked for ACS (and when you get to the 
> component that is "pci0000:XX", that means you're at the root complex 
> and so you're done.

This looks very good yes, and probably way faster than the initial design.

In addition to the lines changed in the proposed initial patch, you can find 
around line 1146 of virpci.c a test that induce a specific behaviour if the 
device is connected to the root complex. So if you can look at that part too, 
it would be marvelous!

> If my ADHD brain hasn't forgotten it by the time I wake up tomorrow, 
> I'll try refactoring the code to do this (and then artificially 
> re-enable the ACS check for VFIO so I can actually test it :-).

I will be more than happy to help you to test. Qubes R4.3.0 is using libvirt 
version 10.5.2 but I assume virpci.c source file had not that much changed 
since then.

Bertrand

Reply via email to