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

Re: [PATCH V7 07/11] vpci/header: emulate PCI_COMMAND register for guests


  • To: Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 26 Jul 2022 17:30:44 +0200
  • 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=JocGxLVhaQThOw6xbD3S6s9QzLjFqr/F2wA3rOCr5Yc=; b=IFDZVs2Y1qtqe88nYWeGwxhQmFqBxVYpYiJl/p85DpcW7tj/RRAT5PpzTg1tNjvDDtWzHadYRMLNBoZo9bXuq0QwZjTuHVj2rsxKd+fRmYjzeSrfZeQ356u+pO5dwxkQIstfCJMpNYx3IeAYr1ywJ1GKeloZR/ETvu65IuZSgk3kz6egXP3r5eclwaQzcTe0U1HUUBI2Z2T+MY6e3iEitZtuJ6VrgUGmAB3hWvyPOG2CFUZu9ypc4VNJjtoVQoyF9p1JrBQB3Bp1Vx8gCaUxsphjP13S0tjWaCuqlysTD+Ecl+YSUVuXAFy+wDA9HcZmZpcq2JDCGzrC1FMI8mwhgw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AZipmgCRp2BX3J3iZuFTG8m4MboiHhUUMCwBdvAoH+POjktK7uCKofB+777AWgwTP838BYfny4Ule6DDCzB1qoV4KMHoSLDK5H/BvKQ5AI4qvXu64p9ymYL56xAB3udOzfMmp93UjILEzjkLUsREaUHNkRD85y8s7CPEPL4tU5otBakxe0VRHC40BMtIdCOa7W0SUpYPE0amH5jkRglGDqqO0X21+eygCVgQgJJKlhl3a0LdVoyWWi/ceupF+7hqR0iccvuSuK3FQqKIH33ZK1n32arAQ/ZGiIsSI2xCbsV0wRybVuweMKjzd8GgaA2DPghqDLhr2fvFdAaIpIRSRg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 26 Jul 2022 15:30:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 19.07.2022 19:42, Oleksandr Tyshchenko wrote:
> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -443,11 +443,27 @@ static int modify_bars(const struct pci_dev *pdev, 
> uint16_t cmd, bool rom_only)
>      return 0;
>  }
>  
> +/* TODO: Add proper emulation for all bits of the command register. */
>  static void cf_check cmd_write(
>      const struct pci_dev *pdev, unsigned int reg, uint32_t cmd, void *data)
>  {
>      uint16_t current_cmd = pci_conf_read16(pdev->sbdf, reg);
>  
> +    if ( !is_hardware_domain(pdev->domain) )
> +    {
> +        struct vpci_header *header = data;
> +
> +        header->guest_cmd = cmd;
> +#ifdef CONFIG_HAS_PCI_MSI
> +        if ( pdev->vpci->msi->enabled || pdev->vpci->msix->enabled )
> +            /*
> +             * Guest wants to enable INTx, but it can't be enabled
> +             * if MSI/MSI-X enabled.
> +             */
> +            cmd |= PCI_COMMAND_INTX_DISABLE;
> +#endif
> +    }
> +
>      /*
>       * Let Dom0 play with all the bits directly except for the memory
>       * decoding one.
> @@ -464,6 +480,19 @@ static void cf_check cmd_write(
>          pci_conf_write16(pdev->sbdf, reg, cmd);
>  }
>  
> +static uint32_t cf_check cmd_read(
> +    const struct pci_dev *pdev, unsigned int reg, void *data)
> +{
> +    if ( !is_hardware_domain(pdev->domain) )
> +    {
> +        struct vpci_header *header = data;
> +
> +        return header->guest_cmd;
> +    }
> +
> +    return pci_conf_read16(pdev->sbdf, reg);
> +}

This function wants the same leading comment as cmd_write(). I also
think you better wouldn't give the guest the impression that r/o bits
can actually be written to (but getting this right may well fall
under the TODO).

Jan



 


Rackspace

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