diff options
-rw-r--r-- | arm/kvm.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -85,12 +85,32 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) { } +#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); } |