diff options
author | Marc Zyngier <maz@kernel.org> | 2023-03-13 12:41:14 +0000 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2023-03-13 12:41:14 +0000 |
commit | 3b1253073ee57c0d92baf7b214362829b487b8d5 (patch) | |
tree | 1407ccefd25958afb47b21385f0425a209762226 | |
parent | e17d182ad3f797f01947fc234d95c96c050c534b (diff) | |
download | kvmtool-zero-offset.tar.gz |
ugly hack to set the offsets to 0zero-offset
Signed-off-by: Marc Zyngier <maz@kernel.org>
-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); } |