diff mbox

[v7,RESEND,4/5] target-arm: Add GICv3CPUState in CPUARMState struct

Message ID 1485879782-6075-5-git-send-email-vijay.kilari@gmail.com
State New
Headers show

Commit Message

Vijay Kilari Jan. 31, 2017, 4:23 p.m. UTC
From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>

Add gicv3state void pointer to CPUARMState struct
to store GICv3CPUState.

In case of usecase like CPU reset, we need to reset
GICv3CPUState of the CPU. In such scenario, this pointer
becomes handy.

This patch take care of only GICv3.

Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
---
 hw/intc/arm_gicv3_kvm.c | 8 ++++++++
 target-arm/cpu.h        | 2 ++
 2 files changed, 10 insertions(+)

Comments

Peter Maydell Feb. 7, 2017, 2:42 p.m. UTC | #1
On 31 January 2017 at 16:23,  <vijay.kilari@gmail.com> wrote:
> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>
> Add gicv3state void pointer to CPUARMState struct
> to store GICv3CPUState.
>
> In case of usecase like CPU reset, we need to reset
> GICv3CPUState of the CPU. In such scenario, this pointer
> becomes handy.
>
> This patch take care of only GICv3.
>
> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
> ---
>  hw/intc/arm_gicv3_kvm.c | 8 ++++++++
>  target-arm/cpu.h        | 2 ++
>  2 files changed, 10 insertions(+)
>
> diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
> index 77af32d..f91e0ac 100644
> --- a/hw/intc/arm_gicv3_kvm.c
> +++ b/hw/intc/arm_gicv3_kvm.c
> @@ -644,6 +644,14 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
>
>      gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
>
> +    for (i = 0; i < s->num_cpu; i++) {
> +        ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i));
> +        CPUARMState *env = &cpu->env;
> +
> +        /* Store GICv3CPUState in CPUARMState gicv3state pointer */
> +        env->gicv3state = (void *)&s->cpu[i];
> +    }
> +
>      /* Try to create the device via the device control API */
>      s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);
>      if (s->dev_fd < 0) {

Please set the CPU's pointer to the GICv3 in arm_gicv3_common_realize(),
because that's where we set the GICv3's pointer to the CPU.
(We don't want the pointer to be specific to the KVM GICv3
anyway.)

thanks
-- PMM
Vijay Kilari Feb. 16, 2017, 9:58 a.m. UTC | #2
On Tue, Feb 7, 2017 at 8:12 PM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 31 January 2017 at 16:23,  <vijay.kilari@gmail.com> wrote:
>> From: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>>
>> Add gicv3state void pointer to CPUARMState struct
>> to store GICv3CPUState.
>>
>> In case of usecase like CPU reset, we need to reset
>> GICv3CPUState of the CPU. In such scenario, this pointer
>> becomes handy.
>>
>> This patch take care of only GICv3.
>>
>> Signed-off-by: Vijaya Kumar K <Vijaya.Kumar@cavium.com>
>> ---
>>  hw/intc/arm_gicv3_kvm.c | 8 ++++++++
>>  target-arm/cpu.h        | 2 ++
>>  2 files changed, 10 insertions(+)
>>
>> diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
>> index 77af32d..f91e0ac 100644
>> --- a/hw/intc/arm_gicv3_kvm.c
>> +++ b/hw/intc/arm_gicv3_kvm.c
>> @@ -644,6 +644,14 @@ static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
>>
>>      gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
>>
>> +    for (i = 0; i < s->num_cpu; i++) {
>> +        ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i));
>> +        CPUARMState *env = &cpu->env;
>> +
>> +        /* Store GICv3CPUState in CPUARMState gicv3state pointer */
>> +        env->gicv3state = (void *)&s->cpu[i];
>> +    }
>> +
>>      /* Try to create the device via the device control API */
>>      s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);
>>      if (s->dev_fd < 0) {
>
> Please set the CPU's pointer to the GICv3 in arm_gicv3_common_realize(),
> because that's where we set the GICv3's pointer to the CPU.
> (We don't want the pointer to be specific to the KVM GICv3
> anyway.)

Adding this arch specific to arm_gicv3_common_realize() lands in
compilation errors
 as arm_gicv3_common.c is common file.
So, I would like to add this to arm_gicv3_cpuif.c and export it as a function
and call from arm_gicv3_common_realize().
>
> thanks
> -- PMM
diff mbox

Patch

diff --git a/hw/intc/arm_gicv3_kvm.c b/hw/intc/arm_gicv3_kvm.c
index 77af32d..f91e0ac 100644
--- a/hw/intc/arm_gicv3_kvm.c
+++ b/hw/intc/arm_gicv3_kvm.c
@@ -644,6 +644,14 @@  static void kvm_arm_gicv3_realize(DeviceState *dev, Error **errp)
 
     gicv3_init_irqs_and_mmio(s, kvm_arm_gicv3_set_irq, NULL);
 
+    for (i = 0; i < s->num_cpu; i++) {
+        ARMCPU *cpu = ARM_CPU(qemu_get_cpu(i));
+        CPUARMState *env = &cpu->env;
+
+        /* Store GICv3CPUState in CPUARMState gicv3state pointer */
+        env->gicv3state = (void *)&s->cpu[i];
+    }
+
     /* Try to create the device via the device control API */
     s->dev_fd = kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, false);
     if (s->dev_fd < 0) {
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index ca5c849..b1ca064 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -507,6 +507,8 @@  typedef struct CPUARMState {
 
     void *nvic;
     const struct arm_boot_info *boot_info;
+    /* Store GICv3CPUState to access from this struct */
+    void *gicv3state;
 } CPUARMState;
 
 /**