Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3437315imw; Mon, 11 Jul 2022 08:38:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s5M2GhvMhhQMrbqCf5yM3RLzHgJ55cUn/oyENcVKrGIVc3oW3iMLRDVkR7eYYOUBL5De9L X-Received: by 2002:a63:2c47:0:b0:411:54ab:97b6 with SMTP id s68-20020a632c47000000b0041154ab97b6mr16421728pgs.173.1657553883722; Mon, 11 Jul 2022 08:38:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657553883; cv=none; d=google.com; s=arc-20160816; b=c1+wIoG/diJ02NV6f3BGcLubPOz9o63XLK9p+7maR2uyN8VRk+BN77s2AetuXcyTyK Zg4LxV8vXy0QPEdo6N2pLus/iwajvdcKD6Lu25cYS9QxYS+2BJsL2hWLMuMMfLq3zfsu VDEYbZ+6NZTaKTQh4p622noKQuhp/1M6rJa8vpE0fo9H5NFIgrdxP92d96ZFjzflHzNa 8fv+++VaoOGV4DfeRmTQUsyKqg/frDSoCbYQoaBN2aBoVyMXF5wQ/tvE7kUCTvs7KgEd ZBRSfBd6fofT+8uwxQu7faQPm4VS4hW2O9sZBzEJ9kg+OuiEB6iCaf2KCpSt7ZlQhE/z jgKA== 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=3+iOhYm5m5ryVsh6j+fvjnI4Rfo7Ca22Rrvor4EkRvU=; b=eF4Tz2H8rh41Syw2m7cmMZDk8Rzx7rBpu0ABQl6jV69RfWFZVO8Wexu1Dwv5Y84G76 BWSIJ0f/OnNHAxO0exCU0vuJkc7iBB8B7dTkFPkbYkCwm67aa5sKPnKAmDCcd0wWeJvD IYNvO5+hyzz/6wwVkT3Ge83NfSl+wtxLVW396Pww568gBzptyQg8AU1hSpLdEkm6zevr tl8POBald4O78NenxB1OS0P+yIaqTwg3nMpPHEKmSRUtXKWNRMt3u/ICzJdfF/LrCG6Z CAU4FVtqiyiw0HwMeMlUVTjA6TVDXDXzRJlK8oUmJUaV+d3uGraxhy4auR5drRwLvVsL VOqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DYiXCU7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k84-20020a628457000000b00527d7f8e7ebsi9971580pfd.274.2022.07.11.08.37.49; Mon, 11 Jul 2022 08:38:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=DYiXCU7q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229694AbiGKO4i (ORCPT + 99 others); Mon, 11 Jul 2022 10:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiGKO4f (ORCPT ); Mon, 11 Jul 2022 10:56:35 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC48571BC1 for ; Mon, 11 Jul 2022 07:56:33 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id o18so4927377pgu.9 for ; Mon, 11 Jul 2022 07:56:33 -0700 (PDT) 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=3+iOhYm5m5ryVsh6j+fvjnI4Rfo7Ca22Rrvor4EkRvU=; b=DYiXCU7qoygF17O0LWqvkzaFglZoWfbOLX+t0kfP0XggKmfv8oF1pGaE3oHz4wnSh/ UApcn654dX2cOuxxl0hBop8U+LVF2pQV8d5xhOL2aAroTRBowfXsWnm6QxHXxnqypyYF IPuu9rLUANAH08JMPQw5kXUwtastU3TEj3E00YOAFPCjeS1vqMIPJCy/tm4YRsPYvd5h Y7TMLpeFLy5/1YYGHUSQwQwULPsyMBElRe3ItwT4icPwMcy2dkhUUinT2n3leAyLHYV4 oj+pTxIoqgTr075BZshB250y0poddl9LkF9bSeAhUaNl+9xrEqyUl6yDlebY+GEWYrtD fpQw== 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=3+iOhYm5m5ryVsh6j+fvjnI4Rfo7Ca22Rrvor4EkRvU=; b=u2ELWacLheDydaEYCM4t1TtdFYwfufmi222SqYiplhYKgIxQ20Xw0/CkHCpu2zDZ7i dNKMnh9jOFqudra0uWbcr1vwarG8SwdmH+DY6tu6Wq2mjPQgJEsTmvNzrUIFXO+TGgTN r6+eSatlUe3Fhaz5IQzK/sXYKuVUrGZo7fJfxrMfjV3Qf8C79FP8V8B3Q94YlqvqsHrT qGvAz38EPeAdqpoQT857jw6ZpQAlYbi3FWGCcJqrlqlGl8B+NqaJPKsV+MOz7ebkfh2H PrOBQKReE8vI+MRDlo57aCy8S9nypxMPXqlBm1KOII7ORxDnFJeOdDPz2j61K8wKO6LN fR+w== X-Gm-Message-State: AJIora8Tx7LidtmlD3fyI6ZsTBx0DRI+b/j/Pu+TYv2u4uCuOAxFdoYh qErpJbiapgQ94rqz22W1EIsWsw== X-Received: by 2002:a05:6a00:134e:b0:52a:d5b4:19bb with SMTP id k14-20020a056a00134e00b0052ad5b419bbmr3587768pfu.45.1657551393173; Mon, 11 Jul 2022 07:56:33 -0700 (PDT) Received: from google.com (123.65.230.35.bc.googleusercontent.com. [35.230.65.123]) by smtp.gmail.com with ESMTPSA id k10-20020aa7998a000000b0052ab0a7375fsm4813900pfh.209.2022.07.11.07.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jul 2022 07:56:32 -0700 (PDT) Date: Mon, 11 Jul 2022 14:56:29 +0000 From: Sean Christopherson To: isaku.yamahata@intel.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini Subject: Re: [PATCH v7 043/102] KVM: x86/mmu: Focibly use TDP MMU for TDX Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org s/Focibly/Forcibly, but that's a moot point because KVM shouldn't override the the module param. KVM should instead _require_ the TDP MMU to be enabled. E.g. if userspace disables the TDP MMU to workaround a fatal bug, then forcing the TDP MMU may silently expose KVM to said bug. And overriding tdp_enabled is just mind-boggling broken, all of the SPTE masks will be wrong. On Mon, Jun 27, 2022, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > In this patch series, TDX supports only TDP MMU and doesn't support legacy > MMU. Forcibly use TDP MMU for TDX irrelevant of kernel parameter to > disable TDP MMU. Do not refer to the "patch series", instead phrase the statement with respect to what KVM support. Require the TDP MMU for TDX guests, the so called "shadow" MMU does not support mapping guest private memory, i.e. does not support Secure-EPT. > Signed-off-by: Isaku Yamahata > --- > arch/x86/kvm/mmu/tdp_mmu.c | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index 82f1bfac7ee6..7eb41b176d1e 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -18,8 +18,13 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm) > { > struct workqueue_struct *wq; > > - if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled)) > - return 0; > + /* > + * Because TDX supports only TDP MMU, forcibly use TDP MMU in the case > + * of TDX. > + */ > + if (kvm->arch.vm_type != KVM_X86_TDX_VM && > + (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled))) > + return false; Yeah, no. if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled)) return kvm->arch.vm_type == KVM_X86_TDX_VM ? -EINVAL : 0; > > wq = alloc_workqueue("kvm", WQ_UNBOUND|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 0); > if (!wq) > -- > 2.25.1 >