Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2205479rdf; Mon, 6 Nov 2023 07:35:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGItJkE5WWSXLW4/14cuBxPC3mDsNCIaIL6RZBXsqvDPkn21zOkHUWi8kB50//i6H3Uma/ X-Received: by 2002:a05:6a20:841c:b0:183:e7ba:8919 with SMTP id c28-20020a056a20841c00b00183e7ba8919mr4559088pzd.46.1699284950847; Mon, 06 Nov 2023 07:35:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699284950; cv=none; d=google.com; s=arc-20160816; b=0w/lHJASDealemdR2TOeMDl1YUOQj0zO7pOhTp/F4gU0JrzXO/eIt/pWfepudzKvXd xPPlmXpJzDT/au22XuWcBQSm7LXGEsKfnqiE3NgcPc3dusN5uRZGO/fONUxxADIOq0Hz l5hesMQS8TK5/XOGejC8bylQ0eMvoIextOedqYMSyl1a1M+vgGu1rx46ef8Fch06iVlu UWkE5CX0+9HsD3h8zSCOCuq+rl8POcANUZv4EfmCIq0XLoc3hb3VP1PuFJfHq2wewrnf 0Z+Wih6A6GaYQp1OWTZ3m11j5HZ54SaojUnMQVJ5m6CcSd8uMPVOeoecVSIkLXDntKKG bZmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=QN9PlLU87KtqiGbMa4KJBoLuR+aXNpBWPM+GeSjuPVw=; fh=Gfhd/Pz2thOZzDJi3kGIb3fIDxTZRtE4Apu0pYpkj9I=; b=tMYqlYg7MJT4LvbCMh26qhHoI7rDQYIqfxDmAnQfAyz8HjQuif2NkidqVPJgpBjY4I dt0niPsddcBn7UCxk25Kkarxqc+QVpef6I0HHZkbdfsjdLyTTUg5+B+XQTnk/uB8gJb1 uSWhou39wC5+e0JvNfeZF7PeTvJprTQ4Xh/ob/Onv9i9gyNSd3unHWPDoOekhWtaDKsl fhQdbqLlsTrWM8p08+gJyJ6ZurnS/RLBDqNxuypiOWgw9yo1fhIVCOWY0uRswmV6KkqU C1GH5B3y0S3xdPObCY8TEK9X2dAm+t2b738FaAPhNbILaIQwjqEQaRIAN7ac/JowK2eb B7ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id cl1-20020a056a02098100b0057c24bae994si8660454pgb.355.2023.11.06.07.35.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 07:35:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id C0CA080260D0; Mon, 6 Nov 2023 07:35:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232064AbjKFPfm (ORCPT + 99 others); Mon, 6 Nov 2023 10:35:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbjKFPfk (ORCPT ); Mon, 6 Nov 2023 10:35:40 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01FBB100 for ; Mon, 6 Nov 2023 07:35:35 -0800 (PST) Received: from kwepemm000007.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SPFgG6CmhzMmW3; Mon, 6 Nov 2023 23:31:06 +0800 (CST) Received: from [10.174.185.210] (10.174.185.210) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 6 Nov 2023 23:35:32 +0800 Subject: Re: [RFC PATCH] KVM: arm/arm64: GICv4: Support shared VLPI To: Marc Zyngier CC: Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Gavin Shan , Jean-Philippe Brucker , "open list:IRQCHIP DRIVERS" , , References: <20231102143507.840-1-jiangkunkun@huawei.com> <87msvt6cc7.wl-maz@kernel.org> From: Kunkun Jiang Message-ID: <12266a84-1148-954c-c6d6-67c8f9cc80b7@huawei.com> Date: Mon, 6 Nov 2023 23:33:13 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <87msvt6cc7.wl-maz@kernel.org> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.174.185.210] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm000007.china.huawei.com (7.193.23.189) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 06 Nov 2023 07:35:50 -0800 (PST) Hi Marc, On 2023/11/4 18:29, Marc Zyngier wrote: > On Thu, 02 Nov 2023 14:35:07 +0000, > Kunkun Jiang wrote: >> In some scenarios, the guest virtio-pci driver will request two MSI-X, >> one vector for config, one shared for queues. However, the host driver >> (vDPA or VFIO) will request a vector for each queue. > Well, VFIO will request *all* available MSI-X. It doesn't know what a > queue is. > >> In the current implementation of GICv4/4.1 direct injection of vLPI, >> pINTID and vINTID have one-to-one correspondence. Therefore, the > This matching is a hard requirement that matches the architecture. You > cannot change it. > >> above scenario cannot be handled correctly. The host kernel will >> execute its_map_vlpi multiple times but only execute its_unmap_vlpi >> once. This may cause guest hang[1]. > Why does it hang? As far as it is concerned, it has unmapped the > interrupts it cares about. Where are the calls to its_map_vlpi() > coming from? It should only occur if the guest actively programs the > MSI-X registers. What is your VMM? How can I reproduce this issue? > >> | WARN_ON(!(irq->hw && irq->host_irq == virq)); >> | if (irq->hw) { >> | atomic_dec(&irq->target_vcpu->arch.vgic_cpu.vgic_v3.its_vpe.vlpi_count); >> | irq->hw = false; >> | ret = its_unmap_vlpi(virq); >> | } >> >> Add a list to struct vgic_irq to record all host irqs mapped to the vlpi. >> When performing an action on the vlpi, traverse the list and perform this >> action on all host irqs. > This makes no sense. You are blindly associating multiple host > interrupts with a single guest interrupt. This is a blatant violation > of the architecture. When unmapping a VLPI from a guest, only this one > should be turned again into an LPI. Not two, not all, just this one. > > Maybe you have found an actual issue, but this patch is absolutely > unacceptable. Please fully describe the problem, provide traces, and > if possible a reproducer. > >> Link: https://lore.kernel.org/all/0d9fdf42-76b1-afc6-85a9-159c5490bbd4@huawei.com/#t > I tried to parse this, but it hardly makes sense either. You seem to > imply that the host driver pre-configures the device, which is > completely wrong. The host driver (VFIO) should simply request all > possible physical LPIs, and that's all. It is expected that this > requesting has no other effect on the HW. Also, since your guest > driver only configures a single vLPI, there should be only a single > its_map_vlpi() call. Sorry to replay so late. The virtio-scsi device has seven vectors (entry0-6): one for config, six for queues. In Guest, e.g. centos 7.6 4.19, virtio-pci driver will request only one vLPI, which is shared for queues. The entry 0 is used for config. It's not relevant to this issue, so we're not going to discuss it. The virtio-pci driver write entry1-6 massage.data in the msix-table and trap to QEMU for processing. The massage.data is as follow: > entry-0 0 > entry-1 1 > entry-2 1 > entry-3 1 > entry-4 1 > entry-5 1 > entry-6 1 The calling process of kvm is as follows. its_map_vlpi_will be executed 6 times. Six host irqs are mapped to one vLPI. > kvm_irqfd_assign >     irq_bypass_register_consumer >         ... >         kvm_arch_irq_bypass_add_producer >             kvm_vgic_v4_set_forwarding >                 its_map_vlpi When executing the reboot command inside the Guest, kvm_vgic_v4_unset_forwarding will be execute 6 times. WARN_ON will also be triggered 6 times. But its_unmap_vlpi will only be executed the first time. > kvm_arch_irq_bypass_del_producer >     kvm_vgic_v4_unset_forwarding >         WARN_ON(!(irq->hw && irq->host_irq == virq)); >         if (irq->hw) { >             irq->hw = false; > its_unmap_vlpi >         } Therefore, only the mapping between the first host irq and vLPI is unmapped. When the guest reboots into the BIOS phase, the remaining 5 host irqs may still send interrupts. This causes the guest to hang. Looking forward to your reply. Thanks, Kunkun Jiang > So it seems to me that your HW and SW are doing things that are not > expected at all. > > M. >