From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andre Przywara Subject: Re: [RFC PATCH] KVM: introduce kvm_check_device Date: Wed, 07 Jan 2015 10:55:45 +0000 Message-ID: <54AD10B1.9020709@arm.com> References: <1420560724-5345-1-git-send-email-andre.przywara@arm.com> <1420577568.4961.23.camel@freescale.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: "kvm@vger.kernel.org" , Will Deacon , "kvmarm@lists.cs.columbia.edu" To: Scott Wood Return-path: Received: from cam-admin0.cambridge.arm.com ([217.140.96.50]:62965 "EHLO cam-admin0.cambridge.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472AbbAGKzv (ORCPT ); Wed, 7 Jan 2015 05:55:51 -0500 In-Reply-To: <1420577568.4961.23.camel@freescale.com> Sender: kvm-owner@vger.kernel.org List-ID: Hi Scott, thanks for looking at the patch. On 06/01/15 20:52, Scott Wood wrote: > On Tue, 2015-01-06 at 16:12 +0000, Andre Przywara wrote: >> While we can easily register and unregister KVM devices, there is >> currently no easy way of checking whether a device has been >> registered. >> Introduce kvm_check_device() for that purpose and use it in two >> existing functions. Also change the return code for an invalid >> type number from ENOSPC to EINVAL. >> This function will be later used by another patch set to check >> whether a KVM_CREATE_IRQCHIP ioctl is valid. > > You're checking whether a device type has been registered, not the > device itself -- so could you make it kvm_check_device_type()? Sure. If you are OK with the general approach, I will include the patch in my GICv3 KVM emulation series. >> Signed-off-by: Andre Przywara >> --- >> Hi, >> >> can people comment whether there is an easier way to detect KVM >> device registration _outside_ of virt/kvm/kvm_main.c? Using the >> KVM_CREATE_DEVICE_TEST flag sounds like a fit, but >> kvm_ioctl_create_device() isn't exported. > > Out of curiosity, why do you need to test it from inside the kernel but > outside kvm_main.c? I need it from arch/arm/kvm/arm.c or alternatively virt/kvm/arm/vgic.c. The problem is that while KVM_CREATE_DEVICE works fine with checking the availability of the requested device, KVM_CREATE_IRQCHIP does not - and the latter is handled in the arch specific parts of the code. At the moment the GIC_V2 is the only IRQ chip, so it's all or nothing right now. But very soon there will be a GIC_V3, with GIC_V2 compatibility not always being available, so KVM_CREATE_IRQCHIP may fail although there is an in-kernel IRQ chip available. Instead of hacking something up I thought it would be cleaner to use the existing framework and just map KVM_CREATE_IRQCHIP to KVM_CREATE_DEVICE(KVM_DEV_TYPE_ARM_VGIC_V2). Thanks, Andre.