From: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: kvm@vger.kernel.org, Andre Przywara <Andre.Przywara@arm.com>,
Ard Biesheuvel <ardb@kernel.org>, Will Deacon <will@kernel.org>,
kvmarm@lists.cs.columbia.edu
Subject: Re: [PATCH][kvmtool] kvm: Request VM specific limits instead of system-wide ones
Date: Mon, 27 Apr 2020 18:33:31 +0100 [thread overview]
Message-ID: <20200427183331.48f411f5@why> (raw)
In-Reply-To: <7ac17890-72d1-1c81-e513-5d4f7841ca9d@arm.com>
On Mon, 27 Apr 2020 16:00:58 +0100
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> Hi,
>
> On 4/27/20 3:44 PM, Alexandru Elisei wrote:
> > Hi,
> >
> > On 4/27/20 3:17 PM, Marc Zyngier wrote:
> >> 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.
> >>
> >> 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);
> >>
> > I've checked that gic__create comes before the call kvm__recommended_capus:
> > gic__create is in core_init (called via kvm__init->kvm_arch_init), and
> > kvm__recommended_cpus is in base_init (called via kvm__cpu_init ->
> > kvm__{recommended,max}_cpus).
> >
> > The KVM api documentation states that KVM_CHECK_EXTENSION is available for the vm
> > fd only if the system capability KVM_CAP_CHECK_EXTENSION_VM is present. kvmtool
> > already has a function for checking extensions on the vm fd, it's called
> > kvm__supports_vm_extension. Can we use that instead of doing the ioctl directly on
> > the vm fd?
>
> Scratch that, kvm__supports_vm_extension returns a bool, not an int.
> How about we write kvm__check_vm_extension that returns an int, and
> kvm__supports_vm_extension calls it?
That, or we just change the return type for kvm__supports_vm_extension,
and hack the only places that uses it so far (the GIC code) to detect
the error.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
_______________________________________________
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: Marc Zyngier <maz@kernel.org>
To: Alexandru Elisei <alexandru.elisei@arm.com>
Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org,
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>,
Andre Przywara <Andre.Przywara@arm.com>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH][kvmtool] kvm: Request VM specific limits instead of system-wide ones
Date: Mon, 27 Apr 2020 18:33:31 +0100 [thread overview]
Message-ID: <20200427183331.48f411f5@why> (raw)
In-Reply-To: <7ac17890-72d1-1c81-e513-5d4f7841ca9d@arm.com>
On Mon, 27 Apr 2020 16:00:58 +0100
Alexandru Elisei <alexandru.elisei@arm.com> wrote:
> Hi,
>
> On 4/27/20 3:44 PM, Alexandru Elisei wrote:
> > Hi,
> >
> > On 4/27/20 3:17 PM, Marc Zyngier wrote:
> >> 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.
> >>
> >> 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);
> >>
> > I've checked that gic__create comes before the call kvm__recommended_capus:
> > gic__create is in core_init (called via kvm__init->kvm_arch_init), and
> > kvm__recommended_cpus is in base_init (called via kvm__cpu_init ->
> > kvm__{recommended,max}_cpus).
> >
> > The KVM api documentation states that KVM_CHECK_EXTENSION is available for the vm
> > fd only if the system capability KVM_CAP_CHECK_EXTENSION_VM is present. kvmtool
> > already has a function for checking extensions on the vm fd, it's called
> > kvm__supports_vm_extension. Can we use that instead of doing the ioctl directly on
> > the vm fd?
>
> Scratch that, kvm__supports_vm_extension returns a bool, not an int.
> How about we write kvm__check_vm_extension that returns an int, and
> kvm__supports_vm_extension calls it?
That, or we just change the return type for kvm__supports_vm_extension,
and hack the only places that uses it so far (the GIC code) to detect
the error.
Thanks,
M.
--
Jazz is not dead. It just smells funny...
next prev parent reply other threads:[~2020-04-27 17:33 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 [this message]
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
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=20200427183331.48f411f5@why \
--to=maz@kernel.org \
--cc=Andre.Przywara@arm.com \
--cc=alexandru.elisei@arm.com \
--cc=ardb@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--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.