On Sun, Aug 22, 2021 at 8:25 AM Marc Zyngier <maz@xxxxxxxxxx> wrote: > > Instead of just asking the the default VM size, request the maximum > IPA size to the kernel, and use this at VM creation time. > > The IPA space is parametrized accordingly. > > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx> > --- > arm/aarch64/include/kvm/kvm-arch.h | 19 ++++++++++++++++--- > arm/aarch64/kvm.c | 15 +++++++++++++++ > 2 files changed, 31 insertions(+), 3 deletions(-) > > diff --git a/arm/aarch64/include/kvm/kvm-arch.h b/arm/aarch64/include/kvm/kvm-arch.h > index 55ef8ed1..159567b9 100644 > --- a/arm/aarch64/include/kvm/kvm-arch.h > +++ b/arm/aarch64/include/kvm/kvm-arch.h > @@ -3,10 +3,23 @@ > > struct kvm; > unsigned long long kvm__arch_get_kern_offset(struct kvm *kvm, int fd); > +int kvm__arch_get_ipa_limit(struct kvm *kvm); > > -#define ARM_MAX_MEMORY(kvm) ((kvm)->cfg.arch.aarch32_guest ? \ > - ARM_LOMAP_MAX_MEMORY : \ > - ARM_HIMAP_MAX_MEMORY) > +#define ARM_MAX_MEMORY(kvm) ({ \ > + u64 max_ram; \ > + \ > + if ((kvm)->cfg.arch.aarch32_guest) { \ > + max_ram = ARM_LOMAP_MAX_MEMORY; \ > + } else { \ > + int ipabits = kvm__arch_get_ipa_limit(kvm); \ > + if (ipabits <= 0) \ > + max_ram = ARM_HIMAP_MAX_MEMORY; \ > + else \ > + max_ram = (1ULL << ipabits) - ARM_MEMORY_AREA; \ > + } \ > + \ > + max_ram; \ > +}) > > #include "arm-common/kvm-arch.h" > > diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c > index 49e1dd31..d03a27f2 100644 > --- a/arm/aarch64/kvm.c > +++ b/arm/aarch64/kvm.c > @@ -46,3 +46,18 @@ fail: > return 0x80000; > } > > +int kvm__arch_get_ipa_limit(struct kvm *kvm) > +{ > + int ret; > + > + ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_ARM_VM_IPA_SIZE); > + if (ret <= 0) > + ret = 0; > + > + return ret; > +} > + > +int kvm__get_vm_type(struct kvm *kvm) > +{ > + return KVM_VM_TYPE_ARM_IPA_SIZE(kvm__arch_get_ipa_limit(kvm)); > +} > -- > 2.30.2 > > _______________________________________________ > kvmarm mailing list > kvmarm@xxxxxxxxxxxxxxxxxxxxx > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm Reviewed-by: Oliver Upton <oupton@xxxxxxxxxx> _______________________________________________ kvmarm mailing list kvmarm@xxxxxxxxxxxxxxxxxxxxx https://lists.cs.columbia.edu/mailman/listinfo/kvmarm