On Wed, 28 Sep 2016, Andre Przywara wrote:
> The MAPD command maps a device by associating a memory region for
> storing ITTEs with a certain device ID.
> We just store the given guest physical address in the device table.
> We don't map the device tables permanently, as their alignment
> requirement is only 256 Bytes, thus making mapping of several tables
> complicated. We map the device tables on demand when we need them later.
> 
> Also we propagate the MAPD request to the hardware ITS, as the device ID
> is only meaningful there.
> 
> Signed-off-by: Andre Przywara <andre.przyw...@arm.com>
> ---
>  xen/arch/arm/vgic-its.c | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
> 
> diff --git a/xen/arch/arm/vgic-its.c b/xen/arch/arm/vgic-its.c
> index caad320..83d47e1 100644
> --- a/xen/arch/arm/vgic-its.c
> +++ b/xen/arch/arm/vgic-its.c
> @@ -250,6 +250,34 @@ static int its_handle_mapc(struct virt_its *its, 
> uint64_t *cmdptr)
>      return ret;
>  }
>  
> +static int its_handle_mapd(struct virt_its *its, uint64_t *cmdptr)
> +{
> +    uint32_t devid = its_cmd_get_deviceid(cmdptr);
> +    int size = its_cmd_get_size(cmdptr);
> +    bool valid = its_cmd_get_validbit(cmdptr);
> +    paddr_t itt_addr = its_cmd_mask_field(cmdptr, 2, 0, 52) & GENMASK(51, 8);
> +
> +    if ( !its->dev_table )
> +        return -1;

We should validate devid, size and itt_addr?


> +    spin_lock(&its->its_lock);
> +    if ( valid )
> +        its->dev_table[devid] = DEV_TABLE_ENTRY(itt_addr, size + 1);
> +    else
> +        its->dev_table[devid] = 0;
> +
> +    spin_unlock(&its->its_lock);
> +
> +    /* DomUs (will later) have their ITTs allocated at domain creation time,
> +     * when Dom0 configures the passthrough.
> +     */
> +    if ( its->hw_its )
> +        return gicv3_its_map_device(its->hw_its,
> +                                    its->d, devid, size + 1, valid);
> +
> +    return 0;
> +}
> +
>  #define ITS_CMD_BUFFER_SIZE(baser)      ((((baser) & 0xff) + 1) << 12)
>  
>  static int vgic_its_handle_cmds(struct domain *d, struct virt_its *its,
> @@ -279,6 +307,9 @@ static int vgic_its_handle_cmds(struct domain *d, struct 
> virt_its *its,
>          case GITS_CMD_MAPC:
>              its_handle_mapc(its, cmdptr);
>              break;
> +        case GITS_CMD_MAPD:
> +            its_handle_mapd(its, cmdptr);
> +         break;
>          case GITS_CMD_SYNC:
>              /* We handle ITS commands synchronously, so we ignore SYNC. */
>           break;
> -- 
> 2.9.0
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to