From: Julien Grall <julien.grall@xxxxxxx> The kvm struct already contains a pointer to the configuration, which contains both hugetlbfs_path and ram_size, so is it not necessary to pass them as arguments to kvm__arch_init(). Signed-off-by: Julien Grall <julien.grall@xxxxxxx> Signed-off-by: Alexandru Elisei <alexandru.elisei@xxxxxxx> --- arm/kvm.c | 7 ++++--- include/kvm/kvm.h | 2 +- kvm.c | 2 +- mips/kvm.c | 7 ++++--- powerpc/kvm.c | 5 +++-- riscv/kvm.c | 7 ++++--- x86/kvm.c | 4 +++- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/arm/kvm.c b/arm/kvm.c index af0feae495d7..bd44aa350796 100644 --- a/arm/kvm.c +++ b/arm/kvm.c @@ -57,7 +57,7 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) { } -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { /* * Allocate guest memory. We must align our buffer to 64K to @@ -65,9 +65,10 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) * If using THP, then our minimal alignment becomes 2M. * 2M trumps 64K, so let's go with that. */ - kvm->ram_size = ram_size; + kvm->ram_size = kvm->cfg.ram_size; kvm->arch.ram_alloc_size = kvm->ram_size + SZ_2M; - kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, + kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, + kvm->cfg.hugetlbfs_path, kvm->arch.ram_alloc_size); if (kvm->arch.ram_alloc_start == MAP_FAILED) diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 9f7b2fb26e95..640b76c095f9 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -189,7 +189,7 @@ void kvm__remove_socket(const char *name); void kvm__arch_validate_cfg(struct kvm *kvm); void kvm__arch_set_cmdline(char *cmdline, bool video); -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size); +void kvm__arch_init(struct kvm *kvm); void kvm__arch_delete_ram(struct kvm *kvm); int kvm__arch_setup_firmware(struct kvm *kvm); int kvm__arch_free_firmware(struct kvm *kvm); diff --git a/kvm.c b/kvm.c index 952ef1fbb41c..42b881217df6 100644 --- a/kvm.c +++ b/kvm.c @@ -479,7 +479,7 @@ int kvm__init(struct kvm *kvm) goto err_vm_fd; } - kvm__arch_init(kvm, kvm->cfg.hugetlbfs_path, kvm->cfg.ram_size); + kvm__arch_init(kvm); INIT_LIST_HEAD(&kvm->mem_banks); kvm__init_ram(kvm); diff --git a/mips/kvm.c b/mips/kvm.c index f5b137f46dff..d8610cf81b94 100644 --- a/mips/kvm.c +++ b/mips/kvm.c @@ -61,12 +61,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) } /* Architecture-specific KVM init */ -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { int ret; - kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, ram_size); - kvm->ram_size = ram_size; + kvm->ram_size = kvm->cfg.ram_size; + kvm->ram_start = mmap_anon_or_hugetlbfs(kvm, kvm->cfg.hugetlbfs_path, + kvm->ram_size); if (kvm->ram_start == MAP_FAILED) die("out of memory"); diff --git a/powerpc/kvm.c b/powerpc/kvm.c index 3215b579f5dc..d281b070fd0e 100644 --- a/powerpc/kvm.c +++ b/powerpc/kvm.c @@ -92,12 +92,13 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) } /* Architecture-specific KVM init */ -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { + const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; int cap_ppc_rma; unsigned long hpt; - kvm->ram_size = ram_size; + kvm->ram_size = kvm->cfg.ram_size; /* Map "default" hugetblfs path to the standard 16M mount point */ if (hugetlbfs_path && !strcmp(hugetlbfs_path, "default")) diff --git a/riscv/kvm.c b/riscv/kvm.c index 7fb496282f4c..c46660772aa0 100644 --- a/riscv/kvm.c +++ b/riscv/kvm.c @@ -56,7 +56,7 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) { } -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { /* * Allocate guest memory. We must align our buffer to 64K to @@ -64,9 +64,10 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) * If using THP, then our minimal alignment becomes 2M. * 2M trumps 64K, so let's go with that. */ - kvm->ram_size = min(ram_size, (u64)RISCV_MAX_MEMORY(kvm)); + kvm->ram_size = min(kvm->cfg.ram_size, (u64)RISCV_MAX_MEMORY(kvm)); kvm->arch.ram_alloc_size = kvm->ram_size + SZ_2M; - kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, hugetlbfs_path, + kvm->arch.ram_alloc_start = mmap_anon_or_hugetlbfs(kvm, + kvm->cfg.hugetlbfs_path, kvm->arch.ram_alloc_size); if (kvm->arch.ram_alloc_start == MAP_FAILED) diff --git a/x86/kvm.c b/x86/kvm.c index 6683a5c81d49..24b0305a1841 100644 --- a/x86/kvm.c +++ b/x86/kvm.c @@ -134,9 +134,11 @@ void kvm__arch_set_cmdline(char *cmdline, bool video) } /* Architecture-specific KVM init */ -void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size) +void kvm__arch_init(struct kvm *kvm) { + const char *hugetlbfs_path = kvm->cfg.hugetlbfs_path; struct kvm_pit_config pit_config = { .flags = 0, }; + u64 ram_size = kvm->cfg.ram_size; int ret; ret = ioctl(kvm->vm_fd, KVM_SET_TSS_ADDR, 0xfffbd000); -- 2.36.1 _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm