Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3924343pxb; Mon, 8 Feb 2021 03:44:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaLdKNBHMFh1ucrUs0Wu6RVJ8ri9SaXAaG+4NmSAECdTuIUcaAOorjuyhy0pVhqs7+knTE X-Received: by 2002:a17:906:7687:: with SMTP id o7mr16554179ejm.209.1612784646524; Mon, 08 Feb 2021 03:44:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612784646; cv=none; d=google.com; s=arc-20160816; b=EB+yYx3l5EEubXo1e6uKIXvQ9FT5iX4TILLRt4YWdqepalXDbBy32XS0DJVqxBxx9Z xRKJ41h0kKirlIM5liaCs5dqC1ynI7K0ECVYXOWeaKd/czlCQdzclv7eAELAqxLP0U4A +MK3s+13d94CGcmx0tVlNH07sAZygPEYkww2SMN836RQF8HIjjDWiHNbbheKrRFhySIF amRJYmU5knqcGPralFYJFejQf2Fl8wC6YchL/5Y7eAk2N3iIA/ZwzjZ1XaFezgFtyWO4 m2tvgPMVzL4r5Eml1demDnFKxCUp265zw1Fik9w/ZpN5UhJELfnf/difU67As5XyQMw+ tXOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=GJKmZFXZ04+JRE6r1JWwwNC5goTXVNJKX2B2Plw1PM8=; b=yGPCwMG1pF7/uhAMMpc7rJeExz48OxOfcCHyyO2M2ZLqx3nIJjKh4thWZp5EjN/H+W VcMqwnkqjiQkdreZQpKzu2b0OThZU9mvB5kpH7YnjbudlFc9rbJA8nC8vjjTD9GXXQmp MqmErK80u1fueaw7Koim5dvnKp2ebb+oWZJJpfbZSOnz90LIXTGBvPKJG63nUccnETdO OCxhDI4KTVRYibrT+ST4t/SUGUioLdPn/ffvVbzhZf+bA4fdkXeNBH1awUrFLEqREHha z5P/aDud+8iCBMolOCo6rsMB3ASBBxo7Q0Ik2xkgVqLNEZJSkXIudbwkikgR2P9zZXQ4 PRUQ== 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 d24si5325861edv.303.2021.02.08.03.43.42; Mon, 08 Feb 2021 03:44: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; 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 S233363AbhBHLmY (ORCPT + 99 others); Mon, 8 Feb 2021 06:42:24 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:12463 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233006AbhBHLXn (ORCPT ); Mon, 8 Feb 2021 06:23:43 -0500 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DZ3Wj6PCFzjJyB; Mon, 8 Feb 2021 19:21:53 +0800 (CST) Received: from DESKTOP-TMVL5KK.china.huawei.com (10.174.187.128) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.498.0; Mon, 8 Feb 2021 19:22:54 +0800 From: Yanan Wang To: Marc Zyngier , Will Deacon , "Catalin Marinas" , James Morse , "Julien Thierry" , Suzuki K Poulose , Gavin Shan , Quentin Perret , , , , CC: , , , Yanan Wang Subject: [RFC PATCH 2/4] KVM: arm64: Add an independent API for coalescing tables Date: Mon, 8 Feb 2021 19:22:48 +0800 Message-ID: <20210208112250.163568-3-wangyanan55@huawei.com> X-Mailer: git-send-email 2.8.4.windows.1 In-Reply-To: <20210208112250.163568-1-wangyanan55@huawei.com> References: <20210208112250.163568-1-wangyanan55@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.187.128] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Process of coalescing page mappings back to a block mapping is different from normal map path, such as TLB invalidation and CMOs, so here add an independent API for this case. Signed-off-by: Yanan Wang --- arch/arm64/kvm/hyp/pgtable.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 2f4f87021980..78a560446f80 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -525,6 +525,24 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, return 0; } +static void stage2_coalesce_tables_into_block(u64 addr, u32 level, + kvm_pte_t *ptep, + struct stage2_map_data *data) +{ + u64 granule = kvm_granule_size(level), phys = data->phys; + kvm_pte_t new = kvm_init_valid_leaf_pte(phys, data->attr, level); + + 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); + smp_store_release(ptep, new); + data->phys += granule; +} + static int stage2_map_walk_table_pre(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, struct stage2_map_data *data) -- 2.23.0