[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: Oleksandr Andrushchenko <andr2000@xxxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 26 Oct 2021 12:52:55 +0200
  • 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=e0DJg+hmraSsp8QGZrIvJEFGWWT2wGpKz3HFb+iX8R0=; b=V1rJYduwde98LvNxS2RrVs7zxhaq9NaCMbD4K25QfzXJTGGqMMz6TjK1l5WAUbj7IlrDZbVOj7wOUc9p6n4UnNoNJEPazpXYRtfcltKOcU+P48S0hYdOXF1WLN3/mj3Vw2BCHNHXUC3KWbkra3RIPx3Xq/F7xyqBM9CompLDDdavdfkIA3jm/bvRj2nJcCpXe1D4R90+/UXgRSH4mfXk1dE/owQMRBAYNKjInVPTNqkzhtzKyKgiLts7L+vBg6DucY5mdQqJ0DncBCG3SlzVZKDI2LkxdIpMIr7lRgql23lQ8A+1+hZ1GBGzoJP5i5h4q5+ZR9Zc/yHY9wqMV8lqEQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TwjjJ7jCW4N/rz5FpUZE3MPzOaYqhc33Up0QHLm0Ypq67CTJED0X6FxAJO5vKUWEz1Oo7/9xcrnH0kiulNtYtCA4HubZYaHD1SglkY1sR2ubYgyrQHZiEiB/Vf5b/0lMmUyenMrA7vi0KWtg3qdYK/+Kpdkp7I20mQKKciJDbhjzDr7ZVJySGMrVl5A/OplUKcal0X/ZG46N+GRo3vAix3O+R4ocJlMJZpOc+zuUjI5/aDFpL6v9oAIzl719GPy+iMSfgMDgo5Fs5DqSSFHRMofFxxCsrvF2W0I6YlsKMZcDEeiFr0ntJ9E6mg5ryKDE8JjAQRC937QvzuuiKnRJYA==
  • 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>, <jbeulich@xxxxxxxx>, <bertrand.marquis@xxxxxxx>, <rahul.singh@xxxxxxx>, Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>
  • Delivery-date: Tue, 26 Oct 2021 10:53:17 +0000
  • Ironport-data: A9a23:6Zl/UaCzoFmoIBVW/xLlw5YqxClBgxIJ4kV8jS/XYbTApDt23jwPm jNJXDuHOauJMzH1etl+aYu29UkAu5LVyN5hQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WLGs1hxZH1c+EX5500w7wYbVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/sCmCg4p46 u5xh43tTxo1G6TqkeQ0ekwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHvuWu4YAg21YasZmN6/ON +kEWCtTYQmHbgZEeVsmS5cntbL97pX4W2IB8w/EzUYt2EDZwRZtyr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jo1GtAM7U1hDum09ol8KVU22f5LIbF3BHI3kEIAnQSB4zak5avJCkDakCamDhExl6jf7t1I11B tU4QPrXpgKJyHldrGxbX2whndU9PkvEd1UseFFZPv9sO9hLD0dbaOt9s8CU+ChgSe9mMFPPGjW dinNeZU48ADmvVWg1X8/1DGR
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

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.

Thanks, Roger.



 


Rackspace

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