linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Andre Przywara <andre.przywara@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
	Will Deacon <will@kernel.org>,
	Alexandru Elisei <alexandru.elisei@arm.com>
Subject: Re: [PATCH 2/3] kvmtool: arm64: Use the maximum supported IPA size when creating the VM
Date: Thu, 18 Mar 2021 14:06:59 +0000	[thread overview]
Message-ID: <8735wsimik.wl-maz@kernel.org> (raw)
In-Reply-To: <20210318102125.68de47db@slackpad.fritz.box>

On Thu, 18 Mar 2021 10:21:25 +0000,
Andre Przywara <andre.przywara@arm.com> wrote:
> 
> On Tue,  9 Mar 2021 16:39:08 +0000
> Marc Zyngier <maz@kernel.org> wrote:
> 
> Hi,
> 
> > 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@kernel.org>
> > ---
> >  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 55ef8ed..159567b 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 49e1dd3..c4f81d0 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__arch_get_ipa_limit(kvm);
> 
> Shouldn't that be funnelled through KVM_VM_TYPE_ARM_IPA_SIZE()?
> Granted, that doesn't really do anything, but if I understand the
> api.rst directly, it's logically needed to convert the IPA size into a
> VM type.

It wouldn't do anything indeed, until we get the magic extension that
bumps the IPA space beyond 255 bits. Doesn't hurt, I guess...

	M.

-- 
Without deviation from the norm, progress is not possible.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-03-18 14:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-09 16:39 [PATCH 0/3] kvmtool: Limit IPA space to what is actually required Marc Zyngier
2021-03-09 16:39 ` [PATCH 1/3] kvmtool: Abstract KVM_VM_TYPE into a weak function Marc Zyngier
2021-03-18 10:20   ` Andre Przywara
2021-03-09 16:39 ` [PATCH 2/3] kvmtool: arm64: Use the maximum supported IPA size when creating the VM Marc Zyngier
2021-03-18 10:21   ` Andre Przywara
2021-03-18 14:06     ` Marc Zyngier [this message]
2021-03-09 16:39 ` [PATCH 3/3][Do not merge] kvmtool: arm64: Configure VM with the minimal required IPA space Marc Zyngier

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=8735wsimik.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).