From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10919C433FE for ; Tue, 8 Nov 2022 12:47:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234241AbiKHMru (ORCPT ); Tue, 8 Nov 2022 07:47:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233633AbiKHMrt (ORCPT ); Tue, 8 Nov 2022 07:47:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2035952887 for ; Tue, 8 Nov 2022 04:47:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B145861556 for ; Tue, 8 Nov 2022 12:47:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EB72C433D6; Tue, 8 Nov 2022 12:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667911667; bh=l4K/YDcC6VqkVGo4iWVqT5AwzGO/i+AQZ5Jm4A3kjmU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DbsjhCqZUeMvT8tuWKWN0ZpMPzZjZZUB++OgXz99iDfh5Bmt5Ul0sJOGSwD5RJ/wS /fAPpY0AJNt/1VHIVl4yebh2DzRmKvZzzV7PpGDglb1UmzqezZ/Pzc5BAUNjQCZbuQ DgkVeEUNBCH/JQpoG+8XASeoYal4guF+HvGz48DXqavGZCcZdn6xFPeWyp+lxV+r+a DNMo89ktA5Hum8tE58ZKL3b55ecc0PI1hW8u+ZgbQsnOzTAtLJbRZ3RKvaAzwIdAls tORDqIxLovm32T7LxwCH6YMJr1wfG8hmtPdysPDmqho/kY9DCkEfZ61h1P7O/w1u3l FxE0PAJOyWCvw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1osO12-004fvr-Vo; Tue, 08 Nov 2022 12:47:45 +0000 Date: Tue, 08 Nov 2022 12:47:44 +0000 Message-ID: <86wn85pq8f.wl-maz@kernel.org> From: Marc Zyngier To: chenxiang Cc: , , , Subject: Re: [PATCH] KVM: Add system call KVM_VERIFY_MSI to verify MSI vector In-Reply-To: <1667894937-175291-1-git-send-email-chenxiang66@hisilicon.com> References: <1667894937-175291-1-git-send-email-chenxiang66@hisilicon.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: chenxiang66@hisilicon.com, alex.williamson@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, linuxarm@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Tue, 08 Nov 2022 08:08:57 +0000, chenxiang wrote: > > From: Xiang Chen > > Currently the numbers of MSI vectors come from register PCI_MSI_FLAGS > which should be power-of-2, but in some scenaries it is not the same as > the number that driver requires in guest, for example, a PCI driver wants > to allocate 6 MSI vecotrs in guest, but as the limitation, it will allocate > 8 MSI vectors. So it requires 8 MSI vectors in qemu while the driver in > guest only wants to allocate 6 MSI vectors. > > When GICv4.1 is enabled, we can see some exception print as following for > above scenaro: > vfio-pci 0000:3a:00.1: irq bypass producer (token 000000008f08224d) registration fails:66311 > > In order to verify whether a MSI vector is valid, add KVM_VERIFY_MSI to do > that. If there is a mapping, return 0, otherwise return negative value. > > This is the kernel part of adding system call KVM_VERIFY_MSI. Exposing something that is an internal implementation detail to userspace feels like the absolute wrong way to solve this issue. Can you please characterise the issue you're having? Is it that vfio tries to enable an interrupt for which there is no virtual ITS mapping? Shouldn't we instead try and manage this in the kernel? Thanks, M. -- Without deviation from the norm, progress is not possible.