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

Re: [PATCH v3 4/4] xen/vpci: header: status register handler


  • To: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 22 Aug 2023 15:54:58 +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=4pqM5/Nkh7/MlsZwIxGpRCzb6J9NexECHN3wo8sweNg=; b=neUmVJAD2pCAdzgu0T14QBUIZnQeO6/8BbZxqejAJJUHhk98c684+qu8e0amIdbKZAEUI+Q4MBR91LeE3Thq1dTWRrMAJn3OF2XFPB3VRzxbFVINUp/9sNX0nZ0crTPx1kOIVJ759fFNWqdWMVsrUn6QvzRmq9goDo22nprzI9GWpTHtzwK4wvHJGL6AOb+PbSp6OOROKaQDgL3U/Vlp6670dPAGATXh0Tb80gYpezPdXWYWHoG4/CGu+841Kdgk2K6T1jOeHBn11BNsYv6QiGO7ph5msR0pEL/ByiSPzvCO0I5EN37Y+ai/mOAXlj3E9uv6vNrGW8yb3yxIyJYE4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jU5WKzGC/GgC+Lam+S/vMDhYBwqBTsm8HR/BS7Z+cEYurQlRDDLYD7wB4hIcUHClSVHZekhXUPzKw7J3A4bUIkZiFx4/NAw3hrGc8fJnWQuJB1I94RJhIrgi+YsjlEGIMYxpYpBQxRoOIFlqR4EDpKEo4l63I8kmMt991nVamfN5luFlxCcX7tuPO8Y6FhzurGxHnQpZloK0scOjPJiqotCsb3/++PysRM92/qd9gtZYZeqtYiKC/GNwPS0Jq/JyqX1qkxZ8/bo9reOmWdiD8sI77w35/ahFry07p3GCYFwztPNPCm6dNDHSNIRVouM95cfH6xA9eMbUZZfUiU8iow==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 22 Aug 2023 13:55:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 22.08.2023 03:29, Stewart Hildebrand wrote:
> Introduce a handler for the PCI status register, with ability to mask the
> capabilities bit. The status register is write-1-to-clear, so introduce 
> handling
> for this type of register in vPCI.
> 
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
> ---
> v2->v3:
> * new patch

This being a prereq to the cap list filtering, I think the order of the
patches wants to be inverted.

> --- a/xen/drivers/vpci/header.c
> +++ b/xen/drivers/vpci/header.c
> @@ -413,6 +413,17 @@ static void cf_check cmd_write(
>          pci_conf_write16(pdev->sbdf, reg, cmd);
>  }
>  
> +static uint32_t cf_check status_read(const struct pci_dev *pdev,
> +                                     unsigned int reg, void *data)
> +{
> +    struct vpci_header *header = data;
> +
> +    if ( header->mask_cap_list )
> +        return pci_conf_read16(pdev->sbdf, reg) & ~(PCI_STATUS_CAP_LIST);

No need for parentheses around a constant.

> +    return pci_conf_read16(pdev->sbdf, reg);

I think this function would better issue the read just in a single place,
and then do any fiddling that may be needed.

> @@ -556,6 +567,11 @@ static int cf_check init_bars(struct pci_dev *pdev)
>      if ( rc )
>          return rc;
>  
> +    rc = vpci_add_rw1c_register(pdev->vpci, status_read, vpci_hw_write16,
> +                                PCI_STATUS, 2, header);

Is it really correct to treat the entire register as rw1c, and with write-
through to hardware for all bits? There are reserved bit there, and -
however likely that may seem - it's guesswork whether they would also end
up r/o or rw1c once getting assigned some meaning.

> --- a/xen/drivers/vpci/vpci.c
> +++ b/xen/drivers/vpci/vpci.c
> @@ -29,6 +29,7 @@ struct vpci_register {
>      unsigned int offset;
>      void *private;
>      struct list_head node;
> +    bool rw1c : 1;
>  };

I'm not the maintainer of this code, so what I say here may be void, but
generally we have blanks to the left and/or right of colons in bitfield
declarations only when we mean to pad for alignment with other nearby
bitfields.

> @@ -205,6 +213,22 @@ int vpci_add_register(struct vpci *vpci, vpci_read_t 
> *read_handler,
>      return 0;
>  }
>  
> +int vpci_add_register(struct vpci *vpci, vpci_read_t *read_handler,
> +                      vpci_write_t *write_handler, unsigned int offset,
> +                      unsigned int size, void *data)
> +{
> +    return _vpci_add_register(vpci, read_handler, write_handler, offset, 
> size,
> +                              data, false);
> +}
> +
> +int vpci_add_rw1c_register(struct vpci *vpci, vpci_read_t *read_handler,
> +                           vpci_write_t *write_handler, unsigned int offset,
> +                           unsigned int size, void *data)
> +{
> +    return _vpci_add_register(vpci, read_handler, write_handler, offset, 
> size,
> +                              data, true);
> +}

I'm always a little irritated by local functions still retaining the
subsystem prefix. Just add_register() for the now static helper would
imo be enough here and overall shorter to read/type.

> @@ -433,9 +452,11 @@ static void vpci_write_helper(const struct pci_dev *pdev,
>  
>      if ( size != r->size )
>      {
> -        uint32_t val;
> +        uint32_t val = 0;
> +
> +        if ( !r->rw1c )
> +            val = r->read(pdev, r->offset, r->private);

Along with the earlier question: Doesn't rw1c need to be a bit mask,
not a single boolean covering the entire register?

> @@ -99,6 +106,8 @@ struct vpci {
>           * upon to know whether BARs are mapped into the guest p2m.
>           */
>          bool bars_mapped      : 1;
> +        /* Store whether to hide all capabilities from the guest. */
> +        bool mask_cap_list : 1;

I think the intention here is for the colons to align.

Jan



 


Rackspace

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