Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp194956rwi; Sun, 9 Oct 2022 21:34:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ixGxyjPTKKoLR0iFFFSp8oKnVSnRNNqurnOSuB39YS51qK+6WFcBhaIKsnTyacAKjyaeQ X-Received: by 2002:a17:906:7055:b0:78b:9148:6b41 with SMTP id r21-20020a170906705500b0078b91486b41mr13097704ejj.629.1665376466937; Sun, 09 Oct 2022 21:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665376466; cv=none; d=google.com; s=arc-20160816; b=mqEP3D3teLGqjBS4uncub6GNfdE0471PPR6Ff5MMt5Q/YPNBt16FHghdFkc2VplM6/ xNkSx9VezzLqoQEIOzSPFQ5y7O1J9quEoinG10tlpwu3E7GuhytzPyONG5c1jH6dTNmp jPRSiQ5hbJ5ydq63arpdXaonlM1CrtFSZ5DcmYT0NPug6g3rC8QQI2cTjfYhEMNq9m1p O5Svp3K6kHXRGhOG6rrZQxgpSPg3smb9M73UkoDFf3D7U+8JQszGkBiAFiJbnBd+BZMo BgRW7HyaNaen+/18WG08G6iHaDwG6/qD5THSWn0wShtFRGX2vvwigCWHKvXLEGzW5/gs fAeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=wy3CjO6m956FMVfpB0zMg7+XC0RTalCctjYSru1fYVw=; b=H6w2SwpLYqanH8+tMHSVlAfaz6YDnKvlMDDRsy3E1pox4QDaZQXA3UYwGo3fzunP7M PPcHqwG4O4Z1LBX/VS28HLh8//U5Vrf2gzpwDGdfriMjxPWFKrTHABijzO4ibpLkMNjd duL2mQEHrR7OvJc+dJ+NPGg+KZyjpu/t/rCk/zkeNWxBwbvGcOrz68we2k6JJR0w5X/l /fWUO1/8SeuOvtFNfXGJpvVw9yilEFj1oNPtddeUxUbtSrAIkGwnb2dHHeW8zJb2o2qh IppfDagKbXwNyKalFzTm0caN/SRfr2/jTxcRDii1eoYUv1SSNBRmIFGYHcYQfFhSBdWx 5anA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=oWVAWjcV; 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 e11-20020aa7d7cb000000b0045935adb5b1si8440742eds.395.2022.10.09.21.34.01; Sun, 09 Oct 2022 21:34:26 -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=oWVAWjcV; 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 S230410AbiJJD6h (ORCPT + 99 others); Sun, 9 Oct 2022 23:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230092AbiJJD6f (ORCPT ); Sun, 9 Oct 2022 23:58:35 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53AED4A105; Sun, 9 Oct 2022 20:58:33 -0700 (PDT) Date: Mon, 10 Oct 2022 03:58:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1665374311; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wy3CjO6m956FMVfpB0zMg7+XC0RTalCctjYSru1fYVw=; b=oWVAWjcVpjNvfw3SFVK1hv9hT41eVbN7mHBpbGOxDtRXsg5GY1AFAAAkuJRwIAznZbxpU5 nc9ffUv45N30VWIHBvEDUPuQNvrtLIBLaFrl/OQ2zk9saqP75Oaalht3sM03S3i4iFLXvV LU80PITJOklUELxX1kHc62yxI2dgUWA= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Oliver Upton To: Ricardo Koller Cc: Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Quentin Perret , Reiji Watanabe , David Matlack , Ben Gardon , Paolo Bonzini , Gavin Shan , Peter Xu , Sean Christopherson , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/14] KVM: arm64: Tear down unlinked stage-2 subtree after break-before-make Message-ID: References: <20220830194132.962932-1-oliver.upton@linux.dev> <20220830194132.962932-3-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT 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 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 Hey Ricardo, On Tue, Sep 13, 2022 at 05:20:11PM -0700, Ricardo Koller wrote: [...] > > diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c > > index d8127c25424c..5c0c8028d71c 100644 > > --- a/arch/arm64/kvm/hyp/pgtable.c > > +++ b/arch/arm64/kvm/hyp/pgtable.c > > @@ -763,17 +763,21 @@ static int stage2_map_walker_try_leaf(u64 addr, u64 end, u32 level, > > return 0; > > } > > > > +static int stage2_map_walk_leaf(u64 addr, u64 end, u32 level, kvm_pte_t *ptep, > > + struct stage2_map_data *data); > > + > > static int stage2_map_walk_table_pre(u64 addr, u64 end, u32 level, > > kvm_pte_t *ptep, > > struct stage2_map_data *data) > > { > > - if (data->anchor) > > - return 0; > > + struct kvm_pgtable_mm_ops *mm_ops = data->mm_ops; > > + kvm_pte_t *childp = kvm_pte_follow(*ptep, mm_ops); > > + struct kvm_pgtable *pgt = data->mmu->pgt; > > + int ret; > > > > if (!stage2_leaf_mapping_allowed(addr, end, level, data)) > > return 0; > > > > - data->childp = kvm_pte_follow(*ptep, data->mm_ops); > > kvm_clear_pte(ptep); > > > > /* > > @@ -782,8 +786,13 @@ static int stage2_map_walk_table_pre(u64 addr, u64 end, u32 level, > > * individually. > > */ > > kvm_call_hyp(__kvm_tlb_flush_vmid, data->mmu); > > - data->anchor = ptep; > > - return 0; > > + > > + ret = stage2_map_walk_leaf(addr, end, level, ptep, data); > > I think this always ends up calling stage2_map_walker_try_leaf() (at > least it should). In that case, I think it might be clearer to do so, as > the intention is to just install a block. Yikes, I missed this in v2. I do agree with your point, it reads a bit odd to call something that could reinstall a table. Picked up the fix for v3. Thanks! -- Best, Oliver