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 962DDC64E7B for ; Tue, 1 Dec 2020 14:24:46 +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 0D0B720757 for ; Tue, 1 Dec 2020 14:24:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HC9rfXVL"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="XPrqK70x" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D0B720757 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=Z40h1TENB2nNLCrcMbtFEhaSBq5AyBrQ9f/H6gUOslc=; b=HC9rfXVLvThaCBM/BuHdnO+DF JbBxL807LkUQvyYcOgcp0FkbroP2TCa4ecfTCVI6WXVCxi2QXPIkEl7OoRvxe8Ljyjn4DttS/HYD/ doaBMTyt98dPK33luk+kDzUHGOtCtnICAWU9Wij+4jPXfGrPD8CdhLisgROsd1/azRYTzkBTGi5RP NROek41lkMxWOzd4+vbqUzj5aUGlT06FCKAu/AN+jVUhmKPA6uadb3OQX/JdSZjj8dsp/9DadiCIc +R1vGG7ykKoRfg24znC1HA8AKeww7PdyzQERt4kEfk7gY4dB/l7tdnqaPHqy5QUk2uwtVCaXSEUF/ Mm5r3jZmA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kk6Z4-0000L6-T0; Tue, 01 Dec 2020 14:23:34 +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 1kk6Z2-0000KI-PV for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2020 14:23:33 +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 6ADAC20757; Tue, 1 Dec 2020 14:23:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606832611; bh=C+v67/0KcQr9kW1xIWsErc3mmwvhcoTEt92CQWvx2fI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XPrqK70xrZXr4bydVCcxhOZvnaGb8rhQHlJpV9GdEVv9RtZFMI0lvO+wTFTWu4yi3 hEZqFE5SR/hEY1zqXfTOy1O3nIXbEHWmfal89ypLAm0t6O1Fjsn/ZgTvQN7Ms7hVKh 8D/0rwJlqoCpv3aYm4oxaXGqIG7Jsu68J0B0H44c= Date: Tue, 1 Dec 2020 14:23:25 +0000 From: Will Deacon To: Marc Zyngier Subject: Re: [RFC PATCH 2/3] KVM: arm64: Fix handling of merging tables into a block entry Message-ID: <20201201142324.GD26973@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> <03ab1bdd8459831ad05993807e39e5bd@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <03ab1bdd8459831ad05993807e39e5bd@kernel.org> 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_092332_914869_C6BD093C X-CRM114-Status: GOOD ( 16.51 ) 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 , Catalin Marinas , wangjingyi11@huawei.com, Quentin Perret , lushenming@huawei.com, linux-kernel@vger.kernel.org, "wangyanan \(Y\)" , yezengruan@huawei.com, James Morse , linux-arm-kernel@lists.infradead.org, yuzenghui@huawei.com, wanghaibin.wang@huawei.com, zhukeqian1@huawei.com, Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 01, 2020 at 02:05:03PM +0000, Marc Zyngier wrote: > On 2020-12-01 13:46, Will Deacon wrote: > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index 0271b4a3b9fe..12526d8c7ae4 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -493,7 +493,7 @@ static int stage2_map_walk_table_pre(u64 addr, u64 > > end, u32 level, > > return 0; > > > > kvm_set_invalid_pte(ptep); > > - kvm_call_hyp(__kvm_tlb_flush_vmid_ipa, data->mmu, addr, 0); > > + /* TLB invalidation is deferred until the _post handler */ > > data->anchor = ptep; > > return 0; > > } > > @@ -547,11 +547,21 @@ static int stage2_map_walk_table_post(u64 addr, > > u64 end, u32 level, > > struct stage2_map_data *data) > > { > > int ret = 0; > > + kvm_pte_t pte = *ptep; > > > > if (!data->anchor) > > return 0; > > > > - free_page((unsigned long)kvm_pte_follow(*ptep)); > > + kvm_set_invalid_pte(ptep); > > + > > + /* > > + * Invalidate the whole stage-2, as we may have numerous leaf > > + * entries below us which would otherwise need invalidating > > + * individually. > > + */ > > + kvm_call_hyp(__kvm_tlb_flush_vmid, data->mmu); > > That's a big hammer, and we so far have been pretty careful not to > over-invalidate. Is the block-replacing-table *without* an unmap > in between the only case where this triggers? Yes, this only happens in that case. The alternative would be to issue invalidations for every single entry we unmap, which I can implement if you prefer, but it felt worse to me given that by-IPA invalidation isn't really great either). Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel