Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D572C433FE for ; Tue, 4 Jan 2022 20:55:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233764AbiADUzL (ORCPT ); Tue, 4 Jan 2022 15:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233685AbiADUzI (ORCPT ); Tue, 4 Jan 2022 15:55:08 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6F7DC061785 for ; Tue, 4 Jan 2022 12:55:07 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id t19so33241776pfg.9 for ; Tue, 04 Jan 2022 12:55:07 -0800 (PST) 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=OX8TnGGp+Sau0fCZ9YjFewph+wIKfyabwC9wDq4Uvyg=; b=Iz3EAtsohSdfNjculbq93U5enP/6Sfl+Te4d/bMffastpeSdA2tgElC8n2tB1xILcs XjpC3K9kBYtbTOoLs++Z1qdFM29DVsm1pcHoo9wmvmloeorZsn/4e7+5JRjaf1EfhorO g7voV4uLSpTahpdpewVy8bh0lj3m7XV+dNTzdzpWIczgKAi5wkXUxgk5JR1crlF+6YHM qhYVn0DLhXaxhraSzwtTs8Wp3VBjj6ubKM4fswr3BxZyNYHUVC0k3H/84GxntT9ngRVo fKHu9BqjrZYrl5xhSV4auovW1g4p10hl13y8PUBaE/f7gZaOfkXYDE7ix5Ar3Zm3YEie AY9Q== 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=OX8TnGGp+Sau0fCZ9YjFewph+wIKfyabwC9wDq4Uvyg=; b=CLgqoYq0y2lj5GdFZFT44cenDm89qR3VFgeLnQ63WieHA56fSZnZyYLvsGcBMPhhLt gHtqutbvhSDnz2pIzCs/Kv8K8K5M4SzibX+jajuGL1JkC1sc0J73XC0TUf8k0xffzdd+ MiHKZt6ip6x+PaTlh+OK1cG3OgB5S8RhXjU8m5PZ16N7cneIfUpTL5M4o9UhHAfjdXY7 QyKmWxqm23/Ja1iAwaG2N9innwI+EFzHoTJ0+vDi4UGpFhABejIuiGLGfYfCv1q7X9NA BPoo3g1cKypVmakF54byr/o+r7gEEv7ArNsT6Ql8PnOUp1N+x+ukN4w39LglOfs8g0Hj tp5A== X-Gm-Message-State: AOAM531V5bC83/+laVXSX5+apA+ph/uXVD09z6QYN+1LujVOLEITHRCX qCRVFhqYHQCktbtP25AMw4XgYw== X-Google-Smtp-Source: ABdhPJwlegmwapfHfVMD2Qt0rG5au5EwXr34rL2iOSS/REQFWPwiujRf96ZM3jUy1eBJ8gZjC1Pv6g== X-Received: by 2002:a63:3718:: with SMTP id e24mr30213351pga.16.1641329707106; Tue, 04 Jan 2022 12:55:07 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id b13sm40897834pfo.37.2022.01.04.12.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jan 2022 12:55:06 -0800 (PST) Date: Tue, 4 Jan 2022 20:55:03 +0000 From: Sean Christopherson To: Lai Jiangshan Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini , Lai Jiangshan , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" Subject: Re: [RFC PATCH 6/6] KVM: X86: Use level_promoted and pae_root shadow page for 32bit guests Message-ID: References: <20211210092508.7185-1-jiangshanlai@gmail.com> <20211210092508.7185-7-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211210092508.7185-7-jiangshanlai@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 10, 2021, Lai Jiangshan wrote: > diff --git a/arch/x86/kvm/mmu/tdp_mmu.h b/arch/x86/kvm/mmu/tdp_mmu.h > index 476b133544dd..822ff5d76b91 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.h > +++ b/arch/x86/kvm/mmu/tdp_mmu.h > @@ -100,13 +100,8 @@ 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); > - return sp && is_tdp_mmu_page(sp) && sp->root_count; > + return is_tdp_mmu_page(sp) && sp->root_count; > } is_page_fault_stale() can get similar treatment diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index e8c69c2dfbd9..9ff8e228b55e 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3855,19 +3855,7 @@ static bool is_page_fault_stale(struct kvm_vcpu *vcpu, { struct kvm_mmu_page *sp = to_shadow_page(vcpu->arch.mmu->root_hpa); - /* Special roots, e.g. pae_root, are not backed by shadow pages. */ - if (sp && is_obsolete_sp(vcpu->kvm, sp)) - return true; - - /* - * Roots without an associated shadow page are considered invalid if - * there is a pending request to free obsolete roots. The request is - * only a hint that the current root _may_ be obsolete and needs to be - * reloaded, e.g. if the guest frees a PGD that KVM is tracking as a - * previous root, then __kvm_mmu_prepare_zap_page() signals all vCPUs - * to reload even if no vCPU is actively using the root. - */ - if (!sp && kvm_test_request(KVM_REQ_MMU_RELOAD, vcpu)) + if (is_obsolete_sp(vcpu->kvm, sp)) return true; return fault->slot && > #else > static inline bool kvm_mmu_init_tdp_mmu(struct kvm *kvm) { return false; } > -- > 2.19.1.6.gb485710b >