Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2690764rwd; Sun, 28 May 2023 22:18:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qAhUQWd57s1mf8c1jE6j3r7WxNfdGJvCDzgmNjENTngyhaZQUffwxtKphh2Cr6a2BDTN7 X-Received: by 2002:a05:6a20:8403:b0:111:346c:3465 with SMTP id c3-20020a056a20840300b00111346c3465mr2687032pzd.48.1685337505676; Sun, 28 May 2023 22:18:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685337505; cv=none; d=google.com; s=arc-20160816; b=kF2UmZNlZFPY9Dma1P23Dae800NCEdALons7bPHoSSaAORlnfnrYbeiHFrmLsVk8Ml GVONih/yKPPl8k/pOr/h+8svjEoRHQuHHPZPI+g1mxJXEx1UA7JXQmDSVR0PI5h/kOXG YXCgDHC4ZLfxOv5x0TLcssnI6V5ZlxxiKGNoi/MwA9PTUMphq8cm4b3ohoV7uSF+c4FT XP+bXsjm40onzXMQxaXCKjwWbiwzMpoBmAMO2yPBRQc7Higabt2K2aAF6B2xuP6yFQG7 8cUr+cS/T1wZZFsKL6+TTyL45YyVUOOY1L71givPeNg1z4hsszfsEYxRThUjydKO1tL2 IZDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=46ulGpCqshjB79mcsDp00UzMVPFQ/ukabhrGqGbd0k4=; b=rLuMa/pEpb1hMfMwPa7qqhP9rNP7TSj75+G4Zd87CPdkpXAyVirz+GbG+4VPuzQCBc fF2Zk0LXyOzdWoZHxSBb0y9ire+2B0Tc4otbeNekyaWnchYpn32Zza/vN6wO50PyIFmg JE2iQD8QfIKhx4dH+lWFeCRgSJSVD+XUZpZ4r+2qWT6SupHUlm4IzZ2a+TSaqy9toW2V AIW4USCGHNLq7Qn3k+NFJZX1qP0i8M/VuJBCtOySqI2f/AEkJH3aCNFmyULDFZHLk9pZ L8/nRUzIEdoQdzTkzqt/nS7ILBfM9bTSX/+e0Hjx3IcRk7aq9qiSy1FlzSS1+9V3AOl3 JQMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=giohjP32; 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 24-20020a631258000000b005307b843a98si8793970pgs.53.2023.05.28.22.18.13; Sun, 28 May 2023 22:18:25 -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=giohjP32; 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 S232006AbjE2E1I (ORCPT + 99 others); Mon, 29 May 2023 00:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231873AbjE2E00 (ORCPT ); Mon, 29 May 2023 00:26:26 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18802E69; Sun, 28 May 2023 21:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685334236; x=1716870236; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7MFGQrbvS9QLu2cZULAhVrJ66TUe/C+Gr3VI0l6Wlts=; b=giohjP32egn1fU3CaRPmJjP0FB1EmsP9F/bbdTSuYn/56OgJpLSRCrd3 F3y8wcx7yAm7OGgNCFdGCQDr23iFaLxXmTXED7zey1F8Ulg80sYjypzsF p4BHNe1njeaYb7VJ/k4Zqah4hoDh7R3NYdziGiO2IFmcRE3GsMnGv9/tG NgzqhXx8lU9/gijhxnS8p0V+1Nb0fZg32llb3cRviC5iPrdYgNL+HQbtb oZUwl9iAQglrGOYt0EUUlkJ5A7jFqW+piuVzOrK6GH3nSht7YbBw3Sh5k oxpYy5TDATYpV9cEo9EBVWTM/1sop1nAEdonKBKgmabNauPaVZBRmEQMx w==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="334966046" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="334966046" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:21:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="775784351" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="775784351" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 21:21:19 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sean Christopherson , Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com Subject: [PATCH v14 054/113] KVM: TDX: Require TDP MMU and mmio caching for TDX Date: Sun, 28 May 2023 21:19:36 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 From: Isaku Yamahata As TDP MMU is becoming main stream than the legacy MMU, the legacy MMU support for TDX isn't implemented. TDX requires KVM mmio caching. Disable TDX support when TDP MMU or mmio caching aren't supported. Signed-off-by: Isaku Yamahata --- arch/x86/kvm/mmu/mmu.c | 1 + arch/x86/kvm/vmx/main.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 3a3a39b31b1b..c61b77981403 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -100,6 +100,7 @@ module_param_named(flush_on_reuse, force_flush_and_sync_on_reuse, bool, 0644); * If the hardware supports that we don't need to do shadow paging. */ bool tdp_enabled = false; +EXPORT_SYMBOL_GPL(tdp_enabled); static bool __ro_after_init tdp_mmu_allowed; diff --git a/arch/x86/kvm/vmx/main.c b/arch/x86/kvm/vmx/main.c index f3dc052346db..3ed27065aa29 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -58,6 +58,17 @@ static __init int vt_hardware_setup(void) if (enable_ept) kvm_mmu_set_ept_masks(enable_ept_ad_bits, cpu_has_vmx_ept_execute_only()); + /* TDX requires KVM TDP MMU. */ + if (enable_tdx && !tdp_enabled) { + enable_tdx = false; + pr_warn_ratelimited("TDX requires TDP MMU. Please enable TDP MMU for TDX.\n"); + } + + /* TDX requires MMIO caching. */ + if (enable_tdx && !enable_mmio_caching) { + enable_tdx = false; + pr_warn_ratelimited("TDX requires mmio caching. Please enable mmio caching for TDX.\n"); + } enable_tdx = enable_tdx && !tdx_hardware_setup(&vt_x86_ops); -- 2.25.1