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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90E33C433EF for ; Tue, 8 Mar 2022 18:17:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348285AbiCHSSg (ORCPT ); Tue, 8 Mar 2022 13:18:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234608AbiCHSSd (ORCPT ); Tue, 8 Mar 2022 13:18:33 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8603F6460 for ; Tue, 8 Mar 2022 10:17:35 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id mr24-20020a17090b239800b001bf0a375440so2912571pjb.4 for ; Tue, 08 Mar 2022 10:17:35 -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=cI7zgl192Zgl3FFh3U4mmGv/6PXl3YZNSM+T7Oyiol8=; b=Pv+w0OPdgjrA6X05d91ctImuGJjqz6cgOVsS+StY2xCxBllaQ1oKJPpCgl07DTCfim Qj4WFtlGsAAVKez+oNnuYOqWXssbmZb2FpVgOw1Cqu91SrXN+imKKs74YVJDNYV9qrND xPHdeHZfDMLpcHtpdlcvXXoYhwFNAu/8H2Hol8X6YsOGHcbZj1qtYGjU9suZQGFkJFqV yAZXLDesfbeIc1afkcghHlcou2HFoasrcMAIxPrQrs2q1YY5JCGhKN0RHI/ZEjvZPJJd IZQ/63nh2SluOZKNn4E4qMWN91ioO6WYa/c3Vmr9avBgws1nNe4qAqHs4kmp8CAXQGgu z/Bw== 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=cI7zgl192Zgl3FFh3U4mmGv/6PXl3YZNSM+T7Oyiol8=; b=i6jnRahEeAKZGaIKaQ7rGbrFRQHnIk1p8XdslBOrNpcTBPe9WifGV2eP5CRFYeINBw B46E67y+bCTlbxiTa1AF9egHnA6mEsdXzGo1X7aOTLbxFCMm+hgdcOM4Q9ZRcNGiCfx0 lSSTebgyJC967GN4+S3QKqbQtgIUMEQjUvmq5/K34vIvQH0Xrn1vHUnJKmbT1yGEslLz qarZQWUTml9Y4jv6Jc0YcIIH6Kg4Q7C11Gf69j92Vd0qmJHnlTrHEPLqupbeyUEdwxTZ IDgkk9U2XufDjC2dYl0PAO8G1/QxspY8Vyl3fg2KPpQAmHhZoWkAkH16AFIHVNDyRzt6 3OaQ== X-Gm-Message-State: AOAM531G798uTNpsl1s1B3PD/wDAzquLPFykisgKWNJVIEDOEe8e7uvG 1kI3XFblHYE/kIvXorhA2ILkhQ== X-Google-Smtp-Source: ABdhPJz+wgCSAnSzicl3Luf93x8udYKc3NWJOTwE6AbtuwPSPxPWWSntgtXDPstaNRnyUE+WgFBQpQ== X-Received: by 2002:a17:903:3094:b0:151:f5a7:ad72 with SMTP id u20-20020a170903309400b00151f5a7ad72mr8136332plc.135.1646763454896; Tue, 08 Mar 2022 10:17:34 -0800 (PST) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id k23-20020aa790d7000000b004f6c8b7c13bsm14825043pfk.132.2022.03.08.10.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 10:17:34 -0800 (PST) Date: Tue, 8 Mar 2022 18:17:30 +0000 From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, dmatlack@google.com Subject: Re: [PATCH v2 11/25] KVM: x86/mmu: remove kvm_calc_shadow_root_page_role_common Message-ID: References: <20220221162243.683208-1-pbonzini@redhat.com> <20220221162243.683208-12-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 08, 2022, Paolo Bonzini wrote: > On 3/8/22 18:48, Sean Christopherson wrote: > > On Mon, Feb 21, 2022, Paolo Bonzini wrote: > > > kvm_calc_shadow_root_page_role_common is the same as > > > kvm_calc_cpu_mode except for the level, which is overwritten > > > afterwards in kvm_calc_shadow_mmu_root_page_role > > > and kvm_calc_shadow_npt_root_page_role. > > > > > > role.base.direct is already set correctly for the CPU mode, > > > and CR0.PG=1 is required for VMRUN so it will also be > > > correct for nested NPT. > > > > Bzzzt, this is wrong, the nested NPT MMU is indirect but will be computed as direct. > > CR0.PG=1 means it's *not* direct: > > > + role.base.direct = !____is_cr0_pg(regs); Ha! I was just cleverly making the case for checking ____is_cr0_pg() instead of "direct" for computing the dependent flags, I swear... On a serious note, can we add a WARN_ON_ONCE(role.base.direct)? Not so much that the WARN will be helpful, but to document the subtle dependency? If the relevant code goes away in the end, ignore this requrest.