Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2591560pxp; Sun, 13 Mar 2022 23:49:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjNTEOeoRnjbUiqWgzqYwrQbyF1z6GRxlfOlvnTQswR6z1by9CHE4iQpLI0hSf/O7Xiqyl X-Received: by 2002:a63:1651:0:b0:342:b566:57c4 with SMTP id 17-20020a631651000000b00342b56657c4mr18832922pgw.258.1647240567647; Sun, 13 Mar 2022 23:49:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647240567; cv=none; d=google.com; s=arc-20160816; b=rZSZPSGp0UKqwcjgu+7U1CG1aeD9DQeio9wxbso6TARmxn4/2GteJ06EUyhd0i2lVz FjOND+ljB34s4PI4Z6GPhSy33OaPUcFCq+OwNoA2d060mkzg1berWMRc9VSKXIJLzaJJ ulRXQjFLKsTOXW/kZrlgALCR9Nye2WOlSbeg2TWxYSYLERiREQi29KSZDdljLhZRuO2u 9BO6NMJglLpU35Bgq3y8Le2RHgWKfHmz1Plzu+1UxtEO3OfI6KufuYneEDB5NHFx1lIy pXAL9g1OD8T6wN7Br/bH5i/PtEuvuTHal3mMBV3lw5b4lIlMJk22AepjZauDXNYqyAzn 2WgQ== 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=ph/BR3vtYAMb9/8UrfnsKg27LTbjOc8zJl3amLz8OeI=; b=YIgFYSpt2vONXx9tupS/Lp+sdcg8gDzpPkeVbFh/Q7oIhc/eG9zRxDdRhn9amtRJ/D 6V2DZDpeEG2I4caLPIkc/KFy8fk58KuXyqrCWBI1J04J2gnfoWdysEd2vaEjoqJspZnN Ld2ydt60up3Lg+ZDdZdmgBO+KOTOnZ5kTr0oB2os/IC2ruceZS5sFxVBDhp1/Tv95Jid nqw/KsfOwhgTqsIneB6VF4yU28YWgRPKjX7oM1LP5YriRtfOQytuEXoF9x9gpQrCDqW4 r5weYjXKlAjAtqBtVBgRIVKbKB8JsfmMBtdjsf9n8fKkyqrdXPbluoDuNTJIfPTH3ZBf 5fgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=aDewddJq; 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 b17-20020a63a111000000b003785aa398adsi14145411pgf.246.2022.03.13.23.49.16; Sun, 13 Mar 2022 23:49:27 -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=aDewddJq; 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 S233045AbiCMKwF (ORCPT + 99 others); Sun, 13 Mar 2022 06:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233248AbiCMKvn (ORCPT ); Sun, 13 Mar 2022 06:51:43 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58B2436324; Sun, 13 Mar 2022 03:50:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1647168633; x=1678704633; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1/CFhMw+zoD/9IrIuLin35o8R0ap4GLkb9GXsqkEG84=; b=aDewddJqVCRAQ1ssP5t3bkSEeBCDJrRwr1k9tZ0mkjJko4R7PD7Z61Iw NdwQ04Ia6vf+9ISjef6Zzyix9T2zp4h5uqROgB9b8pfYoIXSJWJIO9E4C dtbAdTWkU9hREp8OU73CdxbJEr0hUymTMG6K2GMcQwep3mIknrHnrGg0U efH5yCsVM6u7i5dElWe0MWX+RLC8Wgn3S0JgtpdSKp8HVd7Q56xu1RIj9 /cQMIp7mGrLoJafktzu5UPKLKP25mAymL5DQEBLW402eClZ2nOr6txDaq TODTTBciplt1MUrnQ2OHyaa42alCe+HaXxITPzXY9RMYfBkr2kPAb2qeL g==; X-IronPort-AV: E=McAfee;i="6200,9189,10284"; a="255810449" X-IronPort-AV: E=Sophos;i="5.90,178,1643702400"; d="scan'208";a="255810449" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2022 03:50:33 -0700 X-IronPort-AV: E=Sophos;i="5.90,178,1643702400"; d="scan'208";a="645448109" Received: from mvideche-mobl1.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.251.130.249]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Mar 2022 03:50:29 -0700 From: Kai Huang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: dave.hansen@intel.com, seanjc@google.com, pbonzini@redhat.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, peterz@infradead.org, tony.luck@intel.com, ak@linux.intel.com, dan.j.williams@intel.com, isaku.yamahata@intel.com, kai.huang@intel.com Subject: [PATCH v2 07/21] x86/virt/tdx: Do TDX module global initialization Date: Sun, 13 Mar 2022 23:49:47 +1300 Message-Id: <35c2921238bab117fea6ce6feb8604e83750ac39.1647167475.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=-5.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,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 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.c | 11 ++++++++++- arch/x86/virt/vmx/tdx.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/x86/virt/vmx/tdx.c b/arch/x86/virt/vmx/tdx.c index d87af534db51..45e7404b5d81 100644 --- a/arch/x86/virt/vmx/tdx.c +++ b/arch/x86/virt/vmx/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.h b/arch/x86/virt/vmx/tdx.h index dcc1f6dfe378..f0983b1936d8 100644 --- a/arch/x86/virt/vmx/tdx.h +++ b/arch/x86/virt/vmx/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