Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp80053pxu; Tue, 1 Dec 2020 06:36:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwjai+6zbBHOpvIfAcHpWK+f4QqU/QFPbd0+t1hMDLleSxzMcLyzPkp22Ed9s930TnVBTOK X-Received: by 2002:aa7:c753:: with SMTP id c19mr3332681eds.358.1606833366775; Tue, 01 Dec 2020 06:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606833366; cv=none; d=google.com; s=arc-20160816; b=VYVNQHO7WdcrilqdHhJjzCRh6cml6e9Q+rh6MrV7fCVEL8ynQ2hoA/r6uM6wuSFbHL 3FPPFW2SrXg2XXGtv+6twIF1iIHw2HH2/UouE5zDxnZiTnh66f0LHa1cqqrxrAbhYKe1 n5kOvBoTGcs4C73EnsnAXO094Tmk2FdLXucJPmtSdS0hp4UoG/LeUmx++SGjhEXSI2qh Bf8A3+q33Fr0lBgfCY6SqpDxnW/igINstQ7YPic9l+GvLMLGymr98UrJjYyPz/jcwP6N CHSI7X0J6zKgwwX4Zq/WH0XU4/06xV/VqcEGwc31M4EUTVdCuSr+I1AxbwD6IVLvEpXF 61HA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:user-agent:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :dkim-signature; bh=4b19RuVmaGwI5If2kRSJ1DOI/cN1pAqp84WPHUaGusQ=; b=N/P7233wYrn4YMddWJKeB4kJIaC+2FbycxeXaubV6VoSC3vlN/Qn3cktM9f9MDkQuK Dz5rVHuRhJ/aBvXX/Yk+Uljyp125JMTSmE02GbDlDI6riROzxle0tB4y9L610EyWXwvR VYgjmeNhdO85Y//vZRmGlcw4tmiw2tp8tHq+a0W6GS1U2DWLqbaxaflDZT5lYRW1mTWs QrrdDN2pBvMhhTMrvhZrgS+46vBCgRv6saPVPHNiPZjtGXQ9nmG8fLVu0JEJyFOQWzbc +GRrJmwWY3LSQpzbrrU7KbXnfWct3tXEVQrfWVpatNSwV3eYoyADd/eGTkHW8P4IapEj KwsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vwda/V4I"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y14si1228407eds.52.2020.12.01.06.35.43; Tue, 01 Dec 2020 06:36:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b="vwda/V4I"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729428AbgLAOd3 (ORCPT + 99 others); Tue, 1 Dec 2020 09:33:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:53584 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727132AbgLAOd2 (ORCPT ); Tue, 1 Dec 2020 09:33:28 -0500 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (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 583F320757; Tue, 1 Dec 2020 14:32:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606833168; bh=LkPHLNioQEa32GFSH3IOprZq0laRIqzUxVI5cxem5H4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vwda/V4IDBtyI8uvixvxdqWAT9PRpD9XNxTpsr2Ih1RUZKSylaW79Yh4L50zCxMaw ejRcbT8+nQj9bT0q2ReyoYYKE868rjGaw83K8DJLihUcYgnWaATUDo4zmG70B3Nlef L99lhbXRIWM9r+wLVGpsUqaJuPRihcGtLLj/ij+E= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1kk6hy-00F4Pm-6C; Tue, 01 Dec 2020 14:32:46 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 01 Dec 2020 14:32:46 +0000 From: Marc Zyngier To: Will Deacon Cc: "wangyanan (Y)" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Catalin Marinas , James Morse , Julien Thierry , Suzuki K Poulose , Gavin Shan , Quentin Perret , wanghaibin.wang@huawei.com, yezengruan@huawei.com, zhukeqian1@huawei.com, yuzenghui@huawei.com, jiangkunkun@huawei.com, wangjingyi11@huawei.com, lushenming@huawei.com Subject: Re: [RFC PATCH 2/3] KVM: arm64: Fix handling of merging tables into a block entry In-Reply-To: <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> <20201201142324.GD26973@willie-the-truck> User-Agent: Roundcube Webmail/1.4.9 Message-ID: X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: will@kernel.org, wangyanan55@huawei.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, gshan@redhat.com, qperret@google.com, wanghaibin.wang@huawei.com, yezengruan@huawei.com, zhukeqian1@huawei.com, yuzenghui@huawei.com, jiangkunkun@huawei.com, wangjingyi11@huawei.com, lushenming@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-12-01 14:23, Will Deacon wrote: > 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). Right. If that's the only case where this happens, I'm not too bothered. What I want to make sure is that the normal table->block upgrade path (which goes via a MMU notifier that unmaps the table) stays relatively quick and doesn't suffer from the above. It looks like Yanan still has some concerns though, and I'd like to understand what they are. Thanks, M. -- Jazz is not dead. It just smells funny...