[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v5 06/14] vpci/header: implement guest BAR register handlers


  • To: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Mon, 31 Jan 2022 12:27:39 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cfZIS6fa6niDjeBcq7713O/YnxTPZAggOnpIc0e2qoY=; b=HmdDbrDDuqbn61W8SXyK4lwQgmK+Bzv6D4i4jt/0JTV33Erhok/947rGmARkqyeY9Ose8bwKMeuHbFYdgTqH8mr6aix94shhIQEahlavW+EFpDVWrZ3Ut/XfCsuVl4ILi32bCStUUUlJgqsc3fOOUinPi6wCWNo5L/DoRfLkEk5es56PhxMxyQNX2gCPmqEfuCQFM5ZSgySLINimW+MSvh9pwoumYUUITqG1NbmxE0Af1eGK0lcZg9Mk89vO4ufp9W97o4Ps9N2Qq2kFyqGP6aeGdzBYfWw8FkRH0X8NNRV2lIA1dElPRpIwGRhqzPwixxXCE47NWDILkbzHUqJGEQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/nNh0XYppO+b8+hXEvu2zGZY9Qz5FwBy74Fsq1jCePBOJNyr6ePhyxBjYYBpgokWnH3kLI+l0e/GONAzL+nibzwjaVDOEOf6lPSbRuPCsB3xmpDK7zbqidspyQYMHUu6hoxurTjqVJPFez4Xt5MHfEjTTzrnvLvM1JwV5MYam9nvlJ8RdsEBzaYPRCSfGxcMgtztOTmida1K1M17jjJfra2dhjZw/zHpe9dneh3ppxH+nl+XuPkh/I+m6vxmVc1EHiSimH3PGt91TviHFvmOotV/TGsy569JS2SaZNd8KKSNtVTSYBqoXNFwGXtydDwS9qJ+tkxWHG4fd6SN2dLbw==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "julien@xxxxxxx" <julien@xxxxxxx>, "sstabellini@xxxxxxxxxx" <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <Oleksandr_Tyshchenko@xxxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Artem Mygaiev <Artem_Mygaiev@xxxxxxxx>, "andrew.cooper3@xxxxxxxxxx" <andrew.cooper3@xxxxxxxxxx>, "george.dunlap@xxxxxxxxxx" <george.dunlap@xxxxxxxxxx>, "paul@xxxxxxx" <paul@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>
  • Delivery-date: Mon, 31 Jan 2022 11:27:56 +0000
  • Ironport-data: A9a23:2OZJWa7Vrm9e2YvRvveKlQxRtAzBchMFZxGqfqrLsTDasY5as4F+v jRLUW2EP6vZYGamKdBwOY60pxxSuZfXm4NmGQA4/ig1Hi5G8cbLO4+Ufxz6V8+wwmwvb67FA +E2MISowBUcFyeEzvuV3zyIQUBUjclkfJKlYAL/En03FV8MpBsJ00o5wbZg2dcw2LBVPivW0 T/Mi5yHULOa82Yc3lI8s8pvfzs24ZweEBtB1rAPTagjUG32zhH5P7pGTU2FFFPqQ5E8IwKPb 72rIIdVXI/u10xF5tuNyt4Xe6CRK1LYFVDmZnF+A8BOjvXez8CbP2lS2Pc0MC9qZzu1c99Zz sRXkMSLUikTEqD0hv1DdxxnEwhgIvgTkFPHCSDXXc27ykTHdz3nwul0DVFwNoodkgp1KTgQr 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QpokGaOvRYM61QkQMIAcFb/iY0a1GkDfl8vlocl7x4zV6/eTbXBwKbQWMkiFUMJB8LJghn bU6oMcT5gHm0kgqP9+Kgzp67WOJKnBcAawruotDWN3gixYxy0EEapvZU3ek7JaKYtRKE08rP j7L2/aS2+UCnhLPKiNhG2LM0OxRgYU1lCpLlFJSdU6Untflh+Ms2EED+zoAUQkInA5M1Ph+O zY3OhQtd7mO5TphmONKQ3uoR1NaHBSc90H8lwkJmWneQxX6X2DBNjRga+OE/URf+GNAZDlLu rqfzT+9Azrtecjw2Ao0WFJk9KO/HYAgqFWalZD1BdmBErk7fSHh0/2namc/ohf6Bd882R/cr u5w8ecsMaD2OEb8eUHg51V2AVjIdC25GQ==
  • Ironport-hdrordr: A9a23:KUZuha/Wp9M5DHbDxVpuk+DhI+orL9Y04lQ7vn2ZHyYlFvBw5P rOoB1773DJYVkqNE3I9errBEDEewK+yXcX2+Is1NWZPDUO0VHARL2Kr7GSoQEIcBeOk9K1u5 0MT0AgY+eAamSTxKzBjjVQuexQpuW6zA==
  • Ironport-sdr: RoIYAWQB8g5cy/2vulw/TtIpwO5xoK92KLDb0LCpslVqWJxmPvIEgxDRxGkwJLSrlRsiEBOk2D m/1cMplfmYiDQ80dcE3LIvCYcJaRtWtSRbJQm0T2ikc/YyK0135JPPfS3/G76Zk6/DPBYMNrsk VnjJYcJrMADAyPtNS+5ZFB+r2YINoZKcIuFBC9q3JXZaKbdtIz3WyJFqUqJz4f3rbXaPDnY+V0 EUz7PgYqrOuL6unTZ2f/loCcTn2cx2nZ74NOv21bGH4Bto1ICWaAxo+WcJ2ayvWjS7gqxI6jU2 Cjw1DzzaWa8hF91ZZg3bp8U1
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Jan 31, 2022 at 11:04:29AM +0000, Oleksandr Andrushchenko wrote:
> Hi, Jan!
> 
> On 31.01.22 12:54, Jan Beulich wrote:
> > On 31.01.2022 11:40, Oleksandr Andrushchenko wrote:
> >> On 31.01.22 11:47, Oleksandr Andrushchenko wrote:
> >>> Hi, Roger!
> >>>
> >>> On 12.01.22 14:35, Roger Pau Monné wrote:
> >>>>> +static void guest_rom_write(const struct pci_dev *pdev, unsigned int 
> >>>>> reg,
> >>>>> +                            uint32_t val, void *data)
> >>>>> +{
> >>>>> +}
> >>>>> +
> >>>>> +static uint32_t guest_rom_read(const struct pci_dev *pdev, unsigned 
> >>>>> int reg,
> >>>>> +                               void *data)
> >>>>> +{
> >>>>> +    return 0xffffffff;
> >>>>> +}
> >>>> There should be no need for those handlers. As said elsewhere: for
> >>>> guests registers not explicitly handled should return ~0 for reads and
> >>>> drop writes, which is what you are proposing here.
> >>> Yes, you are right: I can see in vpci_read that we end up reading ~0 if no
> >>> handler exists (which is what I do here with guest_rom_read). But I am 
> >>> not that
> >>> sure about the dropped writes:
> >>>
> >>> void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
> >>>                    uint32_t data)
> >>> {
> >>>        unsigned int data_offset = 0;
> >>>
> >>> [snip]
> >>>
> >>>        if ( data_offset < size )
> >>>            /* Tailing gap, write the remaining. */
> >>>            vpci_write_hw(sbdf, reg + data_offset, size - data_offset,
> >>>                          data >> (data_offset * 8));
> >>>
> >>> so it looks like for the un-handled writes we still reach the HW register.
> >>> Could you please tell if the code above needs improvement (like checking
> >>> if the write was handled) or I still need to provide a write handler, e.g.
> >>> guest_rom_write here?
> >> Hm, but the same applies to the reads as well... And this is no surprise,
> >> as for the guests I can see that it accesses all the configuration space
> >> registers that I don't handle. Without that I would have guests unable
> >> to properly setup a PCI device being passed through... And this is why
> >> I have a big TODO in this series describing unhandled registers.
> >> So, it seems that I do need to provide those handlers which I need to
> >> drop writes and return ~0 on reads.
> Replying to myself: it is still possible to have vpci_ignored_{read|write}
> to handle defaults if, when vpci_add_register is called, the handler
> provided is NULL
> > It feels like we had been there before: For your initial purposes it may
> > be fine to do as you suggest, but any such patches should carry RFC tags
> > or alike to indicate they're not considered ready. Once you're aiming
> > for things to go in, I think there's no good way around white-listing
> > what guests may access. You may know that we've been bitten by starting
> > out with black-listing in the past, first and foremost with x86'es MSRs.
> I already have a big TODO patch describing the issue. Do you want
> it to have a list of handlers that we support as of now? What sort of
> while/black list would you expect?
> I do understand that we do need proper handling for all the PCI registers
> and capabilities long term, but this can't be done at the moment when
> we have nothing working at all. Requesting proper handling now will
> turn this series into a huge amount of code and undefined time frame.

We should at least make sure the code added now doesn't need to be
changed in the future when the default is switched. If you don't
want to switch the default handling for domUs to ignore writes and
return ~0 from reads to unhandled registers right now you should keep
the patches that add the ignore handlers to the end of the series and
mark them as 'HACK' or some such in order to notice they are just
used for testing purposes.

Thanks, Roger.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.