Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3135898pxf; Mon, 15 Mar 2021 02:16:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwe6oq+lLg1ay4gvonaK4SLm0UzNXs7D1VSQRzCxRjN110KOIt6lt918hdvkVLUrYnJ9HrK X-Received: by 2002:a50:ed96:: with SMTP id h22mr17631347edr.39.1615799783213; Mon, 15 Mar 2021 02:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615799783; cv=none; d=google.com; s=arc-20160816; b=xNu5jAM2Vc1/Y0p3DhHmLJkSXyEKeB/TU6NVpBsniSCFqJWQkevLh4GwSvNLgqCoJX iKxJSF2VDTHgFifx/OVAF0plD0/qid9g/qwI3Vg4NyC8Uy5f1iayONE/HoR+SRz3u1ZW 2lMshPbLLNIPicgUbq6xkHjAsRsZIAzcrOCwQP68j4J6HVr85Tx7s0H8FAuyaoLWp2+W HUEC8nOpNCoblib2C+SUb1GBBmtZjJ7i33qYumUd/e6aiPMBmH54hfmRLIdPvtv/MurH 46OlwZifIppIm3FtazTuuNSqKxm/iYzCs2iKeGjMVNn6yA807O8pO0VXowPOZVHzXwAk FH1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=VOigcW/qG7CO8xf3iFKqNUrNkcHfZTjXgkO5nkvs1Bo=; b=vBoSgcdiTwClALzg4w3y4fmP13pDffhT+sgEAZfnN9GjFrkOfiPa9aYGffUXE937aG Vn8oEWsIvXo8ViSdn5+YFx8qSYc00YDJpgjwiMcjHhEZ4qIBXEY6RoGLCEStXssll+jk RsQVVkjUFK+MU+EZOGgWOIcu6LrJbV0tu9ouhsACqakAryrR76u0WxaRh98ZXOpIEanT BmJh2rm7lHwueXxblvnl9rE+9OD2YJXVV+DNVN0E5zzc8NeTY/6IyGIdhvYKcQjfweqQ 27g0Sne81o02JwAsjNnIdmZ8qaljE+TxRSMFP9sSjsfBJcVNISBOc5NQB9ftlGtGsybI xS2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d10si10536634edp.256.2021.03.15.02.16.00; Mon, 15 Mar 2021 02:16:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229599AbhCOJMW (ORCPT + 99 others); Mon, 15 Mar 2021 05:12:22 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13169 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbhCOJL4 (ORCPT ); Mon, 15 Mar 2021 05:11:56 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DzVwq3CxHzmXXD; Mon, 15 Mar 2021 17:09:31 +0800 (CST) Received: from [10.174.184.135] (10.174.184.135) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.498.0; Mon, 15 Mar 2021 17:11:45 +0800 Subject: Re: [PATCH v4 5/6] KVM: arm64: GICv4.1: Restore VLPI pending state to physical side To: Marc Zyngier CC: Eric Auger , Will Deacon , , , , , Alex Williamson , Cornelia Huck , "Lorenzo Pieralisi" , , References: <20210313083900.234-1-lushenming@huawei.com> <20210313083900.234-6-lushenming@huawei.com> From: Shenming Lu Message-ID: <81fbadda-0489-ffc3-cb38-08e89871ec95@huawei.com> Date: Mon, 15 Mar 2021 17:11:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.184.135] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/3/15 16:30, Marc Zyngier wrote: > On 2021-03-13 08:38, Shenming Lu wrote: >> From: Zenghui Yu >> >> When setting the forwarding path of a VLPI (switch to the HW mode), >> we can also transfer the pending state from irq->pending_latch to >> VPT (especially in migration, the pending states of VLPIs are restored >> into kvm’s vgic first). And we currently send "INT+VSYNC" to trigger >> a VLPI to pending. >> >> Signed-off-by: Zenghui Yu >> Signed-off-by: Shenming Lu >> --- >>  arch/arm64/kvm/vgic/vgic-v4.c | 18 ++++++++++++++++++ >>  1 file changed, 18 insertions(+) >> >> diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c >> index ac029ba3d337..3b82ab80c2f3 100644 >> --- a/arch/arm64/kvm/vgic/vgic-v4.c >> +++ b/arch/arm64/kvm/vgic/vgic-v4.c >> @@ -449,6 +449,24 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq, >>      irq->host_irq    = virq; >>      atomic_inc(&map.vpe->vlpi_count); >> >> +    /* Transfer pending state */ >> +    if (irq->pending_latch) { >> +        unsigned long flags; >> + >> +        ret = irq_set_irqchip_state(irq->host_irq, >> +                        IRQCHIP_STATE_PENDING, >> +                        irq->pending_latch); >> +        WARN_RATELIMIT(ret, "IRQ %d", irq->host_irq); >> + >> +        /* >> +         * Clear pending_latch and communicate this state >> +         * change via vgic_queue_irq_unlock. >> +         */ >> +        raw_spin_lock_irqsave(&irq->irq_lock, flags); >> +        irq->pending_latch = false; >> +        vgic_queue_irq_unlock(kvm, irq, flags); >> +    } >> + >>  out: >>      mutex_unlock(&its->its_lock); >>      return ret; > > The read side of the pending state isn't locked, but the write side is. > I'd rather you lock the whole sequence for peace of mind. Did you mean to lock before emitting the mapping request, Or just before reading the pending state? Thanks, Shenming > > Thanks, > >         M.