Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: julien.grall@arm.com (Julien Grall)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 04/13] Fold kvm__init_ram call in kvm__arch_init
Date: Thu, 10 May 2018 15:04:32 +0100	[thread overview]
Message-ID: <20180510140441.24573-5-julien.grall@arm.com> (raw)
In-Reply-To: <20180510140441.24573-1-julien.grall@arm.com>

The slipt between kvm__init_ram and kvm__arch_init for setting up the
RAM can be quite subttle. By moving the former call in the later, it
will be possible to make the RAM initialization easier on Arm with multi
RAM banks support.

Note that it is necessary to move the call to kvm__arch_init after the
initialization of the list kvm->mem_banks because kvm__init_ram is
relying on it.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 arm/kvm.c         | 4 +++-
 include/kvm/kvm.h | 1 -
 kvm.c             | 4 +---
 mips/kvm.c        | 4 +++-
 powerpc/kvm.c     | 4 +++-
 x86/kvm.c         | 4 +++-
 6 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/arm/kvm.c b/arm/kvm.c
index 7424887..619390a 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -24,7 +24,7 @@ bool kvm__arch_cpu_supports_vm(void)
 	return true;
 }
 
-void kvm__init_ram(struct kvm *kvm)
+static void kvm__init_ram(struct kvm *kvm)
 {
 	int err;
 	u64 phys_start, phys_size;
@@ -97,6 +97,8 @@ 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");
+
+	kvm__init_ram(kvm);
 }
 
 #define FDT_ALIGN	SZ_2M
diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h
index 95bab40..6ac5c66 100644
--- a/include/kvm/kvm.h
+++ b/include/kvm/kvm.h
@@ -79,7 +79,6 @@ 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);
-void kvm__init_ram(struct kvm *kvm);
 int kvm__exit(struct kvm *kvm);
 bool kvm__load_firmware(struct kvm *kvm, const char *firmware_filename);
 bool kvm__load_kernel(struct kvm *kvm, const char *kernel_filename,
diff --git a/kvm.c b/kvm.c
index 98b3cb8..e13d8f2 100644
--- a/kvm.c
+++ b/kvm.c
@@ -317,10 +317,8 @@ int kvm__init(struct kvm *kvm)
 		goto err_vm_fd;
 	}
 
-	kvm__arch_init(kvm);
-
 	INIT_LIST_HEAD(&kvm->mem_banks);
-	kvm__init_ram(kvm);
+	kvm__arch_init(kvm);
 
 	if (!kvm->cfg.firmware_filename) {
 		if (!kvm__load_kernel(kvm, kvm->cfg.kernel_filename,
diff --git a/mips/kvm.c b/mips/kvm.c
index cdb0007..61bf104 100644
--- a/mips/kvm.c
+++ b/mips/kvm.c
@@ -17,7 +17,7 @@ void kvm__arch_read_term(struct kvm *kvm)
 	virtio_console__inject_interrupt(kvm);
 }
 
-void kvm__init_ram(struct kvm *kvm)
+static void kvm__init_ram(struct kvm *kvm)
 {
 	u64	phys_start, phys_size;
 	void	*host_mem;
@@ -75,6 +75,8 @@ void kvm__arch_init(struct kvm *kvm)
 	ret = ioctl(kvm->vm_fd, KVM_CREATE_IRQCHIP);
 	if (ret < 0)
 		die_perror("KVM_CREATE_IRQCHIP ioctl");
+
+	kvm__init_ram(kvm);
 }
 
 void kvm__irq_line(struct kvm *kvm, int irq, int level)
diff --git a/powerpc/kvm.c b/powerpc/kvm.c
index 0f2dab3..2c8dbb7 100644
--- a/powerpc/kvm.c
+++ b/powerpc/kvm.c
@@ -60,7 +60,7 @@ bool kvm__arch_cpu_supports_vm(void)
 	return true;
 }
 
-void kvm__init_ram(struct kvm *kvm)
+static void kvm__init_ram(struct kvm *kvm)
 {
 	u64	phys_start, phys_size;
 	void	*host_mem;
@@ -139,6 +139,8 @@ void kvm__arch_init(struct kvm *kvm)
 			 SPAPR_PCI_MEM_WIN_SIZE,
 			 SPAPR_PCI_IO_WIN_ADDR,
 			 SPAPR_PCI_IO_WIN_SIZE);
+
+	kvm__init_ram(kvm);
 }
 
 void kvm__arch_delete_ram(struct kvm *kvm)
diff --git a/x86/kvm.c b/x86/kvm.c
index 453922f..03b0277 100644
--- a/x86/kvm.c
+++ b/x86/kvm.c
@@ -86,7 +86,7 @@ bool kvm__arch_cpu_supports_vm(void)
  * a gap between 0xe0000000 and 0x100000000 in the guest virtual mem space.
  */
 
-void kvm__init_ram(struct kvm *kvm)
+static void kvm__init_ram(struct kvm *kvm)
 {
 	u64	phys_start, phys_size;
 	void	*host_mem;
@@ -167,6 +167,8 @@ void kvm__arch_init(struct kvm *kvm)
 	ret = ioctl(kvm->vm_fd, KVM_CREATE_IRQCHIP);
 	if (ret < 0)
 		die_perror("KVM_CREATE_IRQCHIP ioctl");
+
+	kvm__init_ram(kvm);
 }
 
 void kvm__arch_delete_ram(struct kvm *kvm)
-- 
2.11.0

  parent reply	other threads:[~2018-05-10 14:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-10 14:04 [RFC 00/13] arm: Allow the user specifying where the RAM is place in the memory Julien Grall
2018-05-10 14:04 ` [RFC 01/13] arm: Allow use of hugepage with 16K pagesize host Julien Grall
2018-05-10 14:04 ` [RFC 02/13] kvm__arch_init: Don't pass hugetlbfs_path and ram_size in parameter Julien Grall
2018-05-10 14:04 ` [RFC 03/13] virtio/scsi: Allow to use multiple banks Julien Grall
2018-05-10 14:04 ` Julien Grall [this message]
2018-05-10 14:04 ` [RFC 05/13] kvm__arch_sanitize_cfg Julien Grall
2018-05-10 14:04 ` [RFC 06/13] arm: Move anything related to RAM initialization in kvm__init_ram Julien Grall
2018-05-10 14:04 ` [RFC 07/13] Allow the user to specify where the RAM is placed in the memory Julien Grall
2018-05-10 14:04 ` [RFC 08/13] arm: Add support for multi memory regions Julien Grall
2018-05-10 14:04 ` [RFC 09/13] virtio: Handle aborts using invalid PFN Julien Grall
2018-05-10 14:04 ` [RFC 10/13] kvmtool: Allow backends to run checks on the KVM device fd Julien Grall
2018-05-10 14:04 ` [RFC 11/13] kvmtool: arm64: Add support for guest physical address size Julien Grall
2018-05-10 14:04 ` [RFC 12/13] kvmtool: arm64: Switch memory layout Julien Grall
2018-05-10 14:04 ` [RFC 13/13] kvmtool: arm/arm64: Add support for creating VM with PA size Julien Grall
2018-05-10 14:14 ` [RFC 00/13] arm: Allow the user specifying where the RAM is place in the memory Julien Grall

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=20180510140441.24573-5-julien.grall@arm.com \
    --to=julien.grall@arm.com \
    --cc=linux-arm-kernel@lists.infradead.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