Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1059940iof; Mon, 6 Jun 2022 19:30:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDthKs2zodgH3TB86GYsrmwvkyS1Kcc5pdzFNu8alTR1DI1NIcB99J+IZRnA2ECR6KUONz X-Received: by 2002:a05:6402:1f8c:b0:42d:c3a9:5beb with SMTP id c12-20020a0564021f8c00b0042dc3a95bebmr30546732edc.160.1654569016138; Mon, 06 Jun 2022 19:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654569016; cv=none; d=google.com; s=arc-20160816; b=fLw8sPfLVhSH7cWU3bGn+CQ5RR+3+lLeNcMhuhs659oOgN7KYi1OHXlr0rTHEO6hzx UGL1Cy+bOw4v+HGCzCrjuI0h8bK4txee5orYg7DbJQ934NAMDAfYY2qPqFvFfzntxyf2 S9utd9hkhYsHrn1POe+uO3Fue16EJn/lQfiA7KzqDTumff61FCUBzy84PrN1lmzfnwSi ZDnQicPEjiU7T+0A1w0Rt/C2R91pYWFp1ylo79VQWCexUx+17yjwYtfiMAtUPIOjdbz2 kckmPbfMZAZb++MWbPoTKu6fo29VmCNCPwqEm2kVbzdWptb419cHoQjbyX1c4T3z0fkJ 2UbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HMYa5NiY0+tNheCQvRZgs2PeYcK66AtT6y4yEJ8Q2nw=; b=XFrcGLymqlkl2aqHi9bSqCLOtqkPo4iu/DiYBKsJvNdkHMGuA6tUW0kvS4HLUxdCBH JwQScbAObPUGzMyLtATCfO5kEp5JatwOEeywhfYN8Hqwz58kIbnh0+P2F/YHMESYfceO 5uD8Xvqg7Ba3IdmvDn/f3Jl01UjorphF6dBZ2pDsMUnFSkaj37Kod17SBler2/VcgsZe tu80VtT/IUNtk3R0gAt3xOrlNU+XR0BalqBM23xjp3Q6ZsEbIQDzOlzV37qBukuGl0BE YUhtg6RRzRISW2lNonanYA/X/RViRunYNKP55xi3M6IECgwCgcn2mKERzC0SnAu9bpi2 +94Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BzuPtwIC; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq25-20020a1709073f1900b006fe9d5da5dcsi22061142ejc.669.2022.06.06.19.29.50; Mon, 06 Jun 2022 19:30:16 -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=@google.com header.s=20210112 header.b=BzuPtwIC; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235234AbiFFXMP (ORCPT + 99 others); Mon, 6 Jun 2022 19:12:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235217AbiFFXMN (ORCPT ); Mon, 6 Jun 2022 19:12:13 -0400 Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B52E9640B for ; Mon, 6 Jun 2022 16:12:11 -0700 (PDT) Received: by mail-yb1-xb35.google.com with SMTP id e184so28275096ybf.8 for ; Mon, 06 Jun 2022 16:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HMYa5NiY0+tNheCQvRZgs2PeYcK66AtT6y4yEJ8Q2nw=; b=BzuPtwICl92nn405IDpleNoejSlfHoVolX0QcMDyWh5sJPX3d2ognqXZ948C603TGR 18+yTMN80wJCnRVdFlaIx41/ACFMaDvO4aaRBZZlSggDG+xOpSAMZRnObzQIMd5U7ul/ CnHYQuXfD77FoNUP8YeQj9BL1+rUJ6g93heCL1rsIRx6Dm6amYZnLIPHQcD/TYRJtcMP Kh3tkD6JdPKzYSXc5v8/Ru7C2GNwZ9UkZO3ov57Mnq2iJzEtSCXMge2wfm4co1nObCrp U+bDtijg3kpaAjCETQOmISqQQwkWVXkCv574qIbjLU1yg1sw8KvksEuMXZdcjJVGgtrt Qwpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HMYa5NiY0+tNheCQvRZgs2PeYcK66AtT6y4yEJ8Q2nw=; b=7ILfqGN+iVjG+j9vdJvzs//wmX/+BPO4Nx+RAe8qDUw51WU8hnaiiZh2eVDNUhMoUD A/ayxAg8sm82/e9Qj1/PsrK2Q8lNd5jV1JLRDa3AO/Q9eXDQqF2t6UfPJN302aADDfQO FiDFZSum83+bW9vWEtSrV+OvFN565tLKAWv9eNspb0UtfqEDmWetbfEcmclUWBn+74Ot nCqyieRCpqsTeZBT6UwL2LxuHgJrSs/Dg8JfXJtnTUaItRFsJ+/hchnRlexOaEgvgBhM u5gadLjijH4SB8pS3DpUKi09GsvXUureW+4AeCre49Gs3+PqVBUHxzULCr4lVSnuOGcc Qe+g== X-Gm-Message-State: AOAM530E1glvZg6aGBUwxIkTS/8RDTAsEPg1BrgdhCF3l61fvXSlXeLL tFUZMj46c4FMQkCjKI54VcI2tU0LjR0bsDa4ivULHA== X-Received: by 2002:a05:6902:124c:b0:663:9db4:671c with SMTP id t12-20020a056902124c00b006639db4671cmr7080234ybu.543.1654557130742; Mon, 06 Jun 2022 16:12:10 -0700 (PDT) MIME-Version: 1.0 References: <20220525230904.1584480-1-bgardon@google.com> In-Reply-To: From: Ben Gardon Date: Mon, 6 Jun 2022 16:11:59 -0700 Message-ID: Subject: Re: [PATCH] KVM: x86/MMU: Zap non-leaf SPTEs when disabling dirty logging To: Paolo Bonzini Cc: Peter Xu , kvm , LKML , Sean Christopherson , David Matlack , Jim Mattson , David Dunn , Jing Zhang , Junaid Shahid Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Thu, May 26, 2022 at 9:00 AM Ben Gardon wrote: > > On Thu, May 26, 2022 at 8:52 AM Paolo Bonzini wrote: > > > > On 5/26/22 16:30, Peter Xu wrote: > > > On Thu, May 26, 2022 at 02:01:43PM +0200, Paolo Bonzini wrote: > > >> On 5/26/22 01:09, Ben Gardon wrote: > > >>> + WARN_ON(max_mapping_level < iter.level); > > >>> + > > >>> + /* > > >>> + * If this page is already mapped at the highest > > >>> + * viable level, there's nothing more to do. > > >>> + */ > > >>> + if (max_mapping_level == iter.level) > > >>> + continue; > > >>> + > > >>> + /* > > >>> + * The page can be remapped at a higher level, so step > > >>> + * up to zap the parent SPTE. > > >>> + */ > > >>> + while (max_mapping_level > iter.level) > > >>> + tdp_iter_step_up(&iter); > > >>> + > > >>> /* Note, a successful atomic zap also does a remote TLB flush. */ > > >>> - if (tdp_mmu_zap_spte_atomic(kvm, &iter)) > > >>> - goto retry; > > >>> + tdp_mmu_zap_spte_atomic(kvm, &iter); > > >>> + > > >> > > >> Can you make this a sparate function (for example > > >> tdp_mmu_zap_collapsible_spte_atomic)? Otherwise looks great! > > > > > > There could be a tiny downside of using a helper in that it'll hide the > > > step-up of the iterator, which might not be as obvious as keeping it in the > > > loop? > > > > That's true, my reasoning is that zapping at a higher level can only be > > done by first moving the iterator up. Maybe > > tdp_mmu_zap_at_level_atomic() is a better Though, I can very well apply > > this patch as is. > > I'd be inclined to apply the patch as-is for a couple reasons: > 1. As Peter said, hiding the step up could be confusing. > 2. If we want to try the in-place promotion, we'll have to dismantle > that helper again anyway or else have a bunch of duplicate code. Circling back on this, Paolo would you like me to send another version of this patch, or do you think it's good to go? > > > > > Paolo > >