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=-9.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 067A8C56202 for ; Thu, 12 Nov 2020 01:34:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABC4E206F1 for ; Thu, 12 Nov 2020 01:34:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728681AbgKLBeA (ORCPT ); Wed, 11 Nov 2020 20:34:00 -0500 Received: from audible.transient.net ([24.143.126.66]:54904 "HELO audible.transient.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1727475AbgKKW5S (ORCPT ); Wed, 11 Nov 2020 17:57:18 -0500 Received: (qmail 12014 invoked from network); 11 Nov 2020 22:57:15 -0000 Received: from cucamonga.audible.transient.net (192.168.2.5) by canarsie.audible.transient.net with QMQP; 11 Nov 2020 22:57:15 -0000 Received: (nullmailer pid 3746 invoked by uid 1000); Wed, 11 Nov 2020 22:57:15 -0000 Date: Wed, 11 Nov 2020 22:57:15 +0000 From: Jamie Heilman To: Ben Gardon Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Peter Shier , Jim Mattson , Zdenek Kaspar Subject: Re: [PATCH] kvm: x86/mmu: Fix is_tdp_mmu_check when using PAE Message-ID: <20201111225715.GA2910@audible.transient.net> Mail-Followup-To: Ben Gardon , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Sean Christopherson , Peter Shier , Jim Mattson , Zdenek Kaspar References: <20201111185337.1237383-1-bgardon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201111185337.1237383-1-bgardon@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ben Gardon wrote: > When PAE is in use, the root_hpa will not have a shadow page assoicated > with it. In this case the kernel will crash with a NULL pointer > dereference. Add checks to ensure is_tdp_mmu_root works as intended even > when using PAE. This seems to work in my amd64 case as well. (https://marc.info/?l=linux-kernel&m=160494962201032&w=2) > Tested: compiles > > Fixes: 02c00b3a2f7e ("kvm: x86/mmu: Allocate and free TDP MMU roots") > Reported-by: Zdenek Kaspar > Signed-off-by: Ben Gardon > --- > arch/x86/kvm/mmu/tdp_mmu.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 27e381c9da6c..13013f4d98ad 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -49,8 +49,18 @@ bool is_tdp_mmu_root(struct kvm *kvm, hpa_t hpa) > { > struct kvm_mmu_page *sp; > > + if (WARN_ON(!VALID_PAGE(hpa))) > + return false; > + > sp = to_shadow_page(hpa); > > + /* > + * If this VM is being run with PAE, the TDP MMU will not be enabled > + * and the root HPA will not have a shadow page associated with it. > + */ > + if (!sp) > + return false; > + > return sp->tdp_mmu_page && sp->root_count; > } > > -- > 2.29.2.222.g5d2a92d10f8-goog > -- Jamie Heilman http://audible.transient.net/~jamie/