[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: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 2 Nov 2021 14:54:57 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.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=sDJJXcbOjoNhtlX3l+dZOaDpJsCSpTQRdsvnz7Znqks=; b=O1TBVpYfzDU4fq9IJ3yN+G0LBpAVgQTMfZRnV97w++JFX5/XW8Rfs3vbwPWF5v1XVRuh4XnOoeSyjEFEpRPUQThuOuOusFgVTSiU2R1TOxa67I4b9V2a0PQb3TOacXih7GkH2WxUlF5tPqBDUuxHYqsHE3GkeINODgJ3M+tODQdMq1jt9y6RhIcN67I6Ud6KQfFXS15miXpqHHPCILLFu8gjx7t8wZLvO7GkUsXgswJ8AqXlMPpsjmwQLJrJxgy99rDi4t+cNcxT2Qp5oCVF4zS/HIvwHn86cAIJJylncfQ+PPuxxKwiSqwaq1atoq0rxHr12Y+L0kcyiBlwl7KTGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SUQWbsLbDZoqWAmVwIY003yXBGQhjzidMp1JIaN3VVgT7mtwHvVtE+p1YEKyRjjxz0lNRIkufasWIUwz9QjnQMcGEZSI/kWbYX23/HfHI0u+MMxH0ZxL2JT67xwIDYBbTjg9Js2xbsxkV6CHKxZdBBZuMjkADX+Ru6terU3zfUwsJ5M1Cvpgt87xRCWkisZIsP22Tm20XrbGvuonOSzmFiX0Cf7Z6Mvx99IfnViIX7tzVo01nyo2b5tsuuv8xCqQqN+woAO4GWO3Qs2JyBz6+VorKESEVzdBKsjthtvh01CS5sMIYxoMG1DzUxX4R9yeSdFR1Ir8MWhxszP9M0dwhg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.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 13:55:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.11.2021 12:50, Roger Pau Monné wrote:
> 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.

Isn't the "else" part questionable even on Arm?

Jan




 


Rackspace

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