[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: Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Date: Tue, 2 Nov 2021 10:48:18 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.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=brPnHj7mXniA8xFQaXIirWOF0xVoPP44xmFnPmgiA44=; b=XAT6SSguMmTIUnRhwTdDA4UiBFmXCctBloMwLGyyl1Ucx+rYpoYcdefFEEvyMvSmiFv2yqy9uInkwDebkd0R6zACQIbkdpiY/hUlTQuT7JUYjTwN/wo3IPg6lc55DIBuxQAF8I/8O6szL9+CEtWGAeW9fVT4FPXXMMLqNZbc9/huM6wuo4q7XtZk9Q6bX8QHxV4W6yklj4C1CF4RVUSseUEboSyFpgmzqAgAJuG7exdKwpgXmdk64YZQZvl/wCw4CEWKc9whevWKJYFlVu9pMGq41aBIpb8yEY64n95bjd5vTBonvMet3iEeEVhbzVeVAkrnlTpvTRn6TSsJreCctQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bWTMhWAisbug5goOpWwhnk4Ff2KnRq9V/ScyxfrnP+8DoOLL5137caRo3xUEzeVgkYvJiDvAjiTEhoZKj6gLHAslSyVJ4aEhBXxBKaZ6dt2ii9k35yzq1QNYoJ97xU/NfwKV/8zWZcMLrvet7VJFOEyWkUuclfglkz5NW93Fo5/W+norx6JfALSsuE0QA5J25ZvkFmLg396jQvx1XHnrHegu6loJHExNAireSsiFmXCsU4mt/f02G4kihxyKCFvezzl4mXm6l57kWwtQs48mz/qCWBF+JNePAz/ycjXzbr9lWNZwFN5B8E4SuxyBJ9PQgCSHdjMRYtsYU3lfi0tHNQ==
  • Cc: "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>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Oleksandr Andrushchenko <Oleksandr_Andrushchenko@xxxxxxxx>
  • Delivery-date: Tue, 02 Nov 2021 10:48:43 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHXtdAkq8Qmwxr3HUWTio8KWsEpvKvlQ6KAgAr/CAA=
  • Thread-topic: [PATCH v3 08/11] vpci/header: Emulate PCI_COMMAND register for guests

Hi, Roger!

On 26.10.21 13:52, Roger Pau Monné wrote:
> On Thu, Sep 30, 2021 at 10:52:20AM +0300, Oleksandr Andrushchenko wrote:
>> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>>
>> Add basic emulation support for guests. At the moment only emulate
>> PCI_COMMAND_INTX_DISABLE bit, the rest is not emulated yet and left
>> as TODO.
>>
>> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>
>> Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
>> ---
>> New in v2
>> ---
>>   xen/drivers/vpci/header.c | 35 ++++++++++++++++++++++++++++++++---
>>   1 file changed, 32 insertions(+), 3 deletions(-)
>>
>> diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
>> index f23c956cde6c..754aeb5a584f 100644
>> --- 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.
This is not arch specific as we just do not allow INTx to be enabled
if MSI/MSI-X has been enabled before. This was discussed previously
(Jan) and this was pointed as an acceptable approach to limit the
guest from having inconsistent configuration
>
> I really wonder if we should allow the guest to play with any other
> bit apart from INTx disable and memory and IO decoding on the command
> register.
This needs to be implemented one day when we understand what
this emulation should look like. This is why I have a "TODO" above.
>
> Thanks, Roger.
Thank you,
Oleksandr

 


Rackspace

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