diff options
author | Marc Zyngier <maz@kernel.org> | 2021-08-22 16:25:24 +0100 |
---|---|---|
committer | Will Deacon <will@kernel.org> | 2021-08-31 15:46:57 +0100 |
commit | 4250819de93bd1ddcede28b916224df4079cc336 (patch) | |
tree | bf0fda87057e7fab06a0777645238c57e6c170b0 | |
parent | 25c1dc6c4942ff0949c08780fcad6b324fec6bf7 (diff) | |
download | kvmtool-4250819de93bd1ddcede28b916224df4079cc336.tar.gz |
kvmtool: Abstract KVM_VM_TYPE into a weak function
Most architectures pass a fixed value for their VM type. However,
arm64 uses it as a parameter describing the size of the guest's
physical address space.
In order to support this, introduce a kvm__get_vm_type() helper
that only returns KVM_VM_TYPE for now.
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Oliver Upton <oupton@google.com>
Link: https://lore.kernel.org/r/20210822152526.1291918-2-maz@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r-- | include/kvm/kvm.h | 1 | ||||
-rw-r--r-- | kvm.c | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 56e9c8e3..ad732e56 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -114,6 +114,7 @@ int kvm__init(struct kvm *kvm); struct kvm *kvm__new(void); int kvm__recommended_cpus(struct kvm *kvm); int kvm__max_cpus(struct kvm *kvm); +int kvm__get_vm_type(struct kvm *kvm); void kvm__init_ram(struct kvm *kvm); int kvm__exit(struct kvm *kvm); bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename); @@ -428,6 +428,11 @@ int kvm__max_cpus(struct kvm *kvm) return ret; } +int __attribute__((weak)) kvm__get_vm_type(struct kvm *kvm) +{ + return KVM_VM_TYPE; +} + int kvm__init(struct kvm *kvm) { int ret; @@ -461,7 +466,7 @@ int kvm__init(struct kvm *kvm) goto err_sys_fd; } - kvm->vm_fd = ioctl(kvm->sys_fd, KVM_CREATE_VM, KVM_VM_TYPE); + kvm->vm_fd = ioctl(kvm->sys_fd, KVM_CREATE_VM, kvm__get_vm_type(kvm)); if (kvm->vm_fd < 0) { pr_err("KVM_CREATE_VM ioctl"); ret = kvm->vm_fd; |