[Qemu-devel] [RFC v2 4/4] hw/intc/arm_gicv3_its: Implement full reset

Eric Auger posted 4 patches 8 years, 3 months ago
There is a newer version of this series
[Qemu-devel] [RFC v2 4/4] hw/intc/arm_gicv3_its: Implement full reset
Posted by Eric Auger 8 years, 3 months ago
Voiding the ITS caches is not supposed to happen via
individual register writes. So we introduced a dedicated
ITS KVM device ioctl to perform a cold reset of the ITS:
KVM_DEV_ARM_VGIC_GRP_CTRL/KVM_DEV_ARM_ITS_CTRL_RESET. Let's
use this latter if the kernel supports it.

Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
 hw/intc/arm_gicv3_its_kvm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
index 537cea1..73e2530 100644
--- a/hw/intc/arm_gicv3_its_kvm.c
+++ b/hw/intc/arm_gicv3_its_kvm.c
@@ -215,9 +215,19 @@ static void kvm_arm_its_post_load(GICv3ITSState *s)
 
 static void kvm_arm_its_reset(DeviceState *dev)
 {
+    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
     KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
 
     c->parent_reset(dev);
+
+    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
+                               KVM_DEV_ARM_ITS_CTRL_RESET)) {
+        error_report("ITS KVM: reset is not supported by the kernel");
+        return;
+    }
+
+    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
+                      KVM_DEV_ARM_ITS_CTRL_RESET, NULL, true, &error_abort);
 }
 
 static Property kvm_arm_its_props[] = {
-- 
2.5.5


Re: [Qemu-devel] [RFC v2 4/4] hw/intc/arm_gicv3_its: Implement full reset
Posted by Peter Maydell 8 years, 3 months ago
On 23 October 2017 at 16:35, Eric Auger <eric.auger@redhat.com> wrote:
> Voiding the ITS caches is not supposed to happen via
> individual register writes. So we introduced a dedicated
> ITS KVM device ioctl to perform a cold reset of the ITS:
> KVM_DEV_ARM_VGIC_GRP_CTRL/KVM_DEV_ARM_ITS_CTRL_RESET. Let's
> use this latter if the kernel supports it.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
>  hw/intc/arm_gicv3_its_kvm.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/hw/intc/arm_gicv3_its_kvm.c b/hw/intc/arm_gicv3_its_kvm.c
> index 537cea1..73e2530 100644
> --- a/hw/intc/arm_gicv3_its_kvm.c
> +++ b/hw/intc/arm_gicv3_its_kvm.c
> @@ -215,9 +215,19 @@ static void kvm_arm_its_post_load(GICv3ITSState *s)
>
>  static void kvm_arm_its_reset(DeviceState *dev)
>  {
> +    GICv3ITSState *s = ARM_GICV3_ITS_COMMON(dev);
>      KVMARMITSClass *c = KVM_ARM_ITS_GET_CLASS(s);
>
>      c->parent_reset(dev);
> +
> +    if (!kvm_device_check_attr(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
> +                               KVM_DEV_ARM_ITS_CTRL_RESET)) {
> +        error_report("ITS KVM: reset is not supported by the kernel");

Best to say "host kernel" so users know we're not complaining about
the guest kernel.

> +        return;
> +    }
> +
> +    kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CTRL,
> +                      KVM_DEV_ARM_ITS_CTRL_RESET, NULL, true, &error_abort);
>  }
>
>  static Property kvm_arm_its_props[] = {
> --

This would be the right patch for the boilerplate for adding
the parent class and hooking into the reset function chain.

thanks
-- PMM