Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1056875iob; Wed, 4 May 2022 13:43:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQl9sATmUAi8/mps4WwcSApBOowanTZq+t6SG+PSe0uZZSawDx9KRS00OcF/l2NyBg5VEr X-Received: by 2002:a17:906:8306:b0:6f4:314b:4db with SMTP id j6-20020a170906830600b006f4314b04dbmr18148341ejx.226.1651696980123; Wed, 04 May 2022 13:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651696980; cv=none; d=google.com; s=arc-20160816; b=EPHXFw8CBx/Hv/oSdkOVgjFrEdHEQ8S1FvdGEbTSAxq4vox34GUr3YJ8X1jBQ8XyHT skdZ9ImoxEgWTLj7nKS06M/0lm8Wub0s1WQgIX6zNw+rEP+ugN9lsjZaRw0W1D5o7huI DEjtVz6KSMHx4CevOBcq4VYJ53AqIr2CJjSja2k82BAcxWLgxy7iSOe4Ei9slsp+FO9w p2UABxA7r3vGsSzNO7wJg1oaQMX9egdNFui95+FMwsWDnCxtPCP8b+PILhWcsoJkf/bt 8AFHuP/i6a4I5EY5d63p0LN6i6sFyrwJT89AiXN4eDgmgqai3DIsTsgRMOrmLvrVJRcw zS0w== 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:date:dkim-signature; bh=jA2U7X2p/3LAhjnBlGykYcq+8q32UQaHNqJDG7iDoz8=; b=1FksTXrlTvMnZCAUhuxTdn0ocmAnyDmFe7X8IE2GsoOg+olqauUeryYJ1vBHMrUCl/ 0ICq2i1QbNB6vqJFLjYHt/EIlVkBGMi1nlicGOwPT6ZmZCCm/ydf9fN1Co22Eq4QL/j9 39Czedo5UBCjjNQ77G13N3h4PWEGdwrGAEaE61dqmrZ+XtVPDC4cypraupu780VZ24de 37jrEqoXBPViisw66FPPdOHEKN4p4MkjEpZGHn6EcVbeconET9mGKqEM1elkn4wMCsS3 1wNnFpxjSJfqxdaeEOq3ke0u8+we1uQsiB/hLMHY9AEZv2IaInEbB2fNBD5Cx4P64lzI yWPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="joZ7V/hZ"; 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 bv19-20020a170906b1d300b006e801269d02si17446980ejb.240.2022.05.04.13.42.36; Wed, 04 May 2022 13:43:00 -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="joZ7V/hZ"; 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 S1351486AbiEDOu4 (ORCPT + 99 others); Wed, 4 May 2022 10:50:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348325AbiEDOuy (ORCPT ); Wed, 4 May 2022 10:50:54 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C75320F5F for ; Wed, 4 May 2022 07:47:18 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d17so1639700plg.0 for ; Wed, 04 May 2022 07:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=jA2U7X2p/3LAhjnBlGykYcq+8q32UQaHNqJDG7iDoz8=; b=joZ7V/hZQ2CuTxOfNunTc0edKk1WTHwW1o5OkZ8MGaXXI6Mv8BBoA7wO4Abow3tXCJ oMCqCxEikz77nG+WnNKxGpyVDgZTkrcL317GSOAuoCuwuMc44TDRZ22beADxjNX45ebC TdxaH97JHE9e7ZkQnpvEdQI+I1RnGVWsq/4mH0ASU15nV42HY2RVcgcuBKIekswNqVfM f2G2fS2iqH01BVOozgDIht7tJ0Kowm83QO39G8Dj0PRD6yeYgY0vym4JpriVXDLpuwjF SfqgeRVV16sniPZiACP9Mohp3XtDQ8WtX19hsBJYPve0YOv/MPcavC9GB5Jt4ayHWKR6 uOzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=jA2U7X2p/3LAhjnBlGykYcq+8q32UQaHNqJDG7iDoz8=; b=K0JTpfhObd/4Yb7NkbGiy1r0N96b3tNQffgbScyHUbr09tdMyM7r6gvv93FsNr9P39 EEfQI2jgQCETq59lYBGqSDEXVV/vuq2k+i3LmMB8PkPA5VJwkJZ9EV7k6HbFp744yh83 +I7cQ+jbzrJhQR0ixWFzhsip7OTzrFV+faCbAbnD/sf4TYb5qmMxtKtM4qb7TtvV9AYA LVi7tx8vDpWy/BUATLyfru2YKEYLyrqG6LAYAKExxQskBFcaJVc3VKtnTOCSn8t1laJ1 pZtZcxvjkM0rkIoyP7NfA6G7ysqdiqaaqdFdmdMO5KhS3YSfOyUrOfCCIfocrR2dhw74 2igw== X-Gm-Message-State: AOAM533h1sWe7VSW3bzGr3ENh7kgc2DV/7tTC+9D78/tVI7xP3CUGlSE 3nU5BMAQHeV1rM+xEIZz7iFt2A== X-Received: by 2002:a17:902:f54a:b0:15e:a95a:c0a7 with SMTP id h10-20020a170902f54a00b0015ea95ac0a7mr13675385plf.134.1651675637749; Wed, 04 May 2022 07:47:17 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id gv21-20020a17090b11d500b001cd4989ff41sm3355441pjb.8.2022.05.04.07.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 May 2022 07:47:16 -0700 (PDT) Date: Wed, 4 May 2022 14:47:12 +0000 From: Sean Christopherson To: Maxim Levitsky Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ben Gardon , David Matlack Subject: Re: [PATCH] KVM: x86/mmu: Do not create SPTEs for GFNs that exceed host.MAXPHYADDR Message-ID: References: <82d1a5364f1cc479da3762b046d22f136db167e3.camel@redhat.com> <42e9431ec2c716f1066fc282ebd97a7a24cbac72.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42e9431ec2c716f1066fc282ebd97a7a24cbac72.camel@redhat.com> 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=unavailable 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 Wed, May 04, 2022, Maxim Levitsky wrote: > On Tue, 2022-05-03 at 20:30 +0000, Sean Christopherson wrote: > > Well, I officially give up, I'm out of ideas to try and repro this on my end. To > > try and narrow the search, maybe try processing "all" possible gfns and see if that > > makes the leak go away? > > > > diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h > > index 7e258cc94152..a354490939ec 100644 > > --- a/arch/x86/kvm/mmu.h > > +++ b/arch/x86/kvm/mmu.h > > @@ -84,9 +84,7 @@ static inline gfn_t kvm_mmu_max_gfn(void) > > * than hardware's real MAXPHYADDR. Using the host MAXPHYADDR > > * disallows such SPTEs entirely and simplifies the TDP MMU. > > */ > > - int max_gpa_bits = likely(tdp_enabled) ? shadow_phys_bits : 52; > > - > > - return (1ULL << (max_gpa_bits - PAGE_SHIFT)) - 1; > > + return (1ULL << (52 - PAGE_SHIFT)) - 1; > > } > > > > static inline u8 kvm_get_shadow_phys_bits(void) > > > > Nope, still reproduces. > > I'll think on how to trace this, maybe that will give me some ideas. > Anything useful to dump from the mmu pages that are still not freed at that point? Dumping the role and gfn is most likely to be useful. Assuming you aren't seeing this WARN too: WARN_ON(!list_empty(&kvm->arch.tdp_mmu_roots)); then it's not a VM refcounting problem. The bugs thus far have been tied to the gfn in some way, e.g. skipping back-to-back entries, the MAXPHYADDR thing. But I don't have any ideas for why such a simple test would generate unique behavior. > Also do you test on AMD? I test on my 3970X. Yep, I've tried Rome and Milan, and CLX (or maybe SKX?) and HSW on the Intel side.