Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1111594pxb; Wed, 6 Apr 2022 09:00:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQZWd7N43u4V53J2PVodysU1y6Lqhov65ktKK+9iOXtk49TY15ITWFmEtxTovqKnN4+GEL X-Received: by 2002:a05:6a00:15cb:b0:4fb:266f:b187 with SMTP id o11-20020a056a0015cb00b004fb266fb187mr9692179pfu.28.1649260841052; Wed, 06 Apr 2022 09:00:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649260841; cv=none; d=google.com; s=arc-20160816; b=pVIPz2huktss3yHDcrfEztqB4vZQO8tQadNHW64i0ycoKIaUCavFCtaTIRw+AQsXwN ht9ca9/7549hkK1WVG5kBjPTBmv/pZq6bI5bhVzhJxbRnAn7H3MbQasro/RJ8uEo2AU3 CjlMGWxCGsw0JHY6GH2BDh9pCr8mEOH/CJ4bwc49JCh6DRfdMRJQbb4FcFbs7D8EwZNB W23GFy/Y6NsnwWVoudizlvNKCaljDhBjbhE1feGPct2kdHg8mI1XIezuQeELbENTQeaF +rTOFjnPeWikTVfaXw3EZ1dwyMHd0zNN/faOZQxCM24Mn+rWbz48LTqQbJ5kBH9fT45D FGWA== 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=STTxlW2OF0ZAN+3oMxdZTZJqrrij7X8OvGO6z7Bj6/0=; b=ur4v2+A6PIvc836XEE9YPs6/+rlF95IpVApeEtHefBcec3Abs20p+dr+qdQNW3C4yU wVo9DaBaGcZZn3XXdxkoMvUbNaAR9Yd7X1O/V8ugU8AzE2T4G0xk+onHOh/BxdgtERVW AU4Pui9/z/W+EhmILDK3XI9ymC05x6AMYybZk3niuLenifUXiqBnQPgC9zBXE9V2itzO Ra4/+yQsCIw2B8s4sTWvNdgCFP0HX+TKrmT+nBYjvvmK/XfPsZK379Byz0IbiLDfHjlN pGnEA01aFH8inEzCLKuSziycLKpA9KCpJTclMAucaAz9lGcqWXyUycjIcQrq0a06hk5B LK5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VfzPQ2La; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id e25-20020a656899000000b0039953df8d61si6048774pgt.134.2022.04.06.09.00.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:00:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=VfzPQ2La; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 532D91B7600; Wed, 6 Apr 2022 07:25:15 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234925AbiDFO1H (ORCPT + 99 others); Wed, 6 Apr 2022 10:27:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234682AbiDFO05 (ORCPT ); Wed, 6 Apr 2022 10:26:57 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E04BD44E5BC; Tue, 5 Apr 2022 21:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649220617; x=1680756617; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JEHzGZUx8hYUK4MYh5P32wAhLE7c3yWf9l91nEbGSFw=; b=VfzPQ2LaG8In1grZPBDmwZMfcosuYwV7ocloc3lEh1gNYlgbOLRP91m9 jH6ArEYOfTQw6MRHSJT791QwaPW5Ebgy8IPE7/UgOLVmzTZSDhcozy/YV nhyOHo1EDr7MEf06olGtNSaIbvnSV3vsQ9C0z5rKWW/cKsifIzkz6QWys oNGt2QYMn/v8+bzHcPZ5tgVezUUW7AxmjT/TfjEECa+ZfBuZU5hZxUlCd qeD1wIeLe6EAeyx+hhEMvdpgABLI4AJtU8aTWf5v+lJyfGw4drpvm7yGW hoJFzdbzOSR39jUJI7x5Cin0ep+m4PSEs7OkJTbvs7HX6jIIqdeddqyHV Q==; X-IronPort-AV: E=McAfee;i="6200,9189,10308"; a="243089819" X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208";a="243089819" 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:16 -0700 X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208";a="524302280" 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:12 -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 08/21] x86/virt/tdx: Do logical-cpu scope TDX module initialization Date: Wed, 6 Apr 2022 16:49:20 +1200 Message-Id: <35081dba60ef61c313c2d7334815247248b8d1da.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 Logical-cpu scope initialization requires calling TDH.SYS.LP.INIT on all BIOS-enabled cpus, otherwise the TDH.SYS.CONFIG SEAMCALL will fail. TDH.SYS.LP.INIT can be called concurrently on all cpus. Following global initialization, do the logical-cpu scope initialization by calling TDH.SYS.LP.INIT on all online cpus. Whether all BIOS-enabled cpus are online is not checked here for simplicity. The caller of tdx_init() should guarantee all BIOS-enabled cpus are online. Signed-off-by: Kai Huang --- arch/x86/virt/vmx/tdx/tdx.c | 12 ++++++++++++ arch/x86/virt/vmx/tdx/tdx.h | 1 + 2 files changed, 13 insertions(+) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 5c2f3a30be2f..ef2718423f0f 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -461,6 +461,13 @@ static int __tdx_detect(void) return -ENODEV; } +static int tdx_module_init_cpus(void) +{ + struct seamcall_ctx sc = { .fn = TDH_SYS_LP_INIT }; + + return seamcall_on_each_cpu(&sc); +} + static int init_tdx_module(void) { int ret; @@ -470,6 +477,11 @@ static int init_tdx_module(void) if (ret) goto out; + /* Logical-cpu scope initialization */ + ret = tdx_module_init_cpus(); + if (ret) + goto out; + /* * Return -EFAULT until all steps of TDX module * initialization are done. diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h index f0983b1936d8..b8cfdd6e12f3 100644 --- a/arch/x86/virt/vmx/tdx/tdx.h +++ b/arch/x86/virt/vmx/tdx/tdx.h @@ -39,6 +39,7 @@ struct p_seamldr_info { * TDX module SEAMCALL leaf functions */ #define TDH_SYS_INIT 33 +#define TDH_SYS_LP_INIT 35 #define TDH_SYS_LP_SHUTDOWN 44 struct tdx_module_output; -- 2.35.1