Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2609661rdg; Mon, 16 Oct 2023 09:17:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/cm107AWsxpCvx2ylbdtVjHJ38+3teZODuJtRFdurcEqoA8LX1DyFsdBmYOZA/X03Eyke X-Received: by 2002:a05:6a00:84b:b0:693:3cac:7897 with SMTP id q11-20020a056a00084b00b006933cac7897mr35339472pfk.9.1697473074703; Mon, 16 Oct 2023 09:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697473074; cv=none; d=google.com; s=arc-20160816; b=GgGzf7yBjnaNt0ciunW37hzKl7scn2H/j7a78rB3fSQ1ZxplEQEyuTtHaRen1ytuBf jZcqsJWJV66qzkWA3Q6HiDTM4O0gPNmTXtHak2o+qPBVz6qoT7MA4Aa4tI1gMsM+AYrE 0Tb+U5ZLPtsd6wadBsSxE9KVR2m3wQA2FzNetSJ4nmrgi65bywyw+wSvv0tiY3Gh6eZs H5q9Gq1ZMSjjvhb81pyyPpj/BPkty4t7C4MUufm8CLhoSMwMq0q2Tk9IZW13nqemUvWJ Gr9jmecTmDWow5LzjiHxR1lik4pELnbEitD+cXb4LVS/A5EeS8VY696QVAvfQWpZ821i b8pw== 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=L8Qod3t+Tr54HY817YP4LricR/DbqiayKryqebt1x/M=; fh=lRdU2Q/1zx5DcPdZuWBjshA5VT5Oc9cEhB1tCFiV0Nw=; b=Pw8Cuqf8ER7QDzrWZSt9MsJOzJhLjJYBGOkAuyxM4SftZyOsXMnUoNK7FtHfkxg7MC MpIRuTHi3JuObfAdxashCWpk3jd69PgRrv/fxqcd029eukvffhEMzCtIdJHrcU/QHOo+ Jh7SClEHcvqBwCQq4cu/4lRvWoqDuVn7RvngjEzSSz0zy/uIBSCVSQQLnAeT2byC50mb AmOYFd0K+f1jocuGaN9oA0+MF71nzpG9BcOF8UxtTfoKmwiEBCgUu1pdCFgdV7ahZSn8 Lft1kgPAIRJ7qWQKhknVGFWiyKSEOLmCIuC0+KpQldTdwmQs217JyTdGBYVMpeE3hEJj AT/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GRk8xEnO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id fd11-20020a056a002e8b00b0068fea8a6169si105489pfb.404.2023.10.16.09.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 09:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GRk8xEnO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B2AFE802D53E; Mon, 16 Oct 2023 09:17:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234077AbjJPQRq (ORCPT + 99 others); Mon, 16 Oct 2023 12:17:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234071AbjJPQRZ (ORCPT ); Mon, 16 Oct 2023 12:17:25 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17BC8D5A; Mon, 16 Oct 2023 09:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697473022; x=1729009022; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8T6zLvlaAzAFwyaBg/0GChxfVbg0Fq6wwYkBsoq3oNs=; b=GRk8xEnOD4ru75vCy2o4PoRnfi4pty9s76wxZRUhRPDIhfjKjhJib//N lc0rzgkeDZq91aH+Jh2Njy0dLVc2zS8269r/DHN9XW6QJeB16uR6ZhriH KBQ4HHEJQlLjoDXd7nZV/Fan4CM6coFdbp+aG4/tWINsyICYPWCtTSYcw bpUxxU3UGny+h0oDNuxMepwiIkssmG5B+f7lnUFg84Ruh6u4MhAX6iQ03 V73SDS1pFKz+h/FMdoNStbYkzTWQv2ciJmKJMApcg3yxemW15q2uTyqAG HDPHHsV2bqwrVbqC/SB2wmlA0VjpD/09STb6WGF1DMOR9LszKBZ0GJBEs w==; X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="364921814" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="364921814" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10865"; a="846448144" X-IronPort-AV: E=Sophos;i="6.03,229,1694761200"; d="scan'208";a="846448144" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Oct 2023 09:15:46 -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, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v16 054/116] KVM: TDX: Require TDP MMU and mmio caching for TDX Date: Mon, 16 Oct 2023 09:14:06 -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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 09:17:53 -0700 (PDT) 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 e1f42fdcd248..91250b2a7081 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -104,6 +104,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 17d119f3c4a8..fda13fd37cae 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