Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1105542pxb; Wed, 6 Apr 2022 08:51:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyL3xwtf+4/JhI+Kv6EoHLbMVs6bL5bhWKohdeHk0MHGlH8nffIsK4NTTT+1R9HeNL36aSf X-Received: by 2002:a17:90b:380b:b0:1ca:c6dd:d75b with SMTP id mq11-20020a17090b380b00b001cac6ddd75bmr10767200pjb.146.1649260317552; Wed, 06 Apr 2022 08:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260317; cv=none; d=google.com; s=arc-20160816; b=oHwSUbpxpaeF5MWNJNkJBKkO4hhFRS2FEvSaytpptm1oskrOY/TT8wqvlJ2vQODFVx x/0HS9KFro+3f9TLxw/Ndooeb4DT6rcSyn05SOeDUdUVQEiCQ28qIFN7Wu65NGFe2wWm wl6eM1zE8h2W/JkNIgUfUZjSyr/Fq6UQhtPkPq4EepkqNhT+OFxc0qYB6i7f6I/LipS9 UCJ0hkiXX13aBByc5viGF5wSKpcdkFt94uSCv8ptrNq0b2oncyJ8YARwGRpibzGJ8Kly jHrSbYbxvNv8hpwEYD7p2O9d2Ua6Blu/rYe7ra0bz9iG2F/ldqqh3HcIaPOEhGqIy0c7 sqPw== 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=Ulu52/IJK/HIvdbHNN2GaFWByITA1t/zeyd37e98BAo=; b=GkJOjLgfFEqsiDCi6EBBFp6j9Bv9nqAsQkoxt50HVmNuCjDJzq19X3iyT6kzmq/rz2 C47x7zj6Nuky7eDlNW7Y1PBXdU6I/igV30vEpsrcfl5W27z24jmHBbcjxSAi5NgChdG3 WwHkHhLGLJp9BCqbIq4XPT7v2atV9liF6VaB15QQAU+ZBdKtMBrnwqpbxw12HTsSpJBr E+OKjxKPkX0eQ2R0UQHDlXB5+eJxOB+tzN5+cRi4idzftdtjb6TUh+20QSEpLggbU2Ki +wGdXauZAImnzdFm66FouJyaI/5EP4AXJnDF6pTkQVo9Bc3yRpW9GbiCkw/aXg/1nkK4 Bawg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OVxoHrrB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e9-20020a170902ef4900b00156b08184bcsi8394664plx.219.2022.04.06.08.51.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:51:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=OVxoHrrB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 67F471E1F59; Wed, 6 Apr 2022 07:59:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235415AbiDFPBN (ORCPT + 99 others); Wed, 6 Apr 2022 11:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235468AbiDFPAi (ORCPT ); Wed, 6 Apr 2022 11:00:38 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 056B244E5B5; Tue, 5 Apr 2022 21:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649220614; x=1680756614; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O4RpktnBj9oVWn2CFbXTXcz/tlOO8+KU7JX2IGLZkdk=; b=OVxoHrrB/UA4r2ZyfLnBp3dh8Wf+03/GvILywONRdaQc46jp7zjq10qj vCBEUJ2t4whjN5vmVv/1Pho+M9T96IK9T3lEAQH1tliKR+VLKtqbAatqs A3okzqvoLLo8aom4LPi7uE9+F3bAzFiU4hHM9uj/B6EoUCGZEMMexJYC5 4qDZsqLJherYOWalNQbYw/NekdAZ57EXpSitc7Swo/1v1wZh5SSgRKSsL Oyzt70lpGPM78DiGITZPqbztXS916eoP0iVRh0Xna5gWdINmbOvjlBVsN lXDawFkfW+rP6u0akiBDNI7dJSZ0j0+3HY93pxaHILrFkz3+DYDCyM99n g==; X-IronPort-AV: E=McAfee;i="6200,9189,10308"; a="243089809" X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208";a="243089809" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 21:50:12 -0700 X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208";a="524302246" Received: from dchang1-mobl3.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.254.29.17]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 21:50:09 -0700 From: Kai Huang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, len.brown@intel.com, tony.luck@intel.com, rafael.j.wysocki@intel.com, reinette.chatre@intel.com, dan.j.williams@intel.com, peterz@infradead.org, ak@linux.intel.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, isaku.yamahata@intel.com, kai.huang@intel.com Subject: [PATCH v3 07/21] x86/virt/tdx: Do TDX module global initialization Date: Wed, 6 Apr 2022 16:49:19 +1200 Message-Id: <66e6aa1dc1bade544b81120d7976cb0601f0528b.1649219184.git.kai.huang@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Do the TDX module global initialization which requires calling TDH.SYS.INIT once on any logical cpu. Signed-off-by: Kai Huang --- arch/x86/virt/vmx/tdx/tdx.c | 11 ++++++++++- arch/x86/virt/vmx/tdx/tdx.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index faf8355965a5..5c2f3a30be2f 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -463,11 +463,20 @@ static int __tdx_detect(void) static int init_tdx_module(void) { + int ret; + + /* TDX module global initialization */ + ret = seamcall(TDH_SYS_INIT, 0, 0, 0, 0, NULL, NULL); + if (ret) + goto out; + /* * Return -EFAULT until all steps of TDX module * initialization are done. */ - return -EFAULT; + ret = -EFAULT; +out: + return ret; } static void shutdown_tdx_module(void) diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h index dcc1f6dfe378..f0983b1936d8 100644 --- a/arch/x86/virt/vmx/tdx/tdx.h +++ b/arch/x86/virt/vmx/tdx/tdx.h @@ -38,6 +38,7 @@ struct p_seamldr_info { /* * TDX module SEAMCALL leaf functions */ +#define TDH_SYS_INIT 33 #define TDH_SYS_LP_SHUTDOWN 44 struct tdx_module_output; -- 2.35.1