Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp11715769pxu; Thu, 31 Dec 2020 19:11:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJxvaiagvTbekK3CkZlQ3FcKWJoBYmTla83Zo/VWBTykC5YxMlY8xddg4UlcxWtn6Wd8liH2 X-Received: by 2002:a17:906:5285:: with SMTP id c5mr44103274ejm.17.1609470703097; Thu, 31 Dec 2020 19:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609470703; cv=none; d=google.com; s=arc-20160816; b=K8h0ziZMQpVOjVqnNwZSWR7mS8irKiQjAuOAxRwGXc+5O2gYiNtduS8M1oetYI8vzi Z55zb/XiaWeHQ/32H20JLmg5GuKtntlEfvzDG/NWr07HGbYsH8Tz7D9095D+mG3aSHU6 8FYu09tWX9rBUYuY4okYBDLEluNbZpftLbpmoylx6Xl1aQtBMkaAcnAWc682i8hjwAN8 p7zuV+2x1QiyCb5Hn2n4+t7a1dDzfVapXjh2saURRLDTdoGkXebWgWdQeSh+p3aGvdzQ YOTQ13Z8sJO76I5/ekq3jV2gbbSWdeSgGRQyc0/7dN7Jc3Hp7nFWvCJQnSsC1Wdn8E3i 8uVw== 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=qG8x+8efEjJCbyJZcG1/wQP1psuujK8jqrrsyuAMJXo=; b=cW5Ou8yBhxx9ngByFER5feoFpalVozdjjIu4FyiwRkYN1GvdSRnzj/9+xHVymdh+Hs q3jvcPr4SwZkAfE+P+ei7bohG2gzLRdGl0nHh62ul6u8lGui2OXOFrpbSYVPiVwibOQ0 J9yzd8DBpcQWlpDGMB1laooZAb7l3ePG+/Piz/uY45YJRN7CMWxbKhryAhhkmUMa04Po 8gGyCV/U7NkH87OUQoW7yp0FWCH1HlU8+MGx6GjOIIs77oBLIkWKtZBJ9fbNEmM3RfL4 Nm+uTU6rTADgWKl35vl3DU3HIrZy7VwRor18AmsAYfyftKJhybSialDa4zMZN/YaF6pw z9oA== 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 a18si26012095edx.342.2020.12.31.19.11.03; Thu, 31 Dec 2020 19:11:43 -0800 (PST) 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 S1726651AbhAADJr (ORCPT + 99 others); Thu, 31 Dec 2020 22:09:47 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9664 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726314AbhAADJr (ORCPT ); Thu, 31 Dec 2020 22:09:47 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4D6VMc07wHz15h91; Fri, 1 Jan 2021 11:08:12 +0800 (CST) Received: from [10.174.184.196] (10.174.184.196) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Fri, 1 Jan 2021 11:08:55 +0800 Subject: Re: [PATCH RFC] KVM: arm64: vgic: Decouple the check of the EnableLPIs bit from the ITS LPI translation To: Marc Zyngier CC: Will Deacon , Eric Auger , , , , , References: <20201231062813.714-1-lushenming@huawei.com> <683134bdea8a22d3bb784117dcfe17a1@kernel.org> <85dd45f580eaa7a0b8ec91ac0b7ca066@kernel.org> From: Shenming Lu Message-ID: <032ab609-0602-a3d6-5877-489e583ba0a8@huawei.com> Date: Fri, 1 Jan 2021 11:08:55 +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: <85dd45f580eaa7a0b8ec91ac0b7ca066@kernel.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.184.196] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/12/31 20:22, Marc Zyngier wrote: > On 2020-12-31 11:58, Shenming Lu wrote: >> On 2020/12/31 16:57, Marc Zyngier wrote: >>> Hi Shemming, >>> >>> On 2020-12-31 06:28, Shenming Lu wrote: >>>> When the EnableLPIs bit is set to 0, any ITS LPI requests in the >>>> Redistributor would be ignored. And this check is independent from >>>> the ITS LPI translation. So it might be better to move the check >>>> of the EnableLPIs bit out of the LPI resolving, and also add it >>>> to the path that uses the translation cache. >>> >>> But by doing that, you are moving the overhead of checking for >>> EnableLPIs from the slow path (translation walk) to the fast >>> path (cache hit), which seems counter-productive. >> >> Oh, I didn't notice the overhead of the checking, I thought it would >> be negligible... > > It probably doesn't show on a modern box, but some of the slower > systems might see it. Overall, this is a design decision to keep > the translation cache as simple and straightforward as possible: > if anything affects the output of the cache, we invalidate it, > and that's it. Ok, get it. > >> >>> >>>> Besides it seems that >>>> by this the invalidating of the translation cache caused by the LPI >>>> disabling is unnecessary. >>>> >>>> Not sure if I have missed something... Thanks. >>> >>> I am certainly missing the purpose of this patch. >>> >>> The effect of EnableLPIs being zero is to drop the result of any >>> translation (a new pending bit) on the floor. Given that, it is >>> immaterial whether this causes a new translation or hits in the >>> cache, as the result is still to not pend a new interrupt. >>> >>> I get the feeling that you are trying to optimise for the unusual >>> case where EnableLPIs is 0 *and* you have a screaming device >>> injecting tons of interrupt. If that is the case, I don't think >>> this is worth it. >> >> In fact, I just found (imagining) that if the EnableLPIs bit is 0, >> the kvm_vgic_v4_set_forwarding() would fail when performing the LPI >> translation, but indeed we don't try to pend any interrupts there... >> >> By the way, it seems that the LPI disabling would not affect the >> injection of VLPIs... > > Yes, good point. We could unmap the VPE from all ITS, which would result > in all translations to be discarded, but this has the really bad side > effect of *also* preventing the delivery of vSGIs, which isn't what > you'd expect. > > Overall, I don't think there is a good way to support this, and maybe > we should just prevent EnableLPIs to be turned off when using direct > injection. After all, the architecture does allow that for GICv3 > implementations, which is what we emulate. Agreed, if there is no good way, we could just make the EnableLPIs clearing unsupported... Thanks(Happy 2021), Shenming > > Thanks, > >         M.