ugly hack to set the offsets to 0

Signed-off-by: Marc Zyngier <maz@kernel.org>
diff --git a/arm/kvm.c b/arm/kvm.c
index d51cc15..842e5fd 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -85,12 +85,32 @@
 {
 }
 
+#ifndef KVM_CAP_TIMER_OFFSET
+struct kvm_arm_counter_offset {
+	__u64 counter_offset;
+	__u64 reserved;
+};
+#define KVM_CAP_COUNTER_OFFSET	227
+#define KVM_ARM_SET_COUNTER_OFFSET _IOW(KVMIO,  0xb5, struct kvm_arm_counter_offset)
+#endif
+
+static void set_counter_offset(struct kvm *kvm)
+{
+	struct kvm_arm_counter_offset offset = { .counter_offset = 0 };
+
+	/* A zero offset is all we care about! */
+	if (kvm__supports_extension(kvm, KVM_CAP_COUNTER_OFFSET) &&
+	    ioctl(kvm->vm_fd, KVM_ARM_SET_COUNTER_OFFSET, &offset))
+		die("Unable to set the counter offset to 0");
+}
+
 void kvm__arch_init(struct kvm *kvm)
 {
 	/* Create the virtual GIC. */
 	if (gic__create(kvm, kvm->cfg.arch.irqchip))
 		die("Failed to create virtual GIC");
 
+	set_counter_offset(kvm);
 	kvm__arch_enable_mte(kvm);
 }