Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5938305rdb; Thu, 14 Dec 2023 04:14:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/oox9MPQmGQIbj/xhekYc1msQrPh0kM6t+xjhwqED+ThA4+SgFx9fyF8laqohwnN0knLa X-Received: by 2002:a17:902:f688:b0:1d3:7220:cc65 with SMTP id l8-20020a170902f68800b001d37220cc65mr181477plg.53.1702556086200; Thu, 14 Dec 2023 04:14:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702556086; cv=none; d=google.com; s=arc-20160816; b=tfPjtghlGGWuTHH2pIZQU11seFq1vWnHyDRO0tNU/PAXqDiuLikOQMtrlf78KUik3x RiuZ972z5wUzSCYeJnoRbXNDcxj1vTlO7JSbYyZMP7ekK6VwADhw9tTaSjxr/So7LvqK DsH8rl5FVSuDLcVtyXlIhWNrBwJwomEqnzIBK6l+1iVMUATbC1JOQFBOBPc0pbXqfT2B +TNYgisnIoy9mQlaklce0JjzQB3b1VVKjGuq07nrD0hBb7N6XLO3IYWTXYiEAtK802oS o3fWMSGuUePjWWI0eRBkSD0qcDCFvS03Hy5XQPiOwzfniKV/mCo3VHj8vcH0q+JS+qhm 3WXA== 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 :mime-version:user-agent:date:message-id:subject:cc:to:from; bh=7UZSWfJbnDs2wYEaT11Dw+ufaF/2ylDTgfuX5XXK6Eo=; fh=P1ckRBcD0xzJlYH2NWybWbsX7FsPmglKIqAwJL4bo0Q=; b=tpPXVTRN0NyISD4vCTefJYaP8otVBcbq150kieS5pMIjccsRCiONzjP8be9M5ZjIft 6N0VqyYsMCPebE39+2rzEmGPsaQRp1bqxJTTiZnS/i5UCaivGutbvflwP/fhBg5s6MX2 izxGERzIsKfuNPX03j3vlbQG8wrKtnNOrCTusEmX4VO+Qlqk4AHd//k0syZ78ZfVCR2W 2EKTvxEF75LmlUR/p44giO3m/HkFlONnvVo2PshKvvVCg4VRoKcKTK5rUcjnX+ndOZNH 3t4pgI6XMJEpyT4IRbuher4M4HmaTLya4xR6uNIsLW2LQHpHqtQ9J1EngUoqcWFVmsYs B+rA== 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:8 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 fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id t15-20020a170902e84f00b001d3673fd28asi1135312plg.138.2023.12.14.04.14.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 04:14:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 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 fry.vger.email (Postfix) with ESMTP id 3F641810FBD5; Thu, 14 Dec 2023 04:14:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572962AbjLNMO3 (ORCPT + 99 others); Thu, 14 Dec 2023 07:14:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572951AbjLNMO2 (ORCPT ); Thu, 14 Dec 2023 07:14:28 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 952EEBD for ; Thu, 14 Dec 2023 04:14:34 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SrWVm0htSzMnmP; Thu, 14 Dec 2023 20:14:24 +0800 (CST) Received: from kwepemm000007.china.huawei.com (unknown [7.193.23.189]) by mail.maildlp.com (Postfix) with ESMTPS id B818B1404D9; Thu, 14 Dec 2023 20:14:32 +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.35; Thu, 14 Dec 2023 20:14:31 +0800 From: Kunkun Jiang To: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Catalin Marinas , Will Deacon , Jean-Philippe Brucker CC: "moderated list:ARM SMMU DRIVERS" , , open list , "wanghaibin.wang@huawei.com" Subject: [bug report] GICv4.1: vSGI remains pending across the guest reset Message-ID: <7e7f2c0c-448b-10a9-8929-4b8f4f6e2a32@huawei.com> Date: Thu, 14 Dec 2023 20:13:57 +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 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-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Thu, 14 Dec 2023 04:14:43 -0800 (PST) Hi list, We have observed on GICv4.1 systems that, after a guest reset, the secondary VCPU would receive an IPI_CPU_STOP accidently and failed to come online eventually. | Guest User-space | | reset (with a vSGI pending in the | hardware) [0] | | disable the distributor (write 0 | into GICD_CTLR) [1] | | clear pending status (write 0 into | GICR_ISPENDR0 for each RD) [2] | | disable the distributor (write 0 | into GICD_CTLR) [3] | | enable the distributor with ARE, | Group1 and nASSGIreq [4] The problem is that even if user-space tries to disable the distributor and clear pending bits for all SGIs, we don't actually propogate it into HW (we only record it via vgic_dist->{enabled, nassgireq} and vgic_irq->pending_latch) and the vSGI remains pending across the guest reset. And when we're at [4], all vSGI's vgic_irq->hw are *true* and vgic_v4_enable_vsgis() becomes a nop.. That's not good. The following solution can solve the problem. Not sure if this is a good solution.Sent out early for suggestions or solutions. diff --git a/arch/arm64/kvm/vgic/vgic-mmio-v3.c b/arch/arm64/kvm/vgic/vgic-mmio-v3.c index 89117ba2528a..3678ab33f5b9 100644 --- a/arch/arm64/kvm/vgic/vgic-mmio-v3.c +++ b/arch/arm64/kvm/vgic/vgic-mmio-v3.c @@ -374,6 +374,10 @@ static int vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu,              irq->pending_latch = true;              vgic_queue_irq_unlock(vcpu->kvm, irq, flags);          } else { +             if (irq->hw && vgic_irq_is_sgi(irq->intid)) +                 irq_set_irqchip_state(irq->host_irq, +                              IRQCHIP_STATE_PENDING, +                              false);              irq->pending_latch = false;              raw_spin_unlock_irqrestore(&irq->irq_lock, flags);          }