Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2774326pxt; Mon, 9 Aug 2021 08:36:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/H0E6V5N6r9RSjr5WSBlQ6TTCcumolre1JUMia/Trw/IhcRBC7N1IaA2NDQcX2meGcnyH X-Received: by 2002:a17:906:c2da:: with SMTP id ch26mr23826444ejb.111.1628523412696; Mon, 09 Aug 2021 08:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628523412; cv=none; d=google.com; s=arc-20160816; b=RVbs+CWGDth1mbD37lgyHGagKqB+jV3EROCfCAV26H80BbToeyPX/CnNtkPtAQ7s4s /55jrYe5D99+ljTwGxr1/KgHwWvXIw1/Ff6lY4lpPYRCrxpbZgn92ijDxoz/WjXAOuOX u1AzBc8YfyttKxh31gXxKNDrbUKVnnCKYTT2w69hsYvQcs7tWqQ9ExNMqXchLXkaeQuT /OIg/91uV3wg6D35jOCcjAL2F5nRkd41440yo5oifNk/mVyBLD+vvGkez1olcL1pgxnn sG8YvfofySaGN32zIfgtskDFaY5SDYyQRUreeAEOEw77Ns2/1DaRe/f6ionyPKQrmpmg 6TVA== 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=0AECcEi2rpt5gm0PQCPyfbI2DBqYy38YFfxxfkJxtfU=; b=h3lDDcmOf/QddaMABzZDuAyXiCdy/yQbzD4mVjJSc5NjMEcNExqxtRH0ueYPG9uCwm yyF04KeUAAJY34wIkmrgmtoWSKc9THOFb8GxzZftKW5V4J7ZFbBZUtZlAo2Ob+S7vjhy 3Jke80hPVUqqb/2TmHNAolzH+ppewqKpMJZlA6iDwL8eC3PD21t+8d2GbFjKzL4LSaBR WfQZ9jffddz9CuT82J98gttdq6Jumbjb4/JvsLCjD5/MWZn/FiWY34mJrcG+dcMVmr86 60294jL5RanJ+zEb4kJVUFR8rDOL04dUqUds7bThVKGSuqktXQtTxnGJxy5ss/EgpFEw Yniw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=nvgDcF9o; 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 k16si17813723edo.475.2021.08.09.08.36.29; Mon, 09 Aug 2021 08:36:52 -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=nvgDcF9o; 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 S235556AbhHIPdr (ORCPT + 99 others); Mon, 9 Aug 2021 11:33:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235537AbhHIPbW (ORCPT ); Mon, 9 Aug 2021 11:31:22 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA92C061798 for ; Mon, 9 Aug 2021 08:30:13 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id l11so5110895plk.6 for ; Mon, 09 Aug 2021 08:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0AECcEi2rpt5gm0PQCPyfbI2DBqYy38YFfxxfkJxtfU=; b=nvgDcF9oG4oweN91pNjyW0PwF3Wwq1kdB8edecupp/0AAlGgeVxfi6VaUQYhaBKIEQ KfxX7PsGRvTGaymoz7UKsMn7m6U3/pvHIAtH9dSiNosjr6WZeZAhce0vGW8uDjdRtKax a6u7Ig4lBKVRJw5VhquaWiKNLQ3TVn7Q6byy7hy4H8juTQJEau+Z6YqtOXl1dN4R4Mij bqpUPJNiavaIwG/MtPnpZ81XQ1+n8tDBylpVsX3eAbu8sPwPVk7UfHhNHRcSvnMto/9O q9iNpgDuNR3OjvkApqeNWTi1MltBiczdHnuiMlcCoaP/YwLWHkMDcMXHnNt53lnK9vCY cFaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0AECcEi2rpt5gm0PQCPyfbI2DBqYy38YFfxxfkJxtfU=; b=Ov9Yt/XvaMkkrpS+pLReBd/K2Txoc9fjHKIo+yS+XSwqKfIOdelI/y48X+eUF1hjII zkYqY3Bju4dvkxhfPgS+nUrIc8eEFzhtpdKEOXcWuv+QdAt/pyRE6dfn/FTyD19t1Eyu vts9hnWRI32OzcYuvaOa86PvC2KF+ZiuQ7H+1duJfCMCqxlzA5eqU1twBNJ/lxvXDsrA G7kbCZgC7z6R5JHZ8725PzJLHO4eGC8heQ8lsS+ghoVgvLmkdXeEHnLNYLlA7DuFxp+e +vLEs4SYq38BhTE/Y1VPiH9APRAln10G8D+ADWaZdbnRR67eA1MNz8Bol3zEchQNJPDB Q2Ng== X-Gm-Message-State: AOAM532CzUFIfe3XHYeepK62OhW3LiO5UvM8t5y10k+5XVI0/UyTGywo EWdOBWjYiUkepw6WhKVKxvQwpw== X-Received: by 2002:a17:90a:bb0b:: with SMTP id u11mr36773910pjr.18.1628523012466; Mon, 09 Aug 2021 08:30:12 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id y2sm19717321pjl.6.2021.08.09.08.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Aug 2021 08:30:11 -0700 (PDT) Date: Mon, 9 Aug 2021 15:30:08 +0000 From: Sean Christopherson To: Yu Zhang Cc: Wei Huang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, vkuznets@redhat.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, hpa@zytor.com Subject: Re: [PATCH v2 1/3] KVM: x86: Allow CPU to force vendor-specific TDP level Message-ID: References: <20210808192658.2923641-1-wei.huang2@amd.com> <20210808192658.2923641-2-wei.huang2@amd.com> <20210809035806.5cqdqm5vkexvngda@linux.intel.com> <20210809042703.25gfuuvujicc3vj7@linux.intel.com> <73bbaac0-701c-42dd-36da-aae1fed7f1a0@amd.com> <20210809064224.ctu3zxknn7s56gk3@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210809064224.ctu3zxknn7s56gk3@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 09, 2021, Yu Zhang wrote: > On Sun, Aug 08, 2021 at 11:33:44PM -0500, Wei Huang wrote: > > > > On 8/8/21 11:27 PM, Yu Zhang wrote: > > > On Sun, Aug 08, 2021 at 11:11:40PM -0500, Wei Huang wrote: > > > > > > > > > > > > On 8/8/21 10:58 PM, Yu Zhang wrote: > > > > > On Sun, Aug 08, 2021 at 02:26:56PM -0500, Wei Huang wrote: > > > > > > AMD future CPUs will require a 5-level NPT if host CR4.LA57 is set. > > > > > > > > > > Sorry, but why? NPT is not indexed by HVA. > > > > > > > > NPT is not indexed by HVA - it is always indexed by GPA. What I meant is NPT > > > > page table level has to be the same as the host OS page table: if 5-level > > > > page table is enabled in host OS (CR4.LA57=1), guest NPT has to 5-level too. > > > > > > I know what you meant. But may I ask why? > > > > I don't have a good answer for it. From what I know, VMCB doesn't have a > > field to indicate guest page table level. As a result, hardware relies on > > host CR4 to infer NPT level. > > I guess you mean not even in the N_CR3 field of VMCB? Correct, nCR3 is a basically a pure representation of a regular CR3. > Then it's not a broken design - it's a limitation of SVM. :) That's just a polite way of saying it's a broken design ;-) Joking aside, NPT opted for a semblance of backwards compatibility at the cost of having to carry all the baggage that comes with a legacy design. Keeping the core functionality from IA32 paging presumably miminizes design and hardware costs, and required minimal enabling in hypervisors. The downside is that it's less flexible than EPT and has a few warts, e.g. shadowing NPT is gross because the host can't easily mirror L1's desired paging mode.