Re: [PATCH v10 09/17] KVM: arm64: introduce ITS emulation file with MMIO framework

2016-07-18 Thread Auger Eric
Hi Andre,

On 18/07/2016 18:34, Andre Przywara wrote:
> Hi Eric,
> 
> On 18/07/16 10:18, Auger Eric wrote:
>> Hi Andre, Marc,
>>
>> On 15/07/2016 13:43, Andre Przywara wrote:
>>> The ARM GICv3 ITS emulation code goes into a separate file, but needs
>>> to be connected to the GICv3 emulation, of which it is an option.
>>> The ITS MMIO handlers require the respective ITS pointer to be passed in,
>>> so we amend the existing VGIC MMIO framework to let it cope with that.
>>> Also we introduce the basic ITS data structure and initialize it, but
>>> don't return any success yet, as we are not yet ready for the show.
>>>
>>> Signed-off-by: Andre Przywara 
>>> ---
>>>  include/kvm/arm_vgic.h   |  22 -
>>>  virt/kvm/arm/vgic/vgic-its.c | 103 
>>> +++
>>>  virt/kvm/arm/vgic/vgic-mmio-v3.c |  40 ++-
>>>  virt/kvm/arm/vgic/vgic-mmio.c|  37 +++---
>>>  virt/kvm/arm/vgic/vgic-mmio.h|  17 +--
>>>  virt/kvm/arm/vgic/vgic.h |   7 +++
>>>  6 files changed, 213 insertions(+), 13 deletions(-)
>>>  create mode 100644 virt/kvm/arm/vgic/vgic-its.c
>>>
>>> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
>>> index df2dec5..685f339 100644
>>> --- a/include/kvm/arm_vgic.h
>>> +++ b/include/kvm/arm_vgic.h
>>> @@ -108,15 +108,35 @@ struct vgic_irq {
>>>  };
>>>  
>>>  struct vgic_register_region;
>>> +struct vgic_its;
>>> +
>>> +enum iodev_type {
>>> +   IODEV_CPUIF,
>>> +   IODEV_DIST,
>>> +   IODEV_REDIST,
>>> +   IODEV_ITS
>>> +};
>>>  
>>>  struct vgic_io_device {
>>> gpa_t base_addr;
>>> -   struct kvm_vcpu *redist_vcpu;
>>> +   union {
>>> +   struct kvm_vcpu *redist_vcpu;
>>> +   struct vgic_its *its;
>>> +   };
>>> const struct vgic_register_region *regions;
>>> +   enum iodev_type iodev_type;
>>> int nr_regions;
>>> struct kvm_io_device dev;
>>>  };
>>>  
>>> +struct vgic_its {
>>> +   /* The base address of the ITS control register frame */
>>> +   gpa_t   vgic_its_base;
>>> +
>>> +   boolenabled;
>>> +   struct vgic_io_device   iodev;
>>> +};
>>> +
>>>  struct vgic_dist {
>>> boolin_kernel;
>>> boolready;
>>> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
>>> new file mode 100644
>>> index 000..4654d6e
>>> --- /dev/null
>>> +++ b/virt/kvm/arm/vgic/vgic-its.c
>>> @@ -0,0 +1,103 @@
>>> +/*
>>> + * GICv3 ITS emulation
>>> + *
>>> + * Copyright (C) 2015,2016 ARM Ltd.
>>> + * Author: Andre Przywara 
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License version 2 as
>>> + * published by the Free Software Foundation.
>>> + *
>>> + * 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 .
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include "vgic.h"
>>> +#include "vgic-mmio.h"
>>> +
>>> +#define REGISTER_ITS_DESC(off, rd, wr, length, acc)\
>>> +{  \
>>> +   .reg_offset = off,  \
>>> +   .len = length,  \
>>> +   .access_flags = acc,\
>>> +   .its_read = rd, \
>>> +   .its_write = wr,\
>>> +}
>>> +
>>> +static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its 
>>> *its,
>>> +  gpa_t addr, unsigned int len)
>>> +{
>>> +   return 0;
>>> +}
>>> +
>>> +static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its,
>>> + gpa_t addr, unsigned int len, unsigned long val)
>>> +{
>>> +   /* Ignore */
>>> +}
>>> +
>>> +static struct vgic_register_region its_registers[] = {
>>> +   REGISTER_ITS_DESC(GITS_CTLR,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 4,
>>> +   VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_IIDR,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 4,
>>> +   VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_TYPER,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 8,
>>> +   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_CBASER,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 8,
>>> +   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>>> +   

Re: [PATCH v10 09/17] KVM: arm64: introduce ITS emulation file with MMIO framework

2016-07-18 Thread Andre Przywara
Hi Eric,

On 18/07/16 10:18, Auger Eric wrote:
> Hi Andre, Marc,
> 
> On 15/07/2016 13:43, Andre Przywara wrote:
>> The ARM GICv3 ITS emulation code goes into a separate file, but needs
>> to be connected to the GICv3 emulation, of which it is an option.
>> The ITS MMIO handlers require the respective ITS pointer to be passed in,
>> so we amend the existing VGIC MMIO framework to let it cope with that.
>> Also we introduce the basic ITS data structure and initialize it, but
>> don't return any success yet, as we are not yet ready for the show.
>>
>> Signed-off-by: Andre Przywara 
>> ---
>>  include/kvm/arm_vgic.h   |  22 -
>>  virt/kvm/arm/vgic/vgic-its.c | 103 
>> +++
>>  virt/kvm/arm/vgic/vgic-mmio-v3.c |  40 ++-
>>  virt/kvm/arm/vgic/vgic-mmio.c|  37 +++---
>>  virt/kvm/arm/vgic/vgic-mmio.h|  17 +--
>>  virt/kvm/arm/vgic/vgic.h |   7 +++
>>  6 files changed, 213 insertions(+), 13 deletions(-)
>>  create mode 100644 virt/kvm/arm/vgic/vgic-its.c
>>
>> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
>> index df2dec5..685f339 100644
>> --- a/include/kvm/arm_vgic.h
>> +++ b/include/kvm/arm_vgic.h
>> @@ -108,15 +108,35 @@ struct vgic_irq {
>>  };
>>  
>>  struct vgic_register_region;
>> +struct vgic_its;
>> +
>> +enum iodev_type {
>> +IODEV_CPUIF,
>> +IODEV_DIST,
>> +IODEV_REDIST,
>> +IODEV_ITS
>> +};
>>  
>>  struct vgic_io_device {
>>  gpa_t base_addr;
>> -struct kvm_vcpu *redist_vcpu;
>> +union {
>> +struct kvm_vcpu *redist_vcpu;
>> +struct vgic_its *its;
>> +};
>>  const struct vgic_register_region *regions;
>> +enum iodev_type iodev_type;
>>  int nr_regions;
>>  struct kvm_io_device dev;
>>  };
>>  
>> +struct vgic_its {
>> +/* The base address of the ITS control register frame */
>> +gpa_t   vgic_its_base;
>> +
>> +boolenabled;
>> +struct vgic_io_device   iodev;
>> +};
>> +
>>  struct vgic_dist {
>>  boolin_kernel;
>>  boolready;
>> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
>> new file mode 100644
>> index 000..4654d6e
>> --- /dev/null
>> +++ b/virt/kvm/arm/vgic/vgic-its.c
>> @@ -0,0 +1,103 @@
>> +/*
>> + * GICv3 ITS emulation
>> + *
>> + * Copyright (C) 2015,2016 ARM Ltd.
>> + * Author: Andre Przywara 
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * 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 .
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "vgic.h"
>> +#include "vgic-mmio.h"
>> +
>> +#define REGISTER_ITS_DESC(off, rd, wr, length, acc) \
>> +{   \
>> +.reg_offset = off,  \
>> +.len = length,  \
>> +.access_flags = acc,\
>> +.its_read = rd, \
>> +.its_write = wr,\
>> +}
>> +
>> +static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its 
>> *its,
>> +   gpa_t addr, unsigned int len)
>> +{
>> +return 0;
>> +}
>> +
>> +static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its,
>> +  gpa_t addr, unsigned int len, unsigned long val)
>> +{
>> +/* Ignore */
>> +}
>> +
>> +static struct vgic_register_region its_registers[] = {
>> +REGISTER_ITS_DESC(GITS_CTLR,
>> +its_mmio_read_raz, its_mmio_write_wi, 4,
>> +VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_IIDR,
>> +its_mmio_read_raz, its_mmio_write_wi, 4,
>> +VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_TYPER,
>> +its_mmio_read_raz, its_mmio_write_wi, 8,
>> +VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_CBASER,
>> +its_mmio_read_raz, its_mmio_write_wi, 8,
>> +VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_CWRITER,
>> +its_mmio_read_raz, its_mmio_write_wi, 8,
>> +VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>> +

Re: [PATCH v10 09/17] KVM: arm64: introduce ITS emulation file with MMIO framework

2016-07-18 Thread Auger Eric
Hi,

On 18/07/2016 11:43, Marc Zyngier wrote:
> On 18/07/16 10:18, Auger Eric wrote:
>> Hi Andre, Marc,
>>
>> On 15/07/2016 13:43, Andre Przywara wrote:
>>> The ARM GICv3 ITS emulation code goes into a separate file, but needs
>>> to be connected to the GICv3 emulation, of which it is an option.
>>> The ITS MMIO handlers require the respective ITS pointer to be passed in,
>>> so we amend the existing VGIC MMIO framework to let it cope with that.
>>> Also we introduce the basic ITS data structure and initialize it, but
>>> don't return any success yet, as we are not yet ready for the show.
>>>
>>> Signed-off-by: Andre Przywara 
>>> ---
>>>  include/kvm/arm_vgic.h   |  22 -
>>>  virt/kvm/arm/vgic/vgic-its.c | 103 
>>> +++
>>>  virt/kvm/arm/vgic/vgic-mmio-v3.c |  40 ++-
>>>  virt/kvm/arm/vgic/vgic-mmio.c|  37 +++---
>>>  virt/kvm/arm/vgic/vgic-mmio.h|  17 +--
>>>  virt/kvm/arm/vgic/vgic.h |   7 +++
>>>  6 files changed, 213 insertions(+), 13 deletions(-)
>>>  create mode 100644 virt/kvm/arm/vgic/vgic-its.c
>>>
>>> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
>>> index df2dec5..685f339 100644
>>> --- a/include/kvm/arm_vgic.h
>>> +++ b/include/kvm/arm_vgic.h
>>> @@ -108,15 +108,35 @@ struct vgic_irq {
>>>  };
>>>  
>>>  struct vgic_register_region;
>>> +struct vgic_its;
>>> +
>>> +enum iodev_type {
>>> +   IODEV_CPUIF,
>>> +   IODEV_DIST,
>>> +   IODEV_REDIST,
>>> +   IODEV_ITS
>>> +};
>>>  
>>>  struct vgic_io_device {
>>> gpa_t base_addr;
>>> -   struct kvm_vcpu *redist_vcpu;
>>> +   union {
>>> +   struct kvm_vcpu *redist_vcpu;
>>> +   struct vgic_its *its;
>>> +   };
>>> const struct vgic_register_region *regions;
>>> +   enum iodev_type iodev_type;
>>> int nr_regions;
>>> struct kvm_io_device dev;
>>>  };
>>>  
>>> +struct vgic_its {
>>> +   /* The base address of the ITS control register frame */
>>> +   gpa_t   vgic_its_base;
>>> +
>>> +   boolenabled;
>>> +   struct vgic_io_device   iodev;
>>> +};
>>> +
>>>  struct vgic_dist {
>>> boolin_kernel;
>>> boolready;
>>> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
>>> new file mode 100644
>>> index 000..4654d6e
>>> --- /dev/null
>>> +++ b/virt/kvm/arm/vgic/vgic-its.c
>>> @@ -0,0 +1,103 @@
>>> +/*
>>> + * GICv3 ITS emulation
>>> + *
>>> + * Copyright (C) 2015,2016 ARM Ltd.
>>> + * Author: Andre Przywara 
>>> + *
>>> + * This program is free software; you can redistribute it and/or modify
>>> + * it under the terms of the GNU General Public License version 2 as
>>> + * published by the Free Software Foundation.
>>> + *
>>> + * 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 .
>>> + */
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include 
>>> +
>>> +#include 
>>> +#include 
>>> +#include 
>>> +
>>> +#include "vgic.h"
>>> +#include "vgic-mmio.h"
>>> +
>>> +#define REGISTER_ITS_DESC(off, rd, wr, length, acc)\
>>> +{  \
>>> +   .reg_offset = off,  \
>>> +   .len = length,  \
>>> +   .access_flags = acc,\
>>> +   .its_read = rd, \
>>> +   .its_write = wr,\
>>> +}
>>> +
>>> +static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its 
>>> *its,
>>> +  gpa_t addr, unsigned int len)
>>> +{
>>> +   return 0;
>>> +}
>>> +
>>> +static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its,
>>> + gpa_t addr, unsigned int len, unsigned long val)
>>> +{
>>> +   /* Ignore */
>>> +}
>>> +
>>> +static struct vgic_register_region its_registers[] = {
>>> +   REGISTER_ITS_DESC(GITS_CTLR,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 4,
>>> +   VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_IIDR,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 4,
>>> +   VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_TYPER,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 8,
>>> +   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_CBASER,
>>> +   its_mmio_read_raz, its_mmio_write_wi, 8,
>>> +   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>>> +   REGISTER_ITS_DESC(GITS_CWRITER,
>>> +  

Re: [PATCH v10 09/17] KVM: arm64: introduce ITS emulation file with MMIO framework

2016-07-18 Thread Marc Zyngier
On 18/07/16 10:18, Auger Eric wrote:
> Hi Andre, Marc,
> 
> On 15/07/2016 13:43, Andre Przywara wrote:
>> The ARM GICv3 ITS emulation code goes into a separate file, but needs
>> to be connected to the GICv3 emulation, of which it is an option.
>> The ITS MMIO handlers require the respective ITS pointer to be passed in,
>> so we amend the existing VGIC MMIO framework to let it cope with that.
>> Also we introduce the basic ITS data structure and initialize it, but
>> don't return any success yet, as we are not yet ready for the show.
>>
>> Signed-off-by: Andre Przywara 
>> ---
>>  include/kvm/arm_vgic.h   |  22 -
>>  virt/kvm/arm/vgic/vgic-its.c | 103 
>> +++
>>  virt/kvm/arm/vgic/vgic-mmio-v3.c |  40 ++-
>>  virt/kvm/arm/vgic/vgic-mmio.c|  37 +++---
>>  virt/kvm/arm/vgic/vgic-mmio.h|  17 +--
>>  virt/kvm/arm/vgic/vgic.h |   7 +++
>>  6 files changed, 213 insertions(+), 13 deletions(-)
>>  create mode 100644 virt/kvm/arm/vgic/vgic-its.c
>>
>> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
>> index df2dec5..685f339 100644
>> --- a/include/kvm/arm_vgic.h
>> +++ b/include/kvm/arm_vgic.h
>> @@ -108,15 +108,35 @@ struct vgic_irq {
>>  };
>>  
>>  struct vgic_register_region;
>> +struct vgic_its;
>> +
>> +enum iodev_type {
>> +IODEV_CPUIF,
>> +IODEV_DIST,
>> +IODEV_REDIST,
>> +IODEV_ITS
>> +};
>>  
>>  struct vgic_io_device {
>>  gpa_t base_addr;
>> -struct kvm_vcpu *redist_vcpu;
>> +union {
>> +struct kvm_vcpu *redist_vcpu;
>> +struct vgic_its *its;
>> +};
>>  const struct vgic_register_region *regions;
>> +enum iodev_type iodev_type;
>>  int nr_regions;
>>  struct kvm_io_device dev;
>>  };
>>  
>> +struct vgic_its {
>> +/* The base address of the ITS control register frame */
>> +gpa_t   vgic_its_base;
>> +
>> +boolenabled;
>> +struct vgic_io_device   iodev;
>> +};
>> +
>>  struct vgic_dist {
>>  boolin_kernel;
>>  boolready;
>> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
>> new file mode 100644
>> index 000..4654d6e
>> --- /dev/null
>> +++ b/virt/kvm/arm/vgic/vgic-its.c
>> @@ -0,0 +1,103 @@
>> +/*
>> + * GICv3 ITS emulation
>> + *
>> + * Copyright (C) 2015,2016 ARM Ltd.
>> + * Author: Andre Przywara 
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + *
>> + * 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 .
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include 
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "vgic.h"
>> +#include "vgic-mmio.h"
>> +
>> +#define REGISTER_ITS_DESC(off, rd, wr, length, acc) \
>> +{   \
>> +.reg_offset = off,  \
>> +.len = length,  \
>> +.access_flags = acc,\
>> +.its_read = rd, \
>> +.its_write = wr,\
>> +}
>> +
>> +static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its 
>> *its,
>> +   gpa_t addr, unsigned int len)
>> +{
>> +return 0;
>> +}
>> +
>> +static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its,
>> +  gpa_t addr, unsigned int len, unsigned long val)
>> +{
>> +/* Ignore */
>> +}
>> +
>> +static struct vgic_register_region its_registers[] = {
>> +REGISTER_ITS_DESC(GITS_CTLR,
>> +its_mmio_read_raz, its_mmio_write_wi, 4,
>> +VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_IIDR,
>> +its_mmio_read_raz, its_mmio_write_wi, 4,
>> +VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_TYPER,
>> +its_mmio_read_raz, its_mmio_write_wi, 8,
>> +VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_CBASER,
>> +its_mmio_read_raz, its_mmio_write_wi, 8,
>> +VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_CWRITER,
>> +its_mmio_read_raz, its_mmio_write_wi, 8,
>> +VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
>> +REGISTER_ITS_DESC(GITS_CREADR,
>> +

Re: [PATCH v10 09/17] KVM: arm64: introduce ITS emulation file with MMIO framework

2016-07-18 Thread Auger Eric
Hi Andre, Marc,

On 15/07/2016 13:43, Andre Przywara wrote:
> The ARM GICv3 ITS emulation code goes into a separate file, but needs
> to be connected to the GICv3 emulation, of which it is an option.
> The ITS MMIO handlers require the respective ITS pointer to be passed in,
> so we amend the existing VGIC MMIO framework to let it cope with that.
> Also we introduce the basic ITS data structure and initialize it, but
> don't return any success yet, as we are not yet ready for the show.
> 
> Signed-off-by: Andre Przywara 
> ---
>  include/kvm/arm_vgic.h   |  22 -
>  virt/kvm/arm/vgic/vgic-its.c | 103 
> +++
>  virt/kvm/arm/vgic/vgic-mmio-v3.c |  40 ++-
>  virt/kvm/arm/vgic/vgic-mmio.c|  37 +++---
>  virt/kvm/arm/vgic/vgic-mmio.h|  17 +--
>  virt/kvm/arm/vgic/vgic.h |   7 +++
>  6 files changed, 213 insertions(+), 13 deletions(-)
>  create mode 100644 virt/kvm/arm/vgic/vgic-its.c
> 
> diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
> index df2dec5..685f339 100644
> --- a/include/kvm/arm_vgic.h
> +++ b/include/kvm/arm_vgic.h
> @@ -108,15 +108,35 @@ struct vgic_irq {
>  };
>  
>  struct vgic_register_region;
> +struct vgic_its;
> +
> +enum iodev_type {
> + IODEV_CPUIF,
> + IODEV_DIST,
> + IODEV_REDIST,
> + IODEV_ITS
> +};
>  
>  struct vgic_io_device {
>   gpa_t base_addr;
> - struct kvm_vcpu *redist_vcpu;
> + union {
> + struct kvm_vcpu *redist_vcpu;
> + struct vgic_its *its;
> + };
>   const struct vgic_register_region *regions;
> + enum iodev_type iodev_type;
>   int nr_regions;
>   struct kvm_io_device dev;
>  };
>  
> +struct vgic_its {
> + /* The base address of the ITS control register frame */
> + gpa_t   vgic_its_base;
> +
> + boolenabled;
> + struct vgic_io_device   iodev;
> +};
> +
>  struct vgic_dist {
>   boolin_kernel;
>   boolready;
> diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
> new file mode 100644
> index 000..4654d6e
> --- /dev/null
> +++ b/virt/kvm/arm/vgic/vgic-its.c
> @@ -0,0 +1,103 @@
> +/*
> + * GICv3 ITS emulation
> + *
> + * Copyright (C) 2015,2016 ARM Ltd.
> + * Author: Andre Przywara 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * 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 .
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#include 
> +#include 
> +#include 
> +
> +#include "vgic.h"
> +#include "vgic-mmio.h"
> +
> +#define REGISTER_ITS_DESC(off, rd, wr, length, acc)  \
> +{\
> + .reg_offset = off,  \
> + .len = length,  \
> + .access_flags = acc,\
> + .its_read = rd, \
> + .its_write = wr,\
> +}
> +
> +static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its *its,
> +gpa_t addr, unsigned int len)
> +{
> + return 0;
> +}
> +
> +static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its,
> +   gpa_t addr, unsigned int len, unsigned long val)
> +{
> + /* Ignore */
> +}
> +
> +static struct vgic_register_region its_registers[] = {
> + REGISTER_ITS_DESC(GITS_CTLR,
> + its_mmio_read_raz, its_mmio_write_wi, 4,
> + VGIC_ACCESS_32bit),
> + REGISTER_ITS_DESC(GITS_IIDR,
> + its_mmio_read_raz, its_mmio_write_wi, 4,
> + VGIC_ACCESS_32bit),
> + REGISTER_ITS_DESC(GITS_TYPER,
> + its_mmio_read_raz, its_mmio_write_wi, 8,
> + VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
> + REGISTER_ITS_DESC(GITS_CBASER,
> + its_mmio_read_raz, its_mmio_write_wi, 8,
> + VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
> + REGISTER_ITS_DESC(GITS_CWRITER,
> + its_mmio_read_raz, its_mmio_write_wi, 8,
> + VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
> + REGISTER_ITS_DESC(GITS_CREADR,
> + its_mmio_read_raz, its_mmio_write_wi, 8,
> + VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
> + 

[PATCH v10 09/17] KVM: arm64: introduce ITS emulation file with MMIO framework

2016-07-15 Thread Andre Przywara
The ARM GICv3 ITS emulation code goes into a separate file, but needs
to be connected to the GICv3 emulation, of which it is an option.
The ITS MMIO handlers require the respective ITS pointer to be passed in,
so we amend the existing VGIC MMIO framework to let it cope with that.
Also we introduce the basic ITS data structure and initialize it, but
don't return any success yet, as we are not yet ready for the show.

Signed-off-by: Andre Przywara 
---
 include/kvm/arm_vgic.h   |  22 -
 virt/kvm/arm/vgic/vgic-its.c | 103 +++
 virt/kvm/arm/vgic/vgic-mmio-v3.c |  40 ++-
 virt/kvm/arm/vgic/vgic-mmio.c|  37 +++---
 virt/kvm/arm/vgic/vgic-mmio.h|  17 +--
 virt/kvm/arm/vgic/vgic.h |   7 +++
 6 files changed, 213 insertions(+), 13 deletions(-)
 create mode 100644 virt/kvm/arm/vgic/vgic-its.c

diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h
index df2dec5..685f339 100644
--- a/include/kvm/arm_vgic.h
+++ b/include/kvm/arm_vgic.h
@@ -108,15 +108,35 @@ struct vgic_irq {
 };
 
 struct vgic_register_region;
+struct vgic_its;
+
+enum iodev_type {
+   IODEV_CPUIF,
+   IODEV_DIST,
+   IODEV_REDIST,
+   IODEV_ITS
+};
 
 struct vgic_io_device {
gpa_t base_addr;
-   struct kvm_vcpu *redist_vcpu;
+   union {
+   struct kvm_vcpu *redist_vcpu;
+   struct vgic_its *its;
+   };
const struct vgic_register_region *regions;
+   enum iodev_type iodev_type;
int nr_regions;
struct kvm_io_device dev;
 };
 
+struct vgic_its {
+   /* The base address of the ITS control register frame */
+   gpa_t   vgic_its_base;
+
+   boolenabled;
+   struct vgic_io_device   iodev;
+};
+
 struct vgic_dist {
boolin_kernel;
boolready;
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
new file mode 100644
index 000..4654d6e
--- /dev/null
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -0,0 +1,103 @@
+/*
+ * GICv3 ITS emulation
+ *
+ * Copyright (C) 2015,2016 ARM Ltd.
+ * Author: Andre Przywara 
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 .
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "vgic.h"
+#include "vgic-mmio.h"
+
+#define REGISTER_ITS_DESC(off, rd, wr, length, acc)\
+{  \
+   .reg_offset = off,  \
+   .len = length,  \
+   .access_flags = acc,\
+   .its_read = rd, \
+   .its_write = wr,\
+}
+
+static unsigned long its_mmio_read_raz(struct kvm *kvm, struct vgic_its *its,
+  gpa_t addr, unsigned int len)
+{
+   return 0;
+}
+
+static void its_mmio_write_wi(struct kvm *kvm, struct vgic_its *its,
+ gpa_t addr, unsigned int len, unsigned long val)
+{
+   /* Ignore */
+}
+
+static struct vgic_register_region its_registers[] = {
+   REGISTER_ITS_DESC(GITS_CTLR,
+   its_mmio_read_raz, its_mmio_write_wi, 4,
+   VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_IIDR,
+   its_mmio_read_raz, its_mmio_write_wi, 4,
+   VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_TYPER,
+   its_mmio_read_raz, its_mmio_write_wi, 8,
+   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_CBASER,
+   its_mmio_read_raz, its_mmio_write_wi, 8,
+   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_CWRITER,
+   its_mmio_read_raz, its_mmio_write_wi, 8,
+   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_CREADR,
+   its_mmio_read_raz, its_mmio_write_wi, 8,
+   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_BASER,
+   its_mmio_read_raz, its_mmio_write_wi, 0x40,
+   VGIC_ACCESS_64bit | VGIC_ACCESS_32bit),
+   REGISTER_ITS_DESC(GITS_IDREGS_BASE,
+   its_mmio_read_raz, its_mmio_write_wi, 0x30,
+