@@ -2,4 +2,8 @@
void kvm__arch_validate_cfg(struct kvm *kvm)
{
+ if (kvm->cfg.ram_size > ARM_LOMAP_MAX_MEMORY) {
+ die("RAM size 0x%llx exceeds maximum allowed 0x%llx",
+ kvm->cfg.ram_size, ARM_LOMAP_MAX_MEMORY);
+ }
}
@@ -7,6 +7,11 @@
void kvm__arch_validate_cfg(struct kvm *kvm)
{
+ if (kvm->cfg.arch.aarch32_guest &&
+ kvm->cfg.ram_size > ARM_LOMAP_MAX_MEMORY) {
+ die("RAM size 0x%llx exceeds maximum allowed 0x%llx",
+ kvm->cfg.ram_size, ARM_LOMAP_MAX_MEMORY);
+ }
}
/*
@@ -65,7 +65,7 @@ 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)ARM_MAX_MEMORY(kvm));
+ kvm->ram_size = 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_size);
For 64-bit guests, kvmtool exists with an error in kvm__get_vm_type() if the memory size is larger than what KVM supports. For 32-bit guests, the RAM size is silently rounded down to ARM_LOMAP_MAX_MEMORY in kvm__arch_init(). Be consistent and exit with an error when the user has configured the wrong RAM size for 32-bit guests. Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> --- arm/aarch32/kvm.c | 4 ++++ arm/aarch64/kvm.c | 5 +++++ arm/kvm.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-)