All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Przywara" <andre.przywara@arm.com>
To: Marc Zyngier <maz@kernel.org>,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Cc: Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH][kvmtool] kvm: Request VM specific limits instead of system-wide ones
Date: Mon, 27 Apr 2020 16:37:07 +0100	[thread overview]
Message-ID: <c36c30b1-6017-9c75-e0e9-e643eb348641@arm.com> (raw)
In-Reply-To: <20200427141738.285217-1-maz@kernel.org>

On 27/04/2020 15:17, Marc Zyngier wrote:
Hi,

> On arm64, the maximum number of vcpus is constrained by the type
> of interrupt controller that has been selected (GICv2 imposes a
> limit of 8 vcpus, while GICv3 currently has a limit of 512).
> 
> It is thus important to request this limit on the VM file descriptor
> rather than on the one that corresponds to /dev/kvm, as the latter
> is likely to return something that doesn't take the constraints into
> account.

That sounds reasonable, but I fail to find any distinction in the kernel
code. We don't make any difference between the VM or the system FD in
the ioctl handler for those two extensions. For arm64 we always return
max. 512 (max VCPUs on GICv3), and number of online host cores for the
recommended value. For arm there was a distinction between GICv3 support
compiled in or not, but otherwise the same constant values returned.
Quickly tested on Juno and N1SDP, the ioctls return the same expected
values, regardless of sys_fd vs vm_fd.

So what am I missing here? Is this for some older or even newer kernels?

Cheers,
Andre.

> 
> Reported-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  kvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kvm.c b/kvm.c
> index e327541..3d5173d 100644
> --- a/kvm.c
> +++ b/kvm.c
> @@ -406,7 +406,7 @@ int kvm__recommended_cpus(struct kvm *kvm)
>  {
>  	int ret;
>  
> -	ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS);
> +	ret = ioctl(kvm->vm_fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS);
>  	if (ret <= 0)
>  		/*
>  		 * api.txt states that if KVM_CAP_NR_VCPUS does not exist,
> @@ -421,7 +421,7 @@ int kvm__max_cpus(struct kvm *kvm)
>  {
>  	int ret;
>  
> -	ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
> +	ret = ioctl(kvm->vm_fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
>  	if (ret <= 0)
>  		ret = kvm__recommended_cpus(kvm);
>  
> 

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: "André Przywara" <andre.przywara@arm.com>
To: Marc Zyngier <maz@kernel.org>,
	kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org
Cc: James Morse <james.morse@arm.com>,
	Julien Thierry <julien.thierry.kdev@gmail.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Will Deacon <will@kernel.org>, Ard Biesheuvel <ardb@kernel.org>,
	Alexandru Elisei <Alexandru.Elisei@arm.com>
Subject: Re: [PATCH][kvmtool] kvm: Request VM specific limits instead of system-wide ones
Date: Mon, 27 Apr 2020 16:37:07 +0100	[thread overview]
Message-ID: <c36c30b1-6017-9c75-e0e9-e643eb348641@arm.com> (raw)
In-Reply-To: <20200427141738.285217-1-maz@kernel.org>

On 27/04/2020 15:17, Marc Zyngier wrote:
Hi,

> On arm64, the maximum number of vcpus is constrained by the type
> of interrupt controller that has been selected (GICv2 imposes a
> limit of 8 vcpus, while GICv3 currently has a limit of 512).
> 
> It is thus important to request this limit on the VM file descriptor
> rather than on the one that corresponds to /dev/kvm, as the latter
> is likely to return something that doesn't take the constraints into
> account.

That sounds reasonable, but I fail to find any distinction in the kernel
code. We don't make any difference between the VM or the system FD in
the ioctl handler for those two extensions. For arm64 we always return
max. 512 (max VCPUs on GICv3), and number of online host cores for the
recommended value. For arm there was a distinction between GICv3 support
compiled in or not, but otherwise the same constant values returned.
Quickly tested on Juno and N1SDP, the ioctls return the same expected
values, regardless of sys_fd vs vm_fd.

So what am I missing here? Is this for some older or even newer kernels?

Cheers,
Andre.

> 
> Reported-by: Ard Biesheuvel <ardb@kernel.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  kvm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/kvm.c b/kvm.c
> index e327541..3d5173d 100644
> --- a/kvm.c
> +++ b/kvm.c
> @@ -406,7 +406,7 @@ int kvm__recommended_cpus(struct kvm *kvm)
>  {
>  	int ret;
>  
> -	ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS);
> +	ret = ioctl(kvm->vm_fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS);
>  	if (ret <= 0)
>  		/*
>  		 * api.txt states that if KVM_CAP_NR_VCPUS does not exist,
> @@ -421,7 +421,7 @@ int kvm__max_cpus(struct kvm *kvm)
>  {
>  	int ret;
>  
> -	ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
> +	ret = ioctl(kvm->vm_fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS);
>  	if (ret <= 0)
>  		ret = kvm__recommended_cpus(kvm);
>  
> 


  parent reply	other threads:[~2020-04-27 15:37 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27 14:17 [PATCH][kvmtool] kvm: Request VM specific limits instead of system-wide ones Marc Zyngier
2020-04-27 14:17 ` Marc Zyngier
2020-04-27 14:44 ` Alexandru Elisei
2020-04-27 14:44   ` Alexandru Elisei
2020-04-27 15:00   ` Alexandru Elisei
2020-04-27 15:00     ` Alexandru Elisei
2020-04-27 17:33     ` Marc Zyngier
2020-04-27 17:33       ` Marc Zyngier
2020-04-28  9:09       ` Alexandru Elisei
2020-04-28  9:09         ` Alexandru Elisei
2020-04-27 15:37 ` André Przywara [this message]
2020-04-27 15:37   ` André Przywara
2020-04-27 16:49   ` Marc Zyngier
2020-04-27 16:49     ` 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=c36c30b1-6017-9c75-e0e9-e643eb348641@arm.com \
    --to=andre.przywara@arm.com \
    --cc=ardb@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=maz@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.