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 12948C433EF for ; Tue, 12 Jul 2022 15:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233187AbiGLP0C (ORCPT ); Tue, 12 Jul 2022 11:26:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233212AbiGLPZ4 (ORCPT ); Tue, 12 Jul 2022 11:25:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E01BA47D; Tue, 12 Jul 2022 08:25:56 -0700 (PDT) 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 B64C7615D1; Tue, 12 Jul 2022 15:25:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24419C3411C; Tue, 12 Jul 2022 15:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657639555; bh=f03fkCp+T0kJXEAtG828037pWBQYAHiFGeWOGKqwIQc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ltCadJraaEfxB1g2nkhYInID6Kd/VGUbti3z07+JcpgnNZfeQQIb1y4sziX9yHG8C euE/ussnFSRMTcd7VG19RvLvHHZEU5ctHVt+bXHuO0gcerAoBZgYH90oJRsZny9Coi xFkh/sdvn1Seno8FkCccBu5sNjGbZGFFabc5W9GJEDed1QRaXJI1LLnaUdP1NxS+In tIcyPvfe0XAaAWLSj6XxSask4aY1x1lRna3ngktJHAw2Dm0DZxvzlBh1thHZijAIQk J+a0xlapnQSgIw4RamPB8PY6badYroNFW+aY7osH4hhbEK3bVs1zGJl7UJb39HJAnP bVxDRSKEj7J8Q== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.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 1oBHlo-006yiG-W3; Tue, 12 Jul 2022 16:25:53 +0100 Date: Tue, 12 Jul 2022 16:25:52 +0100 Message-ID: <87bktu1hfj.wl-maz@kernel.org> From: Marc Zyngier To: "chenxiang (M)" Cc: Alex Williamson , , , chenxiang via , linux-kernel Subject: Re: [QUESTION] Exception print when enabling GICv4 In-Reply-To: <6d6d61fb-6241-4e1e-ddff-8ae8be96f9ff@hisilicon.com> References: <6d6d61fb-6241-4e1e-ddff-8ae8be96f9ff@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 (x86_64-pc-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, pbonzini@redhat.com, kvm@vger.kernel.org, qemu-devel@nongnu.org, linux-kernel@vger.kernel.org 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 Hi Xiang, On Tue, 12 Jul 2022 13:55:16 +0100, "chenxiang (M)" wrote: > > Hi, > I encounter a issue related to GICv4 enable on ARM64 platform (kernel > 5.19-rc4, qemu 6.2.0): > We have a accelaration module whose VF has 3 MSI interrupts, and we > passthrough it to virtual machine with following steps: > > echo 0000:79:00.1 > /sys/bus/pci/drivers/hisi_hpre/unbind > echo vfio-pci > > /sys/devices/pci0000\:78/0000\:78\:00.0/0000\:79\:00.1/driver_override > echo 0000:79:00.1 > /sys/bus/pci/drivers_probe > > Then we boot VM with "-device vfio-pci,host=79:00.1,id=net0 \". > When insmod the driver which registers 3 PCI MSI interrupts in VM, > some exception print occur as following: > > vfio-pci 0000:3a:00.1: irq bypass producer (token 000000008f08224d) > registration fails: 66311 > > I find that bit[6:4] of register PCI_MSI_FLAGS is 2 (4 MSI interrupts) > though we only register 3 PCI MSI interrupt, > > and only 3 MSI interrupt is activated at last. > It allocates 4 vectors in function vfio_msi_enable() (qemu) as it > reads the register PCI_MSI_FLAGS. > Later it will call system call VFIO_DEVICE_SET_IRQS to set forwarding > for those interrupts > using function kvm_vgic_v4_set_forrwarding() as GICv4 is enabled. For > interrupt 0~2, it success to set forwarding as they are already > activated, > but for the 4th interrupt, it is not activated, so ite is not found in > function vgic_its_resolve_lpi(), so above printk occurs. > > It seems that we only allocate and activate 3 MSI interrupts in guest > while it tried to set forwarding for 4 MSI interrupts in host. > Do you have any idea about this issue? I have a hunch: QEMU cannot know that the guest is only using 3 MSIs out of the 4 that the device can use, and PCI/Multi-MSI only has a single enable bit for all MSIs. So it probably iterates over all possible MSIs and enable the forwarding. Since the guest has only created 3 mappings in the virtual ITS, the last call fails. I would expect the guest to still work properly though. Thanks, M. -- Without deviation from the norm, progress is not possible.