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

Re: [Xen-devel] [PATCH v6 08/36] ARM: vGICv3: introduce ITS emulation stub



On Fri, 7 Apr 2017, Andre Przywara wrote:
> Create a new file to hold the emulation code for the ITS widget.
> This just holds the data structure and a init and free function for now.
> 
> Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>


> ---
>  xen/arch/arm/Makefile            |  1 +
>  xen/arch/arm/vgic-v3-its.c       | 86 
> ++++++++++++++++++++++++++++++++++++++++
>  xen/arch/arm/vgic-v3.c           |  8 +++-
>  xen/include/asm-arm/gic_v3_its.h | 13 ++++++
>  4 files changed, 107 insertions(+), 1 deletion(-)
>  create mode 100644 xen/arch/arm/vgic-v3-its.c
> 
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 6be85ab..49e1fb2 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -47,6 +47,7 @@ obj-y += traps.o
>  obj-y += vgic.o
>  obj-y += vgic-v2.o
>  obj-$(CONFIG_HAS_GICV3) += vgic-v3.o
> +obj-$(CONFIG_HAS_ITS) += vgic-v3-its.o
>  obj-y += vm_event.o
>  obj-y += vtimer.o
>  obj-y += vpsci.o
> diff --git a/xen/arch/arm/vgic-v3-its.c b/xen/arch/arm/vgic-v3-its.c
> new file mode 100644
> index 0000000..2f1a255
> --- /dev/null
> +++ b/xen/arch/arm/vgic-v3-its.c
> @@ -0,0 +1,86 @@
> +/*
> + * xen/arch/arm/vgic-v3-its.c
> + *
> + * ARM Interrupt Translation Service (ITS) emulation
> + *
> + * Andre Przywara <andre.przywara@xxxxxxx>
> + * Copyright (c) 2016,2017 ARM Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; under version 2 of the License.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; If not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include <xen/bitops.h>
> +#include <xen/config.h>
> +#include <xen/domain_page.h>
> +#include <xen/lib.h>
> +#include <xen/init.h>
> +#include <xen/softirq.h>
> +#include <xen/irq.h>
> +#include <xen/sched.h>
> +#include <xen/sizes.h>
> +#include <asm/current.h>
> +#include <asm/mmio.h>
> +#include <asm/gic_v3_defs.h>
> +#include <asm/gic_v3_its.h>
> +#include <asm/vgic.h>
> +#include <asm/vgic-emul.h>
> +
> +/*
> + * Data structure to describe a virtual ITS.
> + * If both the vcmd_lock and the its_lock are required, the vcmd_lock must
> + * be taken first.
> + */
> +struct virt_its {
> +    struct domain *d;
> +    unsigned int devid_bits;
> +    unsigned int intid_bits;
> +    spinlock_t vcmd_lock;       /* Protects the virtual command buffer, 
> which */
> +    uint64_t cwriter;           /* consists of CWRITER and CREADR and those  
>  */
> +    uint64_t creadr;            /* shadow variables cwriter and creadr. */
> +    /* Protects the rest of this structure, including the ITS tables. */
> +    spinlock_t its_lock;
> +    uint64_t cbaser;
> +    uint64_t baser_dev, baser_coll;     /* BASER0 and BASER1 for the guest */
> +    unsigned int max_collections;
> +    unsigned int max_devices;
> +    bool enabled;
> +};
> +
> +/*
> + * An Interrupt Translation Table Entry: this is indexed by a
> + * DeviceID/EventID pair and is located in guest memory.
> + */
> +struct vits_itte
> +{
> +    uint32_t vlpi;
> +    uint16_t collection;
> +    uint16_t pad;
> +};
> +
> +int vgic_v3_its_init_domain(struct domain *d)
> +{
> +    return 0;
> +}
> +
> +void vgic_v3_its_free_domain(struct domain *d)
> +{
> +}
> +
> +/*
> + * Local variables:
> + * mode: C
> + * c-file-style: "BSD"
> + * c-basic-offset: 4
> + * indent-tabs-mode: nil
> + * End:
> + */
> diff --git a/xen/arch/arm/vgic-v3.c b/xen/arch/arm/vgic-v3.c
> index 1e9890b..d10757a 100644
> --- a/xen/arch/arm/vgic-v3.c
> +++ b/xen/arch/arm/vgic-v3.c
> @@ -28,6 +28,7 @@
>  #include <asm/current.h>
>  #include <asm/mmio.h>
>  #include <asm/gic_v3_defs.h>
> +#include <asm/gic_v3_its.h>
>  #include <asm/vgic.h>
>  #include <asm/vgic-emul.h>
>  #include <asm/vreg.h>
> @@ -1438,7 +1439,7 @@ static inline unsigned int vgic_v3_rdist_count(struct 
> domain *d)
>  static int vgic_v3_domain_init(struct domain *d)
>  {
>      struct vgic_rdist_region *rdist_regions;
> -    int rdist_count, i;
> +    int rdist_count, i, ret;
>  
>      /* Allocate memory for Re-distributor regions */
>      rdist_count = vgic_v3_rdist_count(d);
> @@ -1498,6 +1499,10 @@ static int vgic_v3_domain_init(struct domain *d)
>          d->arch.vgic.rdist_regions[0].first_cpu = 0;
>      }
>  
> +    ret = vgic_v3_its_init_domain(d);
> +    if ( ret )
> +        return ret;
> +
>      /* Register mmio handle for the Distributor */
>      register_mmio_handler(d, &vgic_distr_mmio_handler, d->arch.vgic.dbase,
>                            SZ_64K, NULL);
> @@ -1522,6 +1527,7 @@ static int vgic_v3_domain_init(struct domain *d)
>  
>  static void vgic_v3_domain_free(struct domain *d)
>  {
> +    vgic_v3_its_free_domain(d);
>      xfree(d->arch.vgic.rdist_regions);
>  }
>  
> diff --git a/xen/include/asm-arm/gic_v3_its.h 
> b/xen/include/asm-arm/gic_v3_its.h
> index a96c9dc..84d1692 100644
> --- a/xen/include/asm-arm/gic_v3_its.h
> +++ b/xen/include/asm-arm/gic_v3_its.h
> @@ -144,6 +144,10 @@ uint64_t gicv3_get_redist_address(unsigned int cpu, bool 
> use_pta);
>  /* Map a collection for this host CPU to each host ITS. */
>  int gicv3_its_setup_collection(unsigned int cpu);
>  
> +/* Initialize and destroy the per-domain parts of the virtual ITS support. */
> +int vgic_v3_its_init_domain(struct domain *d);
> +void vgic_v3_its_free_domain(struct domain *d);
> +
>  int gicv3_allocate_host_lpi_block(struct domain *d, uint32_t *first_lpi);
>  void gicv3_free_host_lpi_block(uint32_t first_lpi);
>  
> @@ -184,6 +188,15 @@ static inline int gicv3_its_setup_collection(unsigned 
> int cpu)
>      BUG();
>  }
>  
> +static inline int vgic_v3_its_init_domain(struct domain *d)
> +{
> +    return 0;
> +}
> +
> +static inline void vgic_v3_its_free_domain(struct domain *d)
> +{
> +}
> +
>  #endif /* CONFIG_HAS_ITS */
>  
>  #endif
> -- 
> 2.9.0
> 

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

 


Rackspace

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