From: Andre Przywara <andre.przywara@arm.com> To: Will Deacon <will.deacon@arm.com>, Marc Zyngier <marc.zyngier@arm.com> Cc: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [kvmtool PATCH v10 11/15] add kvm__supports_vm_extension() Date: Tue, 25 Apr 2017 15:39:28 +0100 [thread overview] Message-ID: <20170425143932.17235-12-andre.przywara@arm.com> (raw) In-Reply-To: <20170425143932.17235-1-andre.przywara@arm.com> KVM capabilities can be per-VM, in this case the ioctl should be issued on the VM file descriptor, not on the system fd. Since this feature is guarded by a (system) capability itself, wrap the call into a function of its own. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- include/kvm/kvm.h | 1 + kvm.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 4a76ec2..a76a25d 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -129,6 +129,7 @@ static inline bool host_ptr_in_ram(struct kvm *kvm, void *p) } bool kvm__supports_extension(struct kvm *kvm, unsigned int extension); +bool kvm__supports_vm_extension(struct kvm *kvm, unsigned int extension); static inline void kvm__set_thread_name(const char *name) { diff --git a/kvm.c b/kvm.c index 7fa76f7..665ed14 100644 --- a/kvm.c +++ b/kvm.c @@ -93,6 +93,34 @@ const char *kvm__get_dir(void) return kvm_dir; } +bool kvm__supports_vm_extension(struct kvm *kvm, unsigned int extension) +{ + static int supports_vm_ext_check = 0; + int ret; + + switch (supports_vm_ext_check) { + case 0: + ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, + KVM_CAP_CHECK_EXTENSION_VM); + if (ret <= 0) { + supports_vm_ext_check = -1; + return false; + } + supports_vm_ext_check = 1; + /* fall through */ + case 1: + break; + case -1: + return false; + } + + ret = ioctl(kvm->vm_fd, KVM_CHECK_EXTENSION, extension); + if (ret < 0) + return false; + + return ret; +} + bool kvm__supports_extension(struct kvm *kvm, unsigned int extension) { int ret; -- 2.9.0
WARNING: multiple messages have this Message-ID (diff)
From: andre.przywara@arm.com (Andre Przywara) To: linux-arm-kernel@lists.infradead.org Subject: [kvmtool PATCH v10 11/15] add kvm__supports_vm_extension() Date: Tue, 25 Apr 2017 15:39:28 +0100 [thread overview] Message-ID: <20170425143932.17235-12-andre.przywara@arm.com> (raw) In-Reply-To: <20170425143932.17235-1-andre.przywara@arm.com> KVM capabilities can be per-VM, in this case the ioctl should be issued on the VM file descriptor, not on the system fd. Since this feature is guarded by a (system) capability itself, wrap the call into a function of its own. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- include/kvm/kvm.h | 1 + kvm.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/kvm/kvm.h b/include/kvm/kvm.h index 4a76ec2..a76a25d 100644 --- a/include/kvm/kvm.h +++ b/include/kvm/kvm.h @@ -129,6 +129,7 @@ static inline bool host_ptr_in_ram(struct kvm *kvm, void *p) } bool kvm__supports_extension(struct kvm *kvm, unsigned int extension); +bool kvm__supports_vm_extension(struct kvm *kvm, unsigned int extension); static inline void kvm__set_thread_name(const char *name) { diff --git a/kvm.c b/kvm.c index 7fa76f7..665ed14 100644 --- a/kvm.c +++ b/kvm.c @@ -93,6 +93,34 @@ const char *kvm__get_dir(void) return kvm_dir; } +bool kvm__supports_vm_extension(struct kvm *kvm, unsigned int extension) +{ + static int supports_vm_ext_check = 0; + int ret; + + switch (supports_vm_ext_check) { + case 0: + ret = ioctl(kvm->sys_fd, KVM_CHECK_EXTENSION, + KVM_CAP_CHECK_EXTENSION_VM); + if (ret <= 0) { + supports_vm_ext_check = -1; + return false; + } + supports_vm_ext_check = 1; + /* fall through */ + case 1: + break; + case -1: + return false; + } + + ret = ioctl(kvm->vm_fd, KVM_CHECK_EXTENSION, extension); + if (ret < 0) + return false; + + return ret; +} + bool kvm__supports_extension(struct kvm *kvm, unsigned int extension) { int ret; -- 2.9.0
next prev parent reply other threads:[~2017-04-25 14:39 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-04-25 14:39 [kvmtool PATCH v10 00/15] kvmtool: arm: ITS emulation and GSI routing support Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 01/15] FDT: use static phandles Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 02/15] arm: use static DT phandle for the GIC Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 03/15] irq: move IRQ routing into irq.c Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 04/15] MSI-X: update GSI routing after changed MSI-X configuration Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 05/15] virtio: fix endianness check for vhost support Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 06/15] PCI: Only allocate IRQ routing entry when available Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 07/15] update public Linux headers for GICv3 ITS emulation Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 08/15] arm: allow vGICv3 emulation Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 09/15] arm: allow creation of an MSI register frame region Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 10/15] arm: FDT: create MSI controller DT node Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` Andre Przywara [this message] 2017-04-25 14:39 ` [kvmtool PATCH v10 11/15] add kvm__supports_vm_extension() Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 12/15] PCI: inject PCI device ID on MSI injection Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 13/15] arm: setup SPI IRQ routing tables Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 14/15] extend GSI IRQ routing to take a device ID Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-04-25 14:39 ` [kvmtool PATCH v10 15/15] arm64: enable GICv3-ITS emulation Andre Przywara 2017-04-25 14:39 ` Andre Przywara 2017-06-08 9:11 ` [kvmtool PATCH v10 00/15] kvmtool: arm: ITS emulation and GSI routing support Marc Zyngier 2017-06-08 9:11 ` Marc Zyngier 2017-06-08 9:36 ` Andre Przywara 2017-06-08 9:36 ` Andre Przywara
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=20170425143932.17235-12-andre.przywara@arm.com \ --to=andre.przywara@arm.com \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=marc.zyngier@arm.com \ --cc=will.deacon@arm.com \ /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: linkBe 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.