From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FSL_HELO_FAKE, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB2BAC4320A for ; Thu, 12 Aug 2021 16:43:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEA3160FBF for ; Thu, 12 Aug 2021 16:43:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232894AbhHLQoX (ORCPT ); Thu, 12 Aug 2021 12:44:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232850AbhHLQoU (ORCPT ); Thu, 12 Aug 2021 12:44:20 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64D58C061756 for ; Thu, 12 Aug 2021 09:43:55 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id hv22-20020a17090ae416b0290178c579e424so11627417pjb.3 for ; Thu, 12 Aug 2021 09:43:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Z693XsiBKLrJvSZ/YAAMgAz4mbAtqabwjx08Gr/DpaA=; b=bsXEPviGSDTJ7TDuPHVI19R5NuLoJ2kf8Gaw7EKQDdJmou0qLOnQG5dWGm37aEdqD9 96Nzf+MCAlpC3PxOTU9UU/Kst8rqgPBcfjl8lP38f9gEGT/1+mrCftDd1ehXZgWxRqmY 7dukLUx9IxpTI/84upP+ww7oQYY7zUBZqfb3Pye+i9VIPkgbetLMq6S1l0zFqo4+D8xZ TM+VIqiWUQn7OkMZ9RTAKua2XPdr5atIZqyT8D+Cer3lLWjBqy0dj9SsHmP4X5YwpZj3 R7NTJAdLT/U2ZM6L1YaMAbMqOmzn4f/20r5XePvIzKWL/j91wc1Xsi7wg3qDLioYUqRh pGjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Z693XsiBKLrJvSZ/YAAMgAz4mbAtqabwjx08Gr/DpaA=; b=jq5O8aQcFHatiPMk4T8spTEpop++3DzqxrU+Z62a7oId1HtmCC+yB//ogMquvPm9Av DQwl4oE9ObhB7Tcp6TUkYp0E8hSKZXLTJJiNAk6FXFqSVnfsidbazg6AB+4Hr73mKf9j 5smE6pFRSXIpIKm0TrkfF556r0fjzsW8e7koV6ikPCKnz0F/z+y0Q3q+ABCqWS4/bDpK gTx2XfGOxpaEsvpcf/2Nz1w9P3WqMHYePRhkCh4anrh7H3dm6PeZn4ReaABkD/dNkDq5 g4i6uAjMBLMbkOFqLm3m/xpqO1jfXfkgECVyNxjZ7ww85A75pB8gIGtf1JclFX+Q04NL rzWg== X-Gm-Message-State: AOAM533h07PvlWSqJtLBg3fn5O5JgzAl3MfOQ0FvV7lXKfAmmkwIoYrK i9kA7IG0sTuknNlQP30jRv6cgQ== X-Google-Smtp-Source: ABdhPJwlGCKp/K9xjWsUK3OWafCfD6463Y9XffOe17Y9OHk5HyISbCPM0vw0Mx//+9WqGVF1o8GqOw== X-Received: by 2002:a63:4a41:: with SMTP id j1mr4493549pgl.227.1628786634700; Thu, 12 Aug 2021 09:43:54 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id o22sm3877172pfu.87.2021.08.12.09.43.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Aug 2021 09:43:54 -0700 (PDT) Date: Thu, 12 Aug 2021 16:43:48 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon Subject: Re: [PATCH 1/2] KVM: x86/mmu: Don't skip non-leaf SPTEs when zapping all SPTEs Message-ID: References: <20210812050717.3176478-1-seanjc@google.com> <20210812050717.3176478-2-seanjc@google.com> <01b22936-49b0-638e-baf8-269ba93facd8@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01b22936-49b0-638e-baf8-269ba93facd8@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 12, 2021, Paolo Bonzini wrote: > On 12/08/21 07:07, Sean Christopherson wrote: > > @@ -739,8 +749,16 @@ static bool zap_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root, > > gfn_t start, gfn_t end, bool can_yield, bool flush, > > bool shared) > > { > > + bool zap_all = (end == ZAP_ALL_END); > > struct tdp_iter iter; > > + /* > > + * Bound the walk at host.MAXPHYADDR, guest accesses beyond that will > > + * hit a #PF(RSVD) and never get to an EPT Violation/Misconfig / #NPF, > > + * and so KVM will never install a SPTE for such addresses. > > + */ > > + end = min(end, 1ULL << (shadow_phys_bits - PAGE_SHIFT)); > > Then zap_all need not have any magic value. You can use 0/-1ull, it's > readable enough. ZAP_ALL_END is also unnecessary here if you do: > > gfn_t max_gfn_host = 1ULL << (shadow_phys_bits - PAGE_SHIFT); > bool zap_all = (start == 0 && end >= max_gfn_host); Aha! Nice. I was both too clever and yet not clever enough. > end = min(end, max_gfn_host); > > And as a small commit message nit, I would say "don't leak" instead of > "don't skip", since that's really the effect. Hrm, yeah, I can see how "skip" doesn't raise alarm bells like it should.