On 21.03.2023 10:36, Huang Rui wrote: > On Wed, Mar 15, 2023 at 12:02:35AM +0800, Jan Beulich wrote: >> On 12.03.2023 08:54, Huang Rui wrote: >>> --- a/xen/drivers/vpci/header.c >>> +++ b/xen/drivers/vpci/header.c >>> @@ -392,7 +392,7 @@ static void cf_check bar_write( >>> * Xen only cares whether the BAR is mapped into the p2m, so allow BAR >>> * writes as long as the BAR is not mapped into the p2m. >>> */ >>> - if ( bar->enabled ) >>> + if ( pci_conf_read16(pdev->sbdf, PCI_COMMAND) & PCI_COMMAND_MEMORY ) >>> { >>> /* If the value written is the current one avoid printing a >>> warning. */ >>> if ( val != (uint32_t)(bar->addr >> (hi ? 32 : 0)) ) >> >> ... bar->enabled doesn't properly reflect the necessary state? It >> generally shouldn't be necessary to look at the physical device's >> state here. >> >> Furthermore when you make a change in a case like this, the >> accompanying comment also needs updating (which might have clarified >> what, if anything, has been wrong). >> > > That is the problem that we start domU at the first time, the enable flag > will be set while the passthrough device would like to write the real pcie > bar on the host.
A pass-through device (i.e. one already owned by a DomU) should never be allowed to write to the real BAR. But it's not clear whether I'm not misinterpreting what you said ... > And yes, it's temporary workaround, we should figure out > the root cause. Right, that's the only way to approach this, imo. Jan