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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD4D1C4332F for ; Tue, 8 Nov 2022 12:53:43 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1osO1K-0006AV-0O; Tue, 08 Nov 2022 07:48:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osO1H-00068d-Ob for qemu-devel@nongnu.org; Tue, 08 Nov 2022 07:47:59 -0500 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1osO1F-0002wN-Il for qemu-devel@nongnu.org; Tue, 08 Nov 2022 07:47:58 -0500 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 AACE761542; 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 Received-SPF: pass client-ip=2604:1380:4641:c500::1; envelope-from=maz@kernel.org; helo=dfw.source.kernel.org X-Spam_score_int: -70 X-Spam_score: -7.1 X-Spam_bar: ------- X-Spam_report: (-7.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.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.