Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp393705imw; Tue, 12 Jul 2022 23:36:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5DZieKVdrGYSFpG4+7fMYGaA9Tq5nl0mmh4qC3qSVZwu1RVX/nXboVVVVTq8z1YKH+uhO X-Received: by 2002:a17:90b:4d8d:b0:1ef:e3a1:d1bd with SMTP id oj13-20020a17090b4d8d00b001efe3a1d1bdmr8383572pjb.175.1657694162622; Tue, 12 Jul 2022 23:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657694162; cv=none; d=google.com; s=arc-20160816; b=bGLctaNVaJkwQCpcs0vcPzmgu6o6kZh5rQwjwSVsSqjLFcav0Y+I+n3X0PoStJq8iL nT/Cre/en5TfeUB3SXTByjGMGBcsi45nHe6gT6DFkbvgXAOfDyJL/goc/0neELUJsszX dfWI+iFHjgW1qrxlkwwuYFOlRmCYJEde6xZMb105id/MlRlCDZvnkHuqHyIz9TVMGR1S nH7hzbnGVtC/FIYnTlOX0yiVKsf+xBCoVgEnQBb/Tw0d2chlpyp+rQf0fHYZaJ9Z4eYM qTeVekzCk2osMLZDFnPTHOZemNyOPx8m1FMpm+8PR44ftPRY6l+pirxrOywgTfjxd4mI QYKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=TF7wHkKTxrxAdfopxzJlqvaKtCjRqvG+RhonUd0TYZE=; b=uSlCMogawHWdQwpRu5jl2bEnIHo+WRFmi3tR+tv+AlkdSNfVDC8GmO0F3ZMXdW7Ub1 t3CvH0etnJTYup2KX0PCahAfFr/bbsB0c1N4C2bFXW89S8t7Ruf8aOQP2tXctMW1pX7K tOR2g+iMazZ6Q01wXc4fSHrSB0MvPIkbcUQLESYSQaWxO5GfQNB2IbVQDBFJbCd1ymhB qxIimO2tKx/AhCHN+QYlbYDq4xTMGiic2Zh6DMaohbuH9zf1/ONLT6wWj73xh1qTG4bl ncls4xuarTBkF4w5qvlKcbWmogMhQVY7H8EoAJQRyO3JwpMPrPLm/J3cQj7lhRtjpK4Q ThiQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a10-20020a170902ecca00b001616b8f1c0fsi17847889plh.449.2022.07.12.23.35.48; Tue, 12 Jul 2022 23:36:02 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233316AbiGMGCT (ORCPT + 99 others); Wed, 13 Jul 2022 02:02:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230445AbiGMGCR (ORCPT ); Wed, 13 Jul 2022 02:02:17 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6D114F6AC; Tue, 12 Jul 2022 23:02:16 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LjRkY2gqlzVfp7; Wed, 13 Jul 2022 13:58:29 +0800 (CST) Received: from [10.40.193.166] (10.40.193.166) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Wed, 13 Jul 2022 14:02:10 +0800 Subject: Re: [QUESTION] Exception print when enabling GICv4 To: Marc Zyngier References: <6d6d61fb-6241-4e1e-ddff-8ae8be96f9ff@hisilicon.com> <87bktu1hfj.wl-maz@kernel.org> CC: Alex Williamson , , , chenxiang via , linux-kernel From: "chenxiang (M)" Message-ID: <13e4fde9-05e9-f492-a2b6-20d567eb2920@hisilicon.com> Date: Wed, 13 Jul 2022 14:02:10 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <87bktu1hfj.wl-maz@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.40.193.166] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 Hi Marc, Thank you for your reply. 在 2022/7/12 23:25, Marc Zyngier 写道: > 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. 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. > > Thanks, > > M. >