Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp177714rdb; Mon, 22 Jan 2024 16:33:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxatX4AMa8kYIpR+Bsp+PF8pADN+u47sihOkH8QgcrXhpv9qGvG9ZbBY9poAW/xvENAi9Y X-Received: by 2002:a17:902:e88f:b0:1d7:4c16:9004 with SMTP id w15-20020a170902e88f00b001d74c169004mr2937173plg.108.1705969988600; Mon, 22 Jan 2024 16:33:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705969988; cv=pass; d=google.com; s=arc-20160816; b=0N8v7qiZzjdsPZ7PFoaWKJRkYwD0hqQFCfD2beyAmCpgA50FlEnvw00G7ernaZKD2u haH7q566hh+NXCH85OI8QT6PLPIdsgHeC8bbEChAWYNhvFEX/D14cQe7yqfibyL+yGXU AO5BtVn2LPlMRREf7K16skNJYmJUnGzVkdteV/bF9EvnRUNfg1NMJ+RBs6RoDdAXQxBf qnK+lIy5f/thqlTUoQ87Byqhx8MoflLoUrYPC5pOUO4CXZtas9Ra9RhT7AkPh38rNRN+ BjLXYXa7cjHXJcr8tNzC+iY/bQCwumFPp06Q8wnxPIYsTeND6w2aorbx8idQL1HURqN5 o6tg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zo6+LuhpaY5ayIx/sB1AMVuuVLHYAX7+kviDKmRQ824=; fh=Itbyk7CEvizIrzGEESCqq3I2tZgG1kc/GkVOa3S7Hsg=; b=nrU5woM6Nn/r3jyVUdaMmWIz4p4qCiJNK6YKzcSRJTkPtiO1l2cYjI1mt3+m5XVhB2 5RY55NGAnVqAYqCYTO2cIHGQBesbu+vh4+/3N2FIZuwD7ZiUHG9ShgtsJUcgF7BXxWLm 1d+MiUsD3MJQKMVgBTTVSJ/7muXjZYYMR5blmgtOKN/llWjQ/FP2IYJu+0oKFHM2+G48 Om90TtD+vj2zkfGgOssrW0dxL0MElrOyw6cJftHAZW5mrUiuXyb7ubr1Y3aOs/wrO23q OCw7mqycpRx0Ud7UV/Ej+3rQKXtZ30vF8+mj7NbxqPe0Y1OI6PnFZhj8DA5y1r/XoMFa WQLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ai5cavth; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id m5-20020a170902db0500b001d3ef57d914si2229690plx.95.2024.01.22.16.33.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 16:33:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ai5cavth; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-34380-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34380-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E15DC28FCBE for ; Tue, 23 Jan 2024 00:07:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CBB2465BDF; Mon, 22 Jan 2024 23:55:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ai5cavth" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8F4364CDE; Mon, 22 Jan 2024 23:55:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967752; cv=none; b=QjJw5PFtj65c7xwLrb5Af+FaXCIZjz9M1VapA49XK2MZ6CVW72jCdMUhRW8HqdqyNPTadu9bfb1cjwH9F2F3rOL/mH3SGV11b/gPE2loBjvrCQ02w7UXTrD4yX3q7cxA3nsKtCZu5bWMqJSSOxNCoswZct7fAsAorkwhfrgSRT4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705967752; c=relaxed/simple; bh=l5OSF5BW6i68hDmdAYtfztFn1BeBC/ZkQJ3rYLau+Ig=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ajD72uId1ekwlVyi0o20NmtgBJ/PzkSstSBNb8OByVzbkul0+sSymC4hNFTCSkyBWoMgmGbo+/QrViA4vaUMSw4vcJ+xAAn59H4y8iPNP5iEQERCXdI8UjTkDM8LoQbEC1f5prffH26sQSaG975rF3nfGU6frq91Df4ioRlELWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ai5cavth; arc=none smtp.client-ip=198.175.65.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1705967751; x=1737503751; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l5OSF5BW6i68hDmdAYtfztFn1BeBC/ZkQJ3rYLau+Ig=; b=ai5cavthuvdImaDsfK5AHY0ve/GltiqRUjnj5TarMXacIUJRaJFTlLWi cmqFdfJm29Zi7VdEyOeNAJ53RBqR39cU3zJn/0w2xxyINdZMYvbujYUVk 5BLwYjH4XeQdQ6xd+TJ5dYx/H/Llvu+LyBYS1Wffj9v59qagoUwoHlWe4 jDg6DprlweyXKU+GGHhmRsftrGb9AVAHemxlXH2kWzhJkZVw1HJz0NAE1 RNMQVxciWvD4x6502JJBSwAvNWcgWYiGUwSHQXgLEa+zLHjJF4dxo2oEl bbEy8U+wxQfiGX4ny2cHZe3svaaCrPSRvq7TF5b1y04XM+ZgQ1PXXyoDa g==; X-IronPort-AV: E=McAfee;i="6600,9927,10961"; a="8016447" X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="8016447" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,212,1701158400"; d="scan'208";a="1468189" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2024 15:55:35 -0800 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 , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com Subject: [PATCH v18 059/121] KVM: TDX: Require TDP MMU and mmio caching for TDX Date: Mon, 22 Jan 2024 15:53:35 -0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 f338b85d6d5b..7db152f46d82 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 f55ac09edc60..e77c045dca84 100644 --- a/arch/x86/kvm/vmx/main.c +++ b/arch/x86/kvm/vmx/main.c @@ -62,6 +62,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