Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5115189pxj; Tue, 22 Jun 2021 15:41:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPaARi5y3TBsS5zx3sjKRx45jQLcONPmq+b16+x+OuyjhFu8zdThF1rUNa3+pHIrWYPUW/ X-Received: by 2002:a5e:8513:: with SMTP id i19mr4553964ioj.50.1624401667250; Tue, 22 Jun 2021 15:41:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624401667; cv=none; d=google.com; s=arc-20160816; b=VZpRnRPHN2fvhp5CrUXHBQA+nVkHvaQ7vZ0QlaE3EuXZ2/T84NDt7iAsn2mBXf4qcf /KydGr5PooNmd7wP5N0YKU41v72Y/wMq8kUmPKaHUDRyEaaMZQgS1uqK9Rl5yOUQl3B6 ImgHep2onv0FomBOu8w8bRoSpa5rJ3myp3fmpzB0gAgdUhjjOHC9t3J3E+ibaJnSdu5q MLhmZ0af9ZAkUlHwMeyGsz4qGmnJGC4MKyutW4LIBAkPyweInNOpR4uGufDBtfx64hSj ffiaqAVDobOi9EseLKS9LXp+AdUXBjzXW6DQnlVwEGDopzEcygWIkHaqVPFFb5lueIe/ IkLA== 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=qSJCzIJ/W2NmiCitrgwllPiyxSA/GA4EEsJjyUuSU30=; b=hWUnL2IL7aERXDz58CRnhFelFlqlifjCUEjBr2HgKlo0dJQjhoZN37ZjH0uwqHZqYi XGTuHmpv5BvWVX3sQ1T/1a1ksStR3/d45+yT+CSd8XMn56yjBcvPlhTMl6bfWvo3CIDa /w/eQzkwXqjPNrcmnWi4eelyN3qKUiSNj7WbbxEV68tHTILHPkr70hnKRk3ZR6kMNopA A2kIsudV+QmouzllCoF7gkWWcM32GJCl6jTRVadhiIpX3lsHc24CjLZcqu8g0VN9SrYq gdkxYMdWg3DpkfAMLjXCRF2lgCB5Hu1qhpa8Bi4Odux6Ps1Y2L15zCjxfUzcuLKwijE3 hZOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oyktG73Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si12852667ilq.15.2021.06.22.15.40.54; Tue, 22 Jun 2021 15:41:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oyktG73Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S230357AbhFVWlj (ORCPT + 99 others); Tue, 22 Jun 2021 18:41:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229800AbhFVWlj (ORCPT ); Tue, 22 Jun 2021 18:41:39 -0400 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88457C061574 for ; Tue, 22 Jun 2021 15:39:22 -0700 (PDT) Received: by mail-lj1-x236.google.com with SMTP id c11so332623ljd.6 for ; Tue, 22 Jun 2021 15:39:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qSJCzIJ/W2NmiCitrgwllPiyxSA/GA4EEsJjyUuSU30=; b=oyktG73YZVDch+DxSWZBlUYtTGIHzL78FhJ/G2Cbmc71waG4Z3/lFnjGgL/IqYV1jK WNgB53E8bbLHlfKWSbaUvcRVQ0hDjyeWDlu7jqP5TG3374N87wFX5FrYF2gH1GdTuiF0 fvBIv425RseHG54g0rrjatewbzwOGEMhiJN4MGdVl1VZpe+XaMpFC5hPJ2OGz7H2Hnbq vIwjhSa91ZLHE9SMWkb1kEBUcrC1dIUSUsc4ei7J+JRpJUywEUIXu3wpLc8QX74URK8i Xaf9ixG9oTKgJeT1mj9JiIJ3wlzmN117pUM3cmqzeg4iQxgQp7JVx4peowqd1zckZW2Y KNjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qSJCzIJ/W2NmiCitrgwllPiyxSA/GA4EEsJjyUuSU30=; b=ftP0g6Ki1QnMQxa5AcEzevEqYsuNvPC3ja9bEbVqJpZm1TKKz4H6o2ueMLjJw7K2Be NDYMGjffLBnGlwMvuLMQgnk+oqC/TFUrGdDcDlGM1lN5CttkyOTRHl/mCOGMlqR/NVb4 /DxnEVElRTVTvEctz+vRNiivwQ+2nmpXgh+rft2AAI0Ca0sF5unO5ofzBShK9D4kJIaA QXjtRmb+maAq1C4pL1h4lPDDQ9Yv6aOkJocU13KWSQOw0HXLawbc2GSZjy/TYC9wWZLo tJ3hoAGZsqIk+fo2tVDwVZz50uF76SisV6UgU5181V7lO/qCSbMVauIv2Gl88lOj3wr/ lq2Q== X-Gm-Message-State: AOAM531Hnxu0+CCM2UDyvVn15QL0sdlMN+bobPEO7EGBuGHgcqIUoHDN S4LGPuVu5lT18g2DgGvJDniy+jCDsvEQqjU2KderYw== X-Received: by 2002:a2e:9852:: with SMTP id e18mr5092607ljj.383.1624401560707; Tue, 22 Jun 2021 15:39:20 -0700 (PDT) MIME-Version: 1.0 References: <20210622072454.3449146-1-seanjc@google.com> In-Reply-To: <20210622072454.3449146-1-seanjc@google.com> From: David Matlack Date: Tue, 22 Jun 2021 15:38:54 -0700 Message-ID: Subject: Re: [PATCH] KVM: x86/mmu: Don't WARN on a NULL shadow page in TDP MMU check To: Sean Christopherson Cc: Paolo Bonzini , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm list , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 12:24 AM Sean Christopherson wrote: > > Treat a NULL shadow page in the "is a TDP MMU" check as valid, non-TDP > root. KVM uses a "direct" PAE paging MMU when TDP is disabled and the > guest is running with paging disabled. In that case, root_hpa points at > the pae_root page (of which only 32 bytes are used), not a standard > shadow page, and the WARN fires (a lot). > > Fixes: 0b873fd7fb53 ("KVM: x86/mmu: Remove redundant is_tdp_mmu_enabled check") > Cc: David Matlack > Signed-off-by: Sean Christopherson Thanks for the fix. I was able to reproduce the issue by running a kvm-unit-test with EPT=N. I'll add that to my "pre-send-email" workflow in the future. Reviewed-by: David Matlack > --- > arch/x86/kvm/mmu/tdp_mmu.h | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.h b/arch/x86/kvm/mmu/tdp_mmu.h > index b981a044ab55..1cae4485b3bc 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.h > +++ b/arch/x86/kvm/mmu/tdp_mmu.h > @@ -94,11 +94,13 @@ static inline bool is_tdp_mmu(struct kvm_mmu *mmu) > if (WARN_ON(!VALID_PAGE(hpa))) > return false; > > + /* > + * A NULL shadow page is legal when shadowing a non-paging guest with > + * PAE paging, as the MMU will be direct with root_hpa pointing at the > + * pae_root page, not a shadow page. > + */ > sp = to_shadow_page(hpa); > - if (WARN_ON(!sp)) > - return false; > - > - return is_tdp_mmu_page(sp) && sp->root_count; > + return sp && is_tdp_mmu_page(sp) && sp->root_count; > } > #else > static inline bool kvm_mmu_init_tdp_mmu(struct kvm *kvm) { return false; } > -- > 2.32.0.288.g62a8d224e6-goog >