From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CD13C64E7A for ; Tue, 1 Dec 2020 18:18:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BDB7F2151B for ; Tue, 1 Dec 2020 18:18:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JwnBEtCH"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="tcRbpV7E" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BDB7F2151B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=EzrQwK/oztTcYYQ+fWsqJcZSagkEOoEjdU+yMXD2CU4=; b=JwnBEtCHq9BYC6G/8KfsspHoZ h18NR5Swaib7bH8sEAZ72jibppdWymMETo0IrUpq09Kk/ZLEYmeM+9QWRtX1s5bpWk4OcBn7BxRYa q8OpSjE6OVUFoRxXrL5RZQfHTCuNrRymlQ7RrRDObiZBrax5DheYL73NJHwmvux4G7dpAsNokJEJv LcXeE0qLzN2bDlPa/m0wnOR27qqB1RHT2rhaChlTo+JvrTj2eamusAu43jQlLLAeinQ7g4bSOVIPt xTqTnE9NqE9fGuk8Dib1dokiZdKaH88m90m9KZNi6Ibu+sgTozb/Xx2FZZaxqiHkdSfcM19hQDA5W k/bRjQ22A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkADj-0005b5-FU; Tue, 01 Dec 2020 18:17:47 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kkADg-0005aH-QX for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2020 18:17:45 +0000 Received: from willie-the-truck (236.31.169.217.in-addr.arpa [217.169.31.236]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86AF3208C3; Tue, 1 Dec 2020 18:17:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606846663; bh=hHKuNVL42sIlvGmqt+cA/j2QKdUL76ey2Wv7jpqX8wc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tcRbpV7EgzjokMuDfmo0fo46s40HA/TzLOflvurXaoKXmXDkr50duLbzebNzFrXHm eOQthyFWKi4MG6HK2owfAMiK8NhFdCgOhCmMk9Oztuh0suR1bXFXi8D2f2wGNAn29b 77aSlTHNCvrx7MzD3A2iaS5YhqwKZy4xy19oe0co= Date: Tue, 1 Dec 2020 18:17:37 +0000 From: Will Deacon To: "wangyanan (Y)" Subject: Re: [RFC PATCH 2/3] KVM: arm64: Fix handling of merging tables into a block entry Message-ID: <20201201181736.GB27955@willie-the-truck> References: <20201130121847.91808-1-wangyanan55@huawei.com> <20201130121847.91808-3-wangyanan55@huawei.com> <20201130133421.GB24837@willie-the-truck> <67e9e393-1836-eca7-4235-6f4a19fed652@huawei.com> <20201130160119.GA25051@willie-the-truck> <868a4403-10d3-80f3-4ae1-a490813c55e2@huawei.com> <20201201134606.GB26973@willie-the-truck> <2e92a511-496c-d446-95f4-6211ec8b4bb6@huawei.com> <0a36f859-2666-e5e7-856d-47fa306a6f53@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <0a36f859-2666-e5e7-856d-47fa306a6f53@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201201_131745_024228_E9F75947 X-CRM114-Status: GOOD ( 33.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiangkunkun@huawei.com, Gavin Shan , Suzuki K Poulose , Marc Zyngier , wangjingyi11@huawei.com, Quentin Perret , lushenming@huawei.com, linux-kernel@vger.kernel.org, yezengruan@huawei.com, James Morse , linux-arm-kernel@lists.infradead.org, Catalin Marinas , yuzenghui@huawei.com, wanghaibin.wang@huawei.com, zhukeqian1@huawei.com, Julien Thierry Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Dec 02, 2020 at 01:20:33AM +0800, wangyanan (Y) wrote: > On 2020/12/1 22:35, Marc Zyngier wrote: > = > > Hi Yanan, > > = > > On 2020-12-01 14:11, wangyanan (Y) wrote: > > > On 2020/12/1 21:46, Will Deacon wrote: > > > > On Tue, Dec 01, 2020 at 10:30:41AM +0800, wangyanan (Y) wrote: > > = > > [...] > > = > > > > > The point is at b.iii where the TLBI is not enough. There > > > > > are many page > > > > > mappings that we need to merge into a block mapping. > > > > > = > > > > > We invalidate the TLB for the input address without level > > > > > hint at b.iii, but > > > > > this operation just flush TLB for one page mapping, there > > > > > = > > > > > are still some TLB entries for the other page mappings in > > > > > the cache, the MMU > > > > > hardware walker can still hit these entries next time. > > > > Ah, yes, I see. Thanks. I hadn't considered the case where there > > > > are table > > > > entries beneath the anchor. So how about the diff below? > > > > = > > > > Will > > > > = > > > > --->8 > > > = > > > Hi, I think it's inappropriate to put the TLBI of all the leaf entries > > > in function stage2_map_walk_table_post(), > > > = > > > because the *ptep must be an upper table entry when we enter > > > stage2_map_walk_table_post(). > > > = > > > We should make the TLBI for every leaf entry not table entry in the > > > last lookup level,=A0 just as I am proposing > > > = > > > to add the additional TLBI in function stage2_map_walk_leaf(). > > = > > Could you make your concerns explicit? As far as I can tell, this should > > address the bug you found, at least from a correctness perspective. > > = > > Are you worried about the impact of the full S2 invalidation? Or do you > > see another correctness issue? > = > = > Hi Will, Marc, > = > = > After recheck of the diff, the full S2 invalidation in > stage2_map_walk_table_post() should be well enough to solve this problem. > = > But I was wondering if we can add the full S2 invalidation in > stage2_map_walk_table_pre(), where __kvm_tlb_flush_vmid() will be called = for > only one time. > = > If we add the full TLBI in stage2_map_walk_table_post(), > __kvm_tlb_flush_vmid() might be called for many times in the loop and lots > of (unnecessary) CPU instructions will be wasted. > = > What I'm saying is something like below, please let me know what do you > think. > = > If this is OK, I can update the diff in v2 and send it with your SOB (is = it > appropriate?) after some tests. > = > = > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > index b232bdd142a6..f11fb2996080 100644 > --- a/arch/arm64/kvm/hyp/pgtable.c > +++ b/arch/arm64/kvm/hyp/pgtable.c > @@ -496,7 +496,7 @@ static int stage2_map_walk_table_pre(u64 addr, u64 en= d, > u32 level, > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 return 0; > = > =A0=A0=A0=A0=A0=A0=A0 kvm_set_invalid_pte(ptep); > -=A0=A0=A0=A0=A0=A0 kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, data->mmu, add= r, 0); > +=A0=A0=A0=A0=A0=A0 kvm_call_hyp(__kvm_tlb_flush_vmid, data->mmu); > =A0=A0=A0=A0=A0=A0=A0 data->anchor =3D ptep; > =A0=A0=A0=A0=A0=A0=A0 return 0; Yes, I think that's much better, but please add a comment! (you can probably more-or-less copy the one I had in the post handler) Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel