Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp410605imw; Wed, 13 Jul 2022 00:06:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1suK5cua8NCBKtUvGWR4rtDyzZEX91Fkyknq5tEX/7paxFTNDmtJ1UHu7aNpENYiLIXn5dn X-Received: by 2002:a17:90a:2b4a:b0:1ef:3e28:fbc8 with SMTP id y10-20020a17090a2b4a00b001ef3e28fbc8mr2279955pjc.54.1657696018343; Wed, 13 Jul 2022 00:06:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657696018; cv=none; d=google.com; s=arc-20160816; b=FIgKU9fc/8EK2OHuHlFSgh/hX7yBfhQhY5MT8yFGjAn2RYDfDI8ATiPYpEcsVES44F c1JF4UqN46NzNj7opNKxn6moTR87bhY44/plbFZStK6v2mpaYShB++Md3r6xkIDR+yMd Xoh4SvFUyF+vvor6IGCkedIcTMzpN1d0VC7saBOh/b4wTTca/lY+TTHSA/Tqw32vTGK8 me5KbbwJvdS7IOB6RqrH25WUC1SF4HNIEN3cJNBHFlGEOkXQVmAyGI4fXERVoC+LeULZ VxfWtiymq1BtpZUQGVTf3QSd1t2C4jV6Bfgm7zktr6/KHZzseSkbBaFwh6lWgyAtEs3Y 0HTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:subject:cc:to:from:message-id :date:dkim-signature; bh=jA36gJC6EtKl5iS4AS2KczVnTUKNyokhzxOAvU4/o0U=; b=NLSy9+vzfJ8/BmCznyUL9OGp+iwt9znfQp8IlWxvkK1UHrsPytcIVblOvkxPBdZraC V++ooht3mmpSFtQHLGkQoiScApo7yjy9v4rK8NzV9PZSW0n4r+HfBWATWiI3CCL1cAjs /UEGd8twcfIC4N8A6Jrswlf2CLGa4vOPMXHEFriTcmMQIn+1Jw70PjHhpchQV9f3XFxV o+2WcWME4uMRd+6VMdHAgTR7WKZfBb0ChoBFTKc8LJK81naoiVLW5vQgmfgJ5tqKLRBL WFBYC7u1nLUglq7ntXW4Qu/2RSKTnLhnBNTozNxCT7rF6XPwHnl1a0Rt5zbf/PlIoKQ+ bplQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="r4+vtgJ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a170902b68700b0016b829435f5si12816501pls.465.2022.07.13.00.06.46; Wed, 13 Jul 2022 00:06:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="r4+vtgJ/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234189AbiGMG5B (ORCPT + 99 others); Wed, 13 Jul 2022 02:57:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiGMG5A (ORCPT ); Wed, 13 Jul 2022 02:57:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0B8613D6A; Tue, 12 Jul 2022 23:56:55 -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 3BDBB611A5; Wed, 13 Jul 2022 06:56:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0D6AC34114; Wed, 13 Jul 2022 06:56:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657695414; bh=DKPBIy5G1EM3xhqzMqfJWRNGFPADJwakpp4q2L0oBi4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=r4+vtgJ/BjF/IHHR46dA/3SZPJjB5AcuGaE29qnGPKYUd83wfoHSn5NLmyD6fKD6h wSfTI81txXPJiV22p36SnJ+pKJmu6mpcEeVKpw7sH+ENSnhHY3L16hbOviV3hDbiNh Y5qNjZDqTybvJC9nb3nHFPQZ5GIvlKLOJxGT/Qry3m6FjvIf4BYyYYD9dpCEjUZnvO RuWS9ddu/EBANk5tBwso7AacLcyxfg8TbCcR+WKg1VWoAF9QZaAa5ma+D3dqMx0mOl xqGdPNUIcFHPU9Fobfk8o4mjHZVMLnUS1a7Z95Sh2Yn+qG3QRvHRZxWInlJcdh4SKa KaWyiEBpUf5QA== Received: from ip-185-104-136-29.ptr.icomera.net ([185.104.136.29] helo=wait-a-minute.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 1oBWIm-0078fU-85; Wed, 13 Jul 2022 07:56:52 +0100 Date: Wed, 13 Jul 2022 07:56:42 +0100 Message-ID: <87cze9lcut.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: <13e4fde9-05e9-f492-a2b6-20d567eb2920@hisilicon.com> References: <6d6d61fb-6241-4e1e-ddff-8ae8be96f9ff@hisilicon.com> <87bktu1hfj.wl-maz@kernel.org> <13e4fde9-05e9-f492-a2b6-20d567eb2920@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=UTF-8 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 185.104.136.29 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 X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jul 2022 07:02:10 +0100, "chenxiang (M)" wrote: >=20 > Hi Marc, >=20 > Thank you for your reply. >=20 > =E5=9C=A8 2022/7/12 23:25, Marc Zyngier =E5=86=99=E9=81=93: > > Hi Xiang, > >=20 > > 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: > >>=20 > >> 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 > >>=20 > >> Then we boot VM with "-device vfio-pci,host=3D79:00.1,id=3Dnet0 \". > >> When insmod the driver which registers 3 PCI MSI interrupts in VM, > >> some exception print occur as following: > >>=20 > >> vfio-pci 0000:3a:00.1: irq bypass producer (token 000000008f08224d) > >> registration fails: 66311 > >>=20 > >> I find that bit[6:4] of register PCI_MSI_FLAGS is 2 (4 MSI interrupts) > >> though we only register 3 PCI MSI interrupt, > >>=20 > >> 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. > >>=20 > >> 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. >=20 > Yes, that's the reason of exception print. > Is it possible for QEMU to get the exact number of interrupts guest is > using? It seems not. Not really. Or rather, this is a pretty involved process: you'd need to stop the guest, perform a save operation on the ITS (as if you were doing a migration), and then introspect the ITS tables to find whether there is a mapping for each of the possible events generated by the device. Clearly, that's overkill. A better approach would be to be able to retrieve an individual mapping, using a new API that would be similar to KVM_SIGNAL_MSI. It would take the same kvm_msi structure as input, and retrieving the {LPI, CPU} pair or an error if there is no mapping. Thanks, M. --=20 Without deviation from the norm, progress is not possible.