On Wed, 25 May 2022 12:23:38 +0100 Alexandru Elisei <alexandru.eli...@arm.com> wrote:
> 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.eli...@arm.com> This patch looks fine, as it improves the situation and maintains the current support level, but it turns out that the AArch32 memory limitation is bogus: With LPAE (which is mandatory for any system supporting KVM), there is no reason we can't have memory beyond 4GB of guest PA. In fact, after removing this check, I managed to boot a 32GB AArch32 guest just fine (on a Juno), and a 2919MB guest on an ARMv7 box. It might be useful to lift this limit, as this allows easy testing of the arm(32) kernel's highmem support, but this would be a separate patch, I guess. Reviewed-by: Andre Przywara <andre.przyw...@arm.com> Cheers, Andre > --- > arm/aarch32/kvm.c | 4 ++++ > arm/aarch64/kvm.c | 5 +++++ > arm/kvm.c | 2 +- > 3 files changed, 10 insertions(+), 1 deletion(-) > > diff --git a/arm/aarch32/kvm.c b/arm/aarch32/kvm.c > index ae33ac92479a..9d68d7a15ee2 100644 > --- a/arm/aarch32/kvm.c > +++ b/arm/aarch32/kvm.c > @@ -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); > + } > } > diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c > index ca348f118a56..2134528bf7f2 100644 > --- a/arm/aarch64/kvm.c > +++ b/arm/aarch64/kvm.c > @@ -39,6 +39,11 @@ int vcpu_affinity_parser(const struct option *opt, const > char *arg, int unset) > > 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); > + } > } > > /* > diff --git a/arm/kvm.c b/arm/kvm.c > index c5913000e1ed..af0feae495d7 100644 > --- a/arm/kvm.c > +++ b/arm/kvm.c > @@ -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); _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm