From patchwork Sun Oct 30 06:22:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 12860 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1666032wru; Sat, 29 Oct 2022 23:28:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Q9EB5q2jklezRrl8J1hADzW40yEQw7n3JMDc5lrfFWiWLrp2Z1k2hmx7hqEnHU2Gcd3v7 X-Received: by 2002:a05:6402:360d:b0:459:5f40:5b0a with SMTP id el13-20020a056402360d00b004595f405b0amr7265713edb.168.1667111318920; Sat, 29 Oct 2022 23:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667111318; cv=none; d=google.com; s=arc-20160816; b=Xfysj5Av7/cJsRO1vL/llI60/ewMU5I0YJ2ejcfwlXuTurRTOa8oj5JssG2jAbrq9H qtFtMDSGLJa7hD45l6Jwgm9z37R6FyNSIZmj5zvvK0Wn7zqp1eJ1aRQnkgnMan5XO2Hx NkWZGmtiXhZVJPVYazilFFYdruguxQ4Rx43bNLB4000432NJqsOyYKEF2Qgs0peB3CyC +Du+HM8mHxW8KcVSjVPbn69blZ/Rt5cLRuUwye65pyT5/8su7cJZs91A4kCiXTxDiwO2 R4cAXBhGSDblw9QcA8cMtmeonE6ig2Vr7Wia0hZ7ggrygoZAor3RtQQ3YB8lkhWj+8QW 1/ug== 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=8WCbndcoPcpcw4iQf5/2TwIvIv/jZiueYLToK+OicnI=; b=xsnjrk9+mr5gNmr9Eb0To/iWKpTkK4T9+4SbsI52U2PG6Ygnlas6zhnLbZXDpPeT+v 0Pck0qbcQoXUccGVnDqfcv2/jOnpf+WBv5UcMK2ovjEKXkEvu72ArICpS/HDF0V5cFPJ f2GMkcHoDosZPZh3d0d8cyd68OfPOXWpVg59OPfFJWda2EHGXozp7hY4cKxvayMHweCy h0vLO30OsOZijNcL+oAbIrYIQEOaXrNx/qlZHRodUC2qgA4+3kzVnPtUzUTjE52dbv2H KzOxJVcohe+dAWhFVkL0/UgLX5K5mMDHlfiDTwDCLJIgFaDrVwIhS3p/JcGXyCRuX027 wyuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Iw+GFymT; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tz10-20020a170907c78a00b0078d40f7ef1fsi3042837ejc.330.2022.10.29.23.28.14; Sat, 29 Oct 2022 23:28:38 -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=Iw+GFymT; 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 S230405AbiJ3G1I (ORCPT + 99 others); Sun, 30 Oct 2022 02:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229929AbiJ3GYL (ORCPT ); Sun, 30 Oct 2022 02:24:11 -0400 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46F0F13C; Sat, 29 Oct 2022 23:24:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667111050; x=1698647050; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XTbYY1fmIyEn8RqQg2g2IUB+pcesS3c7XzjHCDTS0FQ=; b=Iw+GFymTIGkx5EbISqnZrHFdmMhH9/fnUdut9U3Axbyqk4q5ud0sC9Sc XQXy00IpbrYaFEJ/EEZ4nvbdWezEKcZKmqqOcwxlbxwn3m9Hg8IuJzySI ynAS40vjzULeTaheKzwF9miog4GnbiLIu/A03UV4MT3Lcy9ijbnzkqjTF 5h7njKv3xJZan3Q/4QgRUw/o2j0/X11eFqFqMUpKCX4xtZHAJx0oYHmBq ELuxLFjQYATwEtw2TxHZnUEz3xw+SWjKOpBCbkkDJIAreog2442Wx5c+/ yc59erGK+4UrTdmSzxJl4fznTixhgT6O7ebZGNOyKcyvjWL2QyHicyaXN Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="395037155" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="395037155" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:04 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10515"; a="878392985" X-IronPort-AV: E=Sophos;i="5.95,225,1661842800"; d="scan'208";a="878392985" Received: from ls.sc.intel.com (HELO localhost) ([143.183.96.54]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2022 23:24:04 -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 Subject: [PATCH v10 043/108] KVM: x86/mmu: Require TDP MMU for TDX Date: Sat, 29 Oct 2022 23:22:44 -0700 Message-Id: <82c25eec5a4c42e4b6a2038c7553bbaf56e87091.1667110240.git.isaku.yamahata@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.9 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 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748092918225755562?= X-GMAIL-MSGID: =?utf-8?q?1748092918225755562?= From: Isaku Yamahata Require the TDP MMU for guest TDs, 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu/tdp_mmu.c b/arch/x86/kvm/mmu/tdp_mmu.c index c6be76f9849c..1bf58288ea79 100644 --- a/arch/x86/kvm/mmu/tdp_mmu.c +++ b/arch/x86/kvm/mmu/tdp_mmu.c @@ -18,8 +18,12 @@ int kvm_mmu_init_tdp_mmu(struct kvm *kvm) { struct workqueue_struct *wq; + /* + * Because only the TDP MMU supports TDX, require the TDP MMU for guest + * TDs. + */ if (!tdp_enabled || !READ_ONCE(tdp_mmu_enabled)) - return 0; + return kvm->arch.vm_type == KVM_X86_TDX_VM ? -EOPNOTSUPP : 0; wq = alloc_workqueue("kvm", WQ_UNBOUND|WQ_MEM_RECLAIM|WQ_CPU_INTENSIVE, 0); if (!wq)