Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp180154pxb; Thu, 7 Apr 2022 02:39:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZZIFJS9QzUtEPY98YxNYXyySyq3WIWWcxU/HYe8HHRetsp2EYmvc+rp7kKvuqra2A0XFf X-Received: by 2002:a05:6402:1a54:b0:41c:cddb:3142 with SMTP id bf20-20020a0564021a5400b0041ccddb3142mr13278230edb.106.1649324387569; Thu, 07 Apr 2022 02:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649324387; cv=none; d=google.com; s=arc-20160816; b=QIZ5KCXg1blM+GrgpR8P2ofmbFYpQPf9gnd2Bf5vUUTX700q5XJdMgRa7/lpHgRWhJ j+Q6i5sgWDmh5cgMCakc1/FP0g/ohW+LPvC1iVWHXIQ2ssBIffvfi5NvKto7GGg0xUGF CzXlcHJ21aaN2rCZHSrEIl4yv6SIlPJR8Hln6iYfBYr/h7ui8Crjgn9qwj+RevOSC192 KBCHLF3UAc5HSWMm9o3tzJBCxOGq/Le8PEHQWj/HY9YeikICuCvOeCTmyqAIP5bwY3pu xx4JCoGJQqjhm0M7Y6wEWKAKekOKDivgcEgVEKKyqX8h36MHmX72UhELRPOVIsN7RSAe dBwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=SCdEzPX3i+3linXtw8zimxzeJmMQP68zu3ZgBxp330c=; b=ss+2EBiCwglAwkyeQgk9YT/W69l9mQozqIU2Z5a7OmsOGZ4QR2kErHdlNVSv4QjX/d 7lXFq7/evwTlKKmgsq+bo49wwYjw9VKngtrg+C3L9tN83wW7wm/jIav6eCwLFM39hPgO eTPKVWUfBcgDm91AamNMN1uSTjz0hGneY3Bk392Bj5qgdj/7kZxOMgq0G5RRf8lio76V 1Xs/AubULnp+nuaFY8deOSzZRK3kT7mos9mI1luWE6Vy73a6hr6seLB3WBPNPEB0ESID E9CCSkbTcgHvSUBMbnUKf/oO7O0Yy49UeoOPwyGYPJY49we/y3YXBlAjMK745Wd4yZOb w1Gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Jw0fWuIV; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a056402510a00b004190b6bd098si15920923edd.234.2022.04.07.02.39.22; Thu, 07 Apr 2022 02:39:47 -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=@intel.com header.s=Intel header.b=Jw0fWuIV; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbiDGBvv (ORCPT + 99 others); Wed, 6 Apr 2022 21:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229998AbiDGBvr (ORCPT ); Wed, 6 Apr 2022 21:51:47 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F6A0171EEA; Wed, 6 Apr 2022 18:49:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649296187; x=1680832187; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=WJrLoov+MjDP0lFzu4rpP8BuKdiCEexw6bxW6BUfq9E=; b=Jw0fWuIVJiOM5HqQVQIS0Qp5JBV95emLWYPV+LrNwSvuwTuvP1zOkLb8 55uUVa2bzy5kIlydkiQgpozIFaeyfxXTfoPgRTShSvvOyrT5JHtT65uzj jjq4yR5w+DIelrqOr9MIdGSntUMwEifSbGWIQQnWwYBCN8v1fw5aSNlZr XrWyB3L6959CqfF0fYANiDqPNi9k962MPfStnG71NJPb+Yy5rikp8KiZB 8K9RCRFo6f/dZDF58Kfbo9YMjGtkh86kZeZL3yoxTb9B9wdjFOQEknkxr 5IKQmlAWYv8ljc1uFCXAOhBPEFMrLXG5dqB+E+M35GoZqyxxTz3th/+JR Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="286180840" X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="286180840" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 18:49:45 -0700 X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="652619313" Received: from mgailhax-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.55.23]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 18:49:43 -0700 Message-ID: Subject: Re: [RFC PATCH v5 058/104] KVM: x86/mmu: Focibly use TDP MMU for TDX From: Kai Huang To: isaku.yamahata@intel.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@gmail.com, Paolo Bonzini , Jim Mattson , erdemaktas@google.com, Connor Kuehl , Sean Christopherson Date: Thu, 07 Apr 2022 13:49:41 +1200 In-Reply-To: <047e05425ffed2b5de321dba6679cb4d1c388f4e.1646422845.git.isaku.yamahata@intel.com> References: <047e05425ffed2b5de321dba6679cb4d1c388f4e.1646422845.git.isaku.yamahata@intel.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Fri, 2022-03-04 at 11:49 -0800, isaku.yamahata@intel.com wrote: > From: Isaku Yamahata > > At this point, TDX supports TDP MMU and doesn't support legacy MMU. > Forcibly use TDP MMU for TDX irrelevant of kernel parameter to disable > TDP MMU. > > Signed-off-by: Isaku Yamahata > --- > arch/x86/kvm/mmu/tdp_mmu.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c > index b33ace3d4456..9df6aa4da202 100644 > --- a/arch/x86/kvm/mmu/tdp_mmu.c > +++ b/arch/x86/kvm/mmu/tdp_mmu.c > @@ -16,7 +16,12 @@ module_param_named(tdp_mmu, tdp_mmu_enabled, bool, 0644); > /* Initializes the TDP MMU for the VM, if enabled. */ > bool kvm_mmu_init_tdp_mmu(struct kvm *kvm) > { > - if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled)) > + /* > + * 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; > > /* This should not be changed for the lifetime of the VM. */ Please move this patch forward before introducing any private/shared mapping support, otherwise nothing prevents you from creating a TD against legacy MMU, which is broken (especially you have allowed userspace to create TD in patch 10 "KVM: TDX: Make TDX VM type supported"). -- Thanks, -Kai