From: julien.grall@arm.com (Julien Grall)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 13/13] kvmtool: arm/arm64: Add support for creating VM with PA size
Date: Thu, 10 May 2018 15:04:41 +0100 [thread overview]
Message-ID: <20180510140441.24573-14-julien.grall@arm.com> (raw)
In-Reply-To: <20180510140441.24573-1-julien.grall@arm.com>
From: Suzuki K Poulose <suzuki.poulose@arm.com>
Specify the physical size for the VM encoded in the vm type.
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Julien Grall <julien.grall@arm.com>
[julien: Don't specify the type of older kernels | fix max_ipa type]
---
arm/include/arm-common/kvm-arch.h | 6 +++++-
arm/kvm.c | 27 +++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h
index 4be9589..81be262 100644
--- a/arm/include/arm-common/kvm-arch.h
+++ b/arm/include/arm-common/kvm-arch.h
@@ -46,7 +46,11 @@
#define KVM_IRQ_OFFSET GIC_SPI_IRQ_BASE
-#define KVM_VM_TYPE 0
+extern unsigned long kvm_arm_type;
+extern void kvm__arch_init_hyp(struct kvm *kvm);
+
+#define KVM_VM_TYPE kvm_arm_type
+#define kvm__arch_init_hyp kvm__arch_init_hyp
#define VIRTIO_DEFAULT_TRANS(kvm) \
((kvm)->cfg.arch.virtio_trans_pci ? VIRTIO_PCI : VIRTIO_MMIO)
diff --git a/arm/kvm.c b/arm/kvm.c
index 5a2bd28..97c1333 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -13,6 +13,8 @@
#include <stdlib.h>
+unsigned long kvm_arm_type;
+
struct kvm_ext kvm_req_ext[] = {
{ DEFINE_KVM_EXT(KVM_CAP_IRQCHIP) },
{ DEFINE_KVM_EXT(KVM_CAP_ONE_REG) },
@@ -20,6 +22,31 @@ struct kvm_ext kvm_req_ext[] = {
{ 0, 0 },
};
+#ifndef KVM_ARM_GET_MAX_VM_PHYS_SHIFT
+#define KVM_ARM_GET_MAX_VM_PHYS_SHIFT _IO(KVMIO, 0x0a)
+#endif
+
+void kvm__arch_init_hyp(struct kvm *kvm)
+{
+ int max_ipa;
+
+ max_ipa = ioctl(kvm->sys_fd, KVM_ARM_GET_MAX_VM_PHYS_SHIFT);
+ if (max_ipa < 0)
+ max_ipa = 40;
+ if (!kvm->cfg.arch.phys_shift)
+ kvm->cfg.arch.phys_shift = 40;
+ if (kvm->cfg.arch.phys_shift > max_ipa)
+ die("Requested PA size (%u) is not supported by the host (%ubits)\n",
+ kvm->cfg.arch.phys_shift, max_ipa);
+
+ /*
+ * Kernel not implementing the ioctl KVM_ARM_GET_MAX_VM_PHYS_SHIFT
+ * will request to have kvm_arm_type zeroed and assume 40 bits IPA.
+ */
+ if (kvm->cfg.arch.phys_shift != 40)
+ kvm_arm_type = kvm->cfg.arch.phys_shift;
+}
+
bool kvm__arch_cpu_supports_vm(void)
{
/* The KVM capability check is enough. */
--
2.11.0
next prev 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 ` [RFC 04/13] Fold kvm__init_ram call in kvm__arch_init Julien Grall
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 ` Julien Grall [this message]
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-14-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