Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4612533rwe; Tue, 30 Aug 2022 13:29:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7/DDAqaRzA8Wec2i6PkS8vwagoozOCJKlVEZZSXK4tlYumMPyl9/uwIwC4t74yLBA7SKP+ X-Received: by 2002:a62:1b84:0:b0:536:e127:cc56 with SMTP id b126-20020a621b84000000b00536e127cc56mr23003276pfb.65.1661891394755; Tue, 30 Aug 2022 13:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661891394; cv=none; d=google.com; s=arc-20160816; b=02FS5r9rGmhG0Nk/p7+TQ87UCRA17z+Rp2zIQlucs+9djGf/JlEggE1xP+iGQ0zx8l a2q3lCb7I5xMwv+Phh97kTShRqBF1nEv3+MbpELlXn3Cgff7f5mE6X2wGz+eP8XESquj 2AVUobz5uyWiJe5+2lxfizPuQCz9XOtMXA2OjPHIfnv9QWLamYQo/kkglyInHTBCAscN dm8bb/k+692yHHJU9The5/7hFMQd4qWg12qGHJSkx9l9LjaH1BOS3DerBGRPm/F4ZH6w PZCVEJqglQdxON0DNd2V5k2T3gI4SStQU1LM2TlZ+7IimHnyxI79LfW4FbHlm4QB+3E9 5y6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yispcYoWHwz6WUZiyFc9UJ/2hA2X4vwfQ9rtB9AplkE=; b=DSMhEjo/GgWECO9Se6zVLHNxupNcBYnNM+Mt2Sl+hdjK/tkTtRcQZQ/IsZcXSS8+e4 3gRLuypwjObQD/aPFl4ySrPLmHESFJg0AxDJqKPhq28fXTgqpTTW67cMesrMv0+Y03gw 9zP2W1dVvN5mkcKL/UR30t8WII9nnMLqob6QAL6omT43PnjRfZTcINWmcmvNPNQs3M+x gsT2Z2osSHRkt2Ie3qm/t0t9JV4XYiDVqRg/STvM9eV8ZGnXJ/fDWn7E4gDyys/tOXFp h0Ewo6BQ/4CJU54nfn3O8Nn0BUOQNSgwjho8CO443cQs9Ze9Ev4diuFyXS/cSf3hwbd2 4AuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QKKwh0mZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a63210c000000b0041b2f37c570si2855479pgh.752.2022.08.30.13.29.21; Tue, 30 Aug 2022 13:29:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=QKKwh0mZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbiH3Tmk (ORCPT + 99 others); Tue, 30 Aug 2022 15:42:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbiH3TmW (ORCPT ); Tue, 30 Aug 2022 15:42:22 -0400 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6685C7C30F; Tue, 30 Aug 2022 12:42:16 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1661888534; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yispcYoWHwz6WUZiyFc9UJ/2hA2X4vwfQ9rtB9AplkE=; b=QKKwh0mZHI3VDDYssNZqIJUh8qzZEqcGK2T3WlXJOjZzzlmkUOBcLFJw1Cstm2IhK1GFIz 0JosO5MJyt2ok6BmAv66t0Zcb9QGbJ1ROXv1n/pZjIFhAB7qdZSTbe5HfblFcESL/uykDN qbUixnxPOgyPrKiBk/pc54SO8HjqpOI= From: Oliver Upton To: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Quentin Perret , Ricardo Koller , Reiji Watanabe , David Matlack , Ben Gardon , Paolo Bonzini , Gavin Shan , Peter Xu , Sean Christopherson , Oliver Upton Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/14] KVM: arm64: Return next table from map callbacks Date: Tue, 30 Aug 2022 19:41:24 +0000 Message-Id: <20220830194132.962932-7-oliver.upton@linux.dev> In-Reply-To: <20220830194132.962932-1-oliver.upton@linux.dev> References: <20220830194132.962932-1-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The map walkers install new page tables during their traversal. Return the newly-installed table PTE from the map callbacks to point the walker at the new table w/o rereading the ptep. Signed-off-by: Oliver Upton --- arch/arm64/kvm/hyp/pgtable.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 331f6e3b2c20..f911509e6512 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -202,13 +202,12 @@ static inline int __kvm_pgtable_visit(struct kvm_pgtable_walk_data *data, if (!table && (flags & KVM_PGTABLE_WALK_LEAF)) { ret = kvm_pgtable_visitor_cb(data, addr, level, ptep, &pte, KVM_PGTABLE_WALK_LEAF); - pte = *ptep; - table = kvm_pte_table(pte, level); } if (ret) goto out; + table = kvm_pte_table(pte, level); if (!table) { data->addr = ALIGN_DOWN(data->addr, kvm_granule_size(level)); data->addr += kvm_granule_size(level); @@ -427,6 +426,7 @@ static int hyp_map_walker(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, kvm_pte new = kvm_init_table_pte(childp, mm_ops); mm_ops->get_page(ptep); smp_store_release(ptep, new); + *old = new; return 0; } @@ -768,7 +768,7 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, } static int stage2_map_walk_leaf(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, - struct stage2_map_data *data); + kvm_pte_t *old, struct stage2_map_data *data); static int stage2_map_walk_table_pre(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, kvm_pte_t *old, @@ -791,7 +791,7 @@ static int stage2_map_walk_table_pre(u64 addr, u64 end, u32 level, */ kvm_call_hyp(__kvm_tlb_flush_vmid, data->mmu); - ret = stage2_map_walk_leaf(addr, end, level, ptep, data); + ret = stage2_map_walk_leaf(addr, end, level, ptep, old, data); mm_ops->put_page(ptep); mm_ops->free_removed_table(childp, level + 1, pgt); @@ -832,6 +832,7 @@ static int stage2_map_walk_leaf(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, new = kvm_init_table_pte(childp, mm_ops); mm_ops->get_page(ptep); smp_store_release(ptep, new); + *old = new; return 0; } -- 2.37.2.672.g94769d06f0-goog