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

Re: [PATCH v3 08/11] vpci/header: Emulate PCI_COMMAND register for guests


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 2 Nov 2021 12:50:10 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; 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=G+yQ8/y5sayzRStPWYzSe98D7nsZ/KIY5dztZJpKUBk=; b=l1erpj3JkzepKWXxc25PIzXuUjLwVkgw82POf+PBCoWariLuUH9eyZfLPNCC5WWylTqMSs5Yd0jjsaGpXJg6AoJ8VNW30FrqnAtlRZhw5MM8KP0OmmUCuPVhKZZCk0s9SekWacxaGPvSO7zHOOu9VJenxEk9ZXQHZhwPWDRZwrWEE2hC/NSPfGSDz21iE0yJCs5o7F+e9aiaAyFOt7YyMjyNP2syTzsI+NgsUywGaUg2pvRdL/Qav3kbn+uRiz0kvapWyNBeaXJRr1LVJFqpeqPSbzm1q7uEBlXaLfuQVUxOygGFbN3GPlxxiJCvti0XeMQiG8Tm9LXXWhslULB5kg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FCxEhMU5qaI8O7bOlumbD2Oq950TI1W6r8e2CJRUtpV8CDjNS86AIzFli0Ots7FK2CtfV0ClxM22+uof7zxyjHJcbe4v9tgsJxYNqDM3N2SUGdLrHOCIqnlMtQI4M7Md5VDgHnxW8LNl4eFwYY9w9QXsHbfPNc2sN9HCdS9jeeA7i1Sx7CZ6r0VudwrVScXFFgu8rdUQ/mNexj4dB8urjRmlGysaDBvNxBymi7PDLFdOpFPsMGUaKZhFsikUwraTOP44L9FX+zkqQovoE7FLS7NnQP8G3J8PPizYcNKnnMyagUTTAY2JBmWszGcTGvsmjR6dvJgrC+RDrPwYQH65jQ==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <julien@xxxxxxx>, <sstabellini@xxxxxxxxxx>, <oleksandr_tyshchenko@xxxxxxxx>, <volodymyr_babchuk@xxxxxxxx>, <Artem_Mygaiev@xxxxxxxx>, <bertrand.marquis@xxxxxxx>, <rahul.singh@xxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • Delivery-date: Tue, 02 Nov 2021 11:50:37 +0000
  • Ironport-data: A9a23:+0d6matEHjFWxT/O5eqbsqxjZefnVJdYMUV32f8akzHdYApBsoF/q tZmKTyPaPvZYDP1f9t/b4W0oUhUup7QzoQxGQs6+yhkRXwa+JbJXdiXEBz9bniYRiHhoOOLz Cm8hv3odp1coqr0/0/1WlTZQP0VOZigHtIQMsadUsxKbVIiGHhJZS5LwbZj29cx2YLhWmthh PupyyHhEA79s9JLGjp8B5Kr8HuDa9yr5Vv0FnRnDRx6lAe2e0s9VfrzFonoR5fMeaFGH/bSe gr25OrRElU1XfsaIojNfr7TKiXmS1NJVOSEoiI+t6OK2nCuqsGuu0qS2TV1hUp/0l20c95NJ Npl5LatVVgrJf3wk9sWSBV/VDBmEqsB5+qSSZS/mZT7I0zudnLtx7NlDV0sPJ1e8eFyaY1M3 aVGcnZXNEnF3r/ohuLgIgVvrp1LwM3DJoQQt2sm1TjEJf0nXYrCU+PB4towMDIY258UQ66GP JZxhTxHPT+bOkZ2JUstUcgbpb643Fz5XzwIpwfAzUYwyzeKl1E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RuN5E8dmkf8Ke8YmQEGQgg3U16wY4ettZmvXdxRBj5 /1ey3IMOn6lCb2zSpNnOLcoT+7+P7sNaNhhjk4apwZrGZVIwoh1Jd4vasr5zKmz5SzNg3kJ82m IqefYaiEIULPjFci7w9PQYfmZPixZk2kWhOhTwrn04rtg3rEI3quVs/utcegdDE+Q0MDFRDI79 gWJKdWuq6l5LwZqLj98E+jdP
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Nov 02, 2021 at 12:19:13PM +0100, Jan Beulich wrote:
> On 26.10.2021 12:52, Roger Pau Monné wrote:
> > On Thu, Sep 30, 2021 at 10:52:20AM +0300, Oleksandr Andrushchenko wrote:
> >> --- a/xen/drivers/vpci/header.c
> >> +++ b/xen/drivers/vpci/header.c
> >> @@ -451,6 +451,32 @@ static void cmd_write(const struct pci_dev *pdev, 
> >> unsigned int reg,
> >>          pci_conf_write16(pdev->sbdf, reg, cmd);
> >>  }
> >>  
> >> +static void guest_cmd_write(const struct pci_dev *pdev, unsigned int reg,
> >> +                            uint32_t cmd, void *data)
> >> +{
> >> +    /* TODO: Add proper emulation for all bits of the command register. */
> >> +
> >> +    if ( (cmd & PCI_COMMAND_INTX_DISABLE) == 0 )
> >> +    {
> >> +        /*
> >> +         * Guest wants to enable INTx. It can't be enabled if:
> >> +         *  - host has INTx disabled
> >> +         *  - MSI/MSI-X enabled
> >> +         */
> >> +        if ( pdev->vpci->msi->enabled )
> >> +            cmd |= PCI_COMMAND_INTX_DISABLE;
> >> +        else
> >> +        {
> >> +            uint16_t current_cmd = pci_conf_read16(pdev->sbdf, reg);
> >> +
> >> +            if ( current_cmd & PCI_COMMAND_INTX_DISABLE )
> >> +                cmd |= PCI_COMMAND_INTX_DISABLE;
> >> +        }
> > 
> > This last part should be Arm specific. On other architectures we
> > likely want the guest to modify INTx disable in order to select the
> > interrupt delivery mode for the device.
> 
> We cannot allow a guest to clear the bit when it has MSI / MSI-X
> enabled - only one of the three is supposed to be active at a time.
> (IOW similarly we cannot allow a guest to enable MSI / MSI-X when
> the bit is clear.)

Sure, but this code is making the bit sticky, by not allowing
INTX_DISABLE to be cleared once set. We do not want that behavior on
x86, as a guest can decide to use MSI or INTx. The else branch needs
to be Arm only.

Regards, Roger.



 


Rackspace

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