[PATCH 1/3] kvmtool: Abstract KVM_VM_TYPE into a weak function
From: Marc Zyngier <maz@kernel.org>
Date: 2021-03-09 16:41:09
Subsystem:
the rest · Maintainer:
Linus Torvalds
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. Signed-off-by: Marc Zyngier <maz@kernel.org> --- include/kvm/kvm.h | 1 + kvm.c | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h
index 53373b0..72a42e8 100644
--- a/include/kvm/kvm.h
+++ b/include/kvm/kvm.h@@ -100,6 +100,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);
diff --git a/kvm.c b/kvm.c
index e327541..5bc66c8 100644
--- a/kvm.c
+++ b/kvm.c@@ -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;
--
2.30.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel