[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 12:19:13 +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=wIDlbItKtfut8ntP/9O/LHcTw/BL35ttBixEbpYSAQE=; b=cXxNLIPdybwkVlpu+OCtmSUosiZHR+zn6WHayk+UeI+K8STvFHf/HIhMyT2dEiwbU1mEpIgMFtybQltiqMNNOCXpyALA2AWmnaAWraFiICrVXT8pyXfuPGJG2PJDL1CO8LZ5x1Pw1i+IcOQc1m/tbYfqmkwMDerzSYjsL3bjSzCVoweRZJ+mwyND3/ZVY2UOvoD9yewRamP2oGH8STXsVZ2zakK/yKpgfhH0bRNiwc38yKm4lXgLGS1uqTaBxAPwBpWvetQz0U/atchx0atE0UT0c7IcDGKUuL1vZrbm/aAx0DdJMuAmLB16j/f9v+fbihhPAfzBpThf82HGuxwDtw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HhYF4LlqA0BZzEkC3donEphmtQsa92pIiP+jhqLEB3bjAOLCPsXoJ3/lS5Y31TbyXNKIqdQagS7RYfApepDApSf8UVAUcMnyxs+TRQYaj+bpja113NB/y1lZ+mDId2/HV1/THh+P7dqNm8iwRl/08ucR0R8RJPBCWGwkVPmPQ8/ZJyk+vk0G6G2OAcF2CgSSEPAY6e2hEfeQiTpcnXi0dN7Ic6aGCzM83UMbCUT7tYRZKWkUNUH7B4iJc9fhAsj6T3vNfirUOqqCMZ0MrKZaV/kr2mCPhBFK1b9wRTErIWMUx5+WKNKlX1f664AeRQhB5y3hCPeBDarGvSUb2X+KnA==
  • 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 11:19:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.)

Jan




 


Rackspace

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