From: Andre Przywara <andre.przywara@arm.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org,
suzuki.poulose@arm.com, julien@xen.org,
linux-arm-kernel@lists.infradead.org,
kvmarm@lists.cs.columbia.edu, james.morse@arm.com,
Julien Grall <julien.grall@arm.com>
Subject: Re: [PATCH v3 kvmtool 10/13] kvm__arch_init: Remove hugetlbfs_path and ram_size as parameters
Date: Wed, 1 Jun 2022 14:13:27 +0100 [thread overview]
Message-ID: <20220601141327.1d49859b@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <20220525112345.121321-11-alexandru.elisei@arm.com>
On Wed, 25 May 2022 12:23:42 +0100
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> From: Julien Grall <julien.grall@arm.com>
>
> 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@arm.com>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Like that cleanup.
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Cheers,
Andre
> ---
> 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);
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-06-01 13:43 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 11:23 [PATCH v3 kvmtool 00/13] arm64: Allow the user to set RAM base address Alexandru Elisei
2022-05-25 11:23 ` [PATCH v3 kvmtool 01/13] Use MB for megabytes consistently Alexandru Elisei
2022-05-25 11:23 ` [PATCH v3 kvmtool 02/13] sizes.h: Make all sizes 64bit Alexandru Elisei
2022-05-30 15:05 ` Andre Przywara
2022-06-15 16:01 ` Alexandru Elisei
2022-05-25 11:23 ` [PATCH v3 kvmtool 03/13] builtin-run: Always use RAM size in bytes Alexandru Elisei
2022-05-25 11:23 ` [PATCH v3 kvmtool 04/13] builtin-run: Rework RAM size validation Alexandru Elisei
2022-05-30 17:13 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 05/13] builtin-run: Add arch hook to validate VM configuration Alexandru Elisei
2022-05-25 11:23 ` [PATCH v3 kvmtool 06/13] arm/arm64: Fail if RAM size is too large for 32-bit guests Alexandru Elisei
2022-06-01 11:09 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 07/13] arm/arm64: Kill the ARM_MAX_MEMORY() macro Alexandru Elisei
2022-06-01 11:14 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 08/13] arm/arm64: Kill the ARM_HIMAP_MAX_MEMORY() macro Alexandru Elisei
2022-06-01 11:16 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 09/13] builtin_run: Allow standard size specifiers for memory Alexandru Elisei
2022-06-01 13:39 ` Andre Przywara
2022-06-01 14:17 ` Alexandru Elisei
2022-06-01 16:14 ` Andre Przywara
2022-06-01 19:39 ` Alexandru Elisei
2022-06-01 19:42 ` Alexandru Elisei
2022-06-01 20:13 ` Alexandru Elisei
2022-06-06 10:53 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 10/13] kvm__arch_init: Remove hugetlbfs_path and ram_size as parameters Alexandru Elisei
2022-06-01 13:13 ` Andre Przywara [this message]
2022-05-25 11:23 ` [PATCH v3 kvmtool 11/13] arm/arm64: Consolidate RAM initialization in kvm__init_ram() Alexandru Elisei
2022-06-01 13:20 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 12/13] Introduce kvm__arch_default_ram_address() Alexandru Elisei
2022-06-01 13:21 ` Andre Przywara
2022-05-25 11:23 ` [PATCH v3 kvmtool 13/13] arm64: Allow the user to specify the RAM base address Alexandru Elisei
2022-06-01 13:39 ` Andre Przywara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220601141327.1d49859b@donnerap.cambridge.arm.com \
--to=andre.przywara@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=james.morse@arm.com \
--cc=julien.grall@arm.com \
--cc=julien.thierry.kdev@gmail.com \
--cc=julien@xen.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=maz@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox