Re: [PATCH v2 3/3] kvmtool: arm64: Configure VM with the minimal required IPA space

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 23, 2021 at 2:36 AM Marc Zyngier <maz@xxxxxxxxxx> wrote:
>
> On Sun, 22 Aug 2021 21:05:16 +0100,
> Oliver Upton <oupton@xxxxxxxxxx> wrote:
> >
> > Marc,
> >
> > On Sun, Aug 22, 2021 at 8:25 AM Marc Zyngier <maz@xxxxxxxxxx> wrote:
> > >
> > > There is some value in keeping the IPA space small, as it reduces
> > > the size of the stage-2 page tables.
> > >
> > > Let's compute the required space at VM creation time, and inform
> > > the kernel of our requirements.
> > >
> > > Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
> > > ---
> > >  arm/aarch64/kvm.c | 20 +++++++++++++++++++-
> > >  1 file changed, 19 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arm/aarch64/kvm.c b/arm/aarch64/kvm.c
> > > index d03a27f2..4e66a22e 100644
> > > --- a/arm/aarch64/kvm.c
> > > +++ b/arm/aarch64/kvm.c
> > > @@ -3,6 +3,7 @@
> > >  #include <asm/image.h>
> > >
> > >  #include <linux/byteorder.h>
> > > +#include <kvm/util.h>
> > >
> > >  /*
> > >   * Return the TEXT_OFFSET value that the guest kernel expects. Note
> > > @@ -59,5 +60,22 @@ int kvm__arch_get_ipa_limit(struct kvm *kvm)
> > >
> > >  int kvm__get_vm_type(struct kvm *kvm)
> > >  {
> > > -       return KVM_VM_TYPE_ARM_IPA_SIZE(kvm__arch_get_ipa_limit(kvm));
> > > +       unsigned int ipa_bits, max_ipa_bits;
> > > +       unsigned long max_ipa;
> > > +
> > > +       /* If we're running on an old kernel, use 0 as the VM type */
> > > +       max_ipa_bits = kvm__arch_get_ipa_limit(kvm);
> > > +       if (!max_ipa_bits)
> > > +               return 0;
> > > +
> > > +       /* Otherwise, compute the minimal required IPA size */
> > > +       max_ipa = ARM_MEMORY_AREA + kvm->cfg.ram_size - 1;
> > > +       ipa_bits = max(32, fls_long(max_ipa));
> > > +       pr_debug("max_ipa %lx ipa_bits %d max_ipa_bits %d",
> > > +                max_ipa, ipa_bits, max_ipa_bits);
> > > +
> > > +       if (ipa_bits > max_ipa_bits)
> > > +               die("Memory too large for this system (needs %d bits, %d available)", ipa_bits, max_ipa_bits);
> >
> > I imagine it may not be immediately obvious to a kvmtool user what
> > this log line means, like what 'bits' are being referred to here.
> > Would it be more helpful to report the maximum allowed memory size for
> > the system, as derived from the max IPA?
>
> That's consistent with what "the other VMM" does as well.

Lol
> But sure,
> happy to amend the message if people feel strongly about it.

Eh, maybe not worth the extra math in the end. My nit would be to say
"needs %d IPA bits" in the message. But regardless:

Reviewed-by: Oliver Upton <oupton@xxxxxxxxxx>
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux