From: julien.grall@arm.com (Julien Grall)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC 12/13] kvmtool: arm64: Switch memory layout
Date: Thu, 10 May 2018 15:04:40 +0100 [thread overview]
Message-ID: <20180510140441.24573-13-julien.grall@arm.com> (raw)
In-Reply-To: <20180510140441.24573-1-julien.grall@arm.com>
From: Suzuki K Poulose <suzuki.poulose@arm.com>
If the guest wants to use a larger physical address space place
the RAM at upper half of the address space. Otherwise, it uses the
default layout.
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
arm/aarch32/include/kvm/kvm-arch.h | 1 +
arm/aarch64/include/kvm/kvm-arch.h | 13 ++++++++++---
arm/include/arm-common/kvm-arch.h | 8 ++++++--
arm/kvm.c | 2 +-
4 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/arm/aarch32/include/kvm/kvm-arch.h b/arm/aarch32/include/kvm/kvm-arch.h
index 2ee0cb1..f0f0943 100644
--- a/arm/aarch32/include/kvm/kvm-arch.h
+++ b/arm/aarch32/include/kvm/kvm-arch.h
@@ -4,6 +4,7 @@
#define ARM_KERN_OFFSET(...) 0x8000
#define ARM_MAX_PHYS_SHIFT(...) 32
+#define ARM_MEMORY_AREA(...) ARM32_MEMORY_AREA
#include "arm-common/kvm-arch.h"
diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h
index 53ac20f..9c9009b 100644
--- a/arm/aarch64/include/kvm/kvm-arch.h
+++ b/arm/aarch64/include/kvm/kvm-arch.h
@@ -1,12 +1,19 @@
#ifndef KVM__KVM_ARCH_H
#define KVM__KVM_ARCH_H
+#include "arm-common/kvm-arch.h"
+
+#define ARM64_MEMORY_AREA(phys_shift) (1UL << (phys_shift - 1))
+
+#define ARM_MEMORY_AREA(cfg) ((cfg)->arch.aarch32_guest ? \
+ ARM32_MEMORY_AREA : \
+ ARM64_MEMORY_AREA((cfg)->arch.phys_shift))
+
#define ARM_KERN_OFFSET(kvm) ((kvm)->cfg.arch.aarch32_guest ? \
0x8000 : \
0x80000)
-#define ARM_MAX_PHYS_SHIFT(cfg) ((cfg)->arch.aarch32_guest ? 32 : 40)
-
-#include "arm-common/kvm-arch.h"
+#define ARM_MAX_PHYS_SHIFT(cfg) ((cfg)->arch.aarch32_guest ? 32 : \
+ (cfg)->arch.phys_shift)
#endif /* KVM__KVM_ARCH_H */
diff --git a/arm/include/arm-common/kvm-arch.h b/arm/include/arm-common/kvm-arch.h
index 884dda8..4be9589 100644
--- a/arm/include/arm-common/kvm-arch.h
+++ b/arm/include/arm-common/kvm-arch.h
@@ -10,7 +10,11 @@
#define ARM_IOPORT_AREA _AC(0x0000000000000000, UL)
#define ARM_MMIO_AREA _AC(0x0000000000010000, UL)
#define ARM_AXI_AREA _AC(0x0000000040000000, UL)
-#define ARM_MEMORY_AREA _AC(0x0000000080000000, UL)
+
+#define ARM32_MEMORY_AREA _AC(0x0000000080000000, UL)
+#define ARM32_MAX_MEMORY ((1ULL << 32) - ARM32_MEMORY_AREA)
+
+#define ARM_IOMEM_AREA_END ARM32_MEMORY_AREA
#define ARM_GIC_DIST_BASE (ARM_AXI_AREA - ARM_GIC_DIST_SIZE)
#define ARM_GIC_CPUI_BASE (ARM_GIC_DIST_BASE - ARM_GIC_CPUI_SIZE)
@@ -21,7 +25,7 @@
#define ARM_IOPORT_SIZE (ARM_MMIO_AREA - ARM_IOPORT_AREA)
#define ARM_VIRTIO_MMIO_SIZE (ARM_AXI_AREA - (ARM_MMIO_AREA + ARM_GIC_SIZE))
#define ARM_PCI_CFG_SIZE (1ULL << 24)
-#define ARM_PCI_MMIO_SIZE (ARM_MEMORY_AREA - \
+#define ARM_PCI_MMIO_SIZE (ARM_IOMEM_AREA_END - \
(ARM_AXI_AREA + ARM_PCI_CFG_SIZE))
#define KVM_IOPORT_AREA ARM_IOPORT_AREA
diff --git a/arm/kvm.c b/arm/kvm.c
index 8a7c611..5a2bd28 100644
--- a/arm/kvm.c
+++ b/arm/kvm.c
@@ -127,7 +127,7 @@ static void kvm__arch_sanitize_cfg(struct kvm_config *cfg)
*/
if (cfg->nr_ram > 1)
die("sanitize: Base address should be specified for all the banks\n");
- bank0->base = ARM_MEMORY_AREA;
+ bank0->base = ARM_MEMORY_AREA(cfg);
/*
* Keep compatibility with old KVM command line behavior where
* the memory is capped.
--
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 ` Julien Grall [this message]
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-13-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