Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3553420rwb; Sun, 20 Nov 2022 16:53:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4LslxmAgnnAjNSQ/3jUETkNNmGkTYba8b0/s5341cvlSB6JQE7ERYfyQPBmqCxpxLqzePo X-Received: by 2002:a17:90a:88f:b0:215:d767:4863 with SMTP id v15-20020a17090a088f00b00215d7674863mr17849834pjc.233.1668992011103; Sun, 20 Nov 2022 16:53:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668992011; cv=none; d=google.com; s=arc-20160816; b=ZEXFahO2PRMtE/D4jvheOs0DQbJvQRQfKDgHJsB8wKJrV6loHSPBbSxHEXRlmrZLEu 1k+jR0B0U/tidIaOfh9H/MnNeuHTGTMsHwV1ZkCShlZYeTK+k2/Tv8eDf1QBux72yzZJ LkyYJuREo4fnRaXdRV7BWPwMVBU9L+yUZLkB7lOwUqHBjbhhfBp1WwkLpLVgQfy3QOTF WHYxqU4nNouqh0a2jdzRIdVvjVa049dZKA/IaRuw9kM+lLYGCdOIB+JNJI/KC9maKgRq 9+bJGCZN+n1g9Jey/LmY1Wtdp9pvqjyEiO+E9mlcXgLJO2CAksBoQbgXPy3AfyEsWzVX kmeQ== 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=S8HROhjstKfGAUz4QI9Bcnwwg4WUDsfi30P1C7QwVIY=; b=Ypk/OohZV9hnSSUF1KXkTHr0GGp79ztcbIbjJMQRJl++R0ZZxAz+z4MvkZYRDd35LJ 9XihRhkxsnZsxmtTaZzMKwOafarc1EJRY7/eSbeMryIlibvSdEdOn2MqdfgZkiTSkEec b8xTokJVvDmB11Ia0xmc778/oov7BAuUtEvvghSCqui86xx1TiaEvCxQLy04DXg2yxpK l0NU6cjDGdBebDHWClDc0yMGaoQ4BCmrkOvYoNKk51ooWwdb6Zg0K0B7vyi3cJNyM5h5 XcuWzmevcVcCHiuOvYp/y9zfmCdXgjFRDbOXhGsyi6iJgCNmg6gt9T8LA0bglyIxOkIN He6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fshP4RzA; 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 30-20020a63165e000000b004767bc4252csi9505720pgw.519.2022.11.20.16.53.19; Sun, 20 Nov 2022 16:53:31 -0800 (PST) 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=fshP4RzA; 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 S230009AbiKUA2Q (ORCPT + 91 others); Sun, 20 Nov 2022 19:28:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbiKUA1b (ORCPT ); Sun, 20 Nov 2022 19:27:31 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D37B0B63; Sun, 20 Nov 2022 16:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668990449; x=1700526449; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gOZ0T77u1owzOZnOoSrcaq1f36vBbh2UkFPGd0zudQU=; b=fshP4RzAcPivCZj9voHBLtObrFqIdBHHUw6YCKJkzpzrfb70Yrw2mXjE GRC4x/1V1l3HBSczukuhLob81yms3MdDjLnOBta40Jm9mIEmGC3WFsixG gaBWVH18haj7xzbaoLGuoroMNq3P1wfngG4XHZhgkmMhkM5YUhrkE6SUk 8Phd6FJ4CWaIuuQWBnkSdCXL+1CYhqGEG9l3Pab1Aq2pWvdS3LaeCLK/h OhVJSZyEiNhVKv/JMvwiuDQI1fSSMpgbvkfIm+7gdriBlxT7R0FuiXcf+ qd6nh8tF4LjhwxleTUe99zV16JyPrn8KNtqpdZh7h1ofJpwV7A9U4miJ9 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10537"; a="399732315" X-IronPort-AV: E=Sophos;i="5.96,180,1665471600"; d="scan'208";a="399732315" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2022 16:27:29 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10537"; a="729825319" X-IronPort-AV: E=Sophos;i="5.96,180,1665471600"; d="scan'208";a="729825319" Received: from tomnavar-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.209.176.15]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2022 16:27:25 -0800 From: Kai Huang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, seanjc@google.com, pbonzini@redhat.com, dave.hansen@intel.com, dan.j.williams@intel.com, rafael.j.wysocki@intel.com, kirill.shutemov@linux.intel.com, ying.huang@intel.com, reinette.chatre@intel.com, len.brown@intel.com, tony.luck@intel.com, peterz@infradead.org, ak@linux.intel.com, isaku.yamahata@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com, kai.huang@intel.com Subject: [PATCH v7 08/20] x86/virt/tdx: Do logical-cpu scope TDX module initialization Date: Mon, 21 Nov 2022 13:26:30 +1300 Message-Id: <083f32ce0721611b7fc9297641cc8f5f222b937e.1668988357.git.kai.huang@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 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 After the global module initialization, the next step is logical-cpu scope module initialization. Logical-cpu initialization requires calling TDH.SYS.LP.INIT on all BIOS-enabled CPUs. This SEAMCALL can run concurrently on all CPUs. Use the helper introduced for shutting down the module to do logical-cpu scope initialization. Signed-off-by: Kai Huang --- arch/x86/virt/vmx/tdx/tdx.c | 14 ++++++++++++++ arch/x86/virt/vmx/tdx/tdx.h | 1 + 2 files changed, 15 insertions(+) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index f292292313bd..2cf7090667aa 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -199,6 +199,15 @@ static void seamcall_on_each_cpu(struct seamcall_ctx *sc) on_each_cpu(seamcall_smp_call_function, sc, true); } +static int tdx_module_init_cpus(void) +{ + struct seamcall_ctx sc = { .fn = TDH_SYS_LP_INIT }; + + seamcall_on_each_cpu(&sc); + + return atomic_read(&sc.err); +} + /* * Detect and initialize the TDX module. * @@ -218,6 +227,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 -EINVAL until all steps of TDX module initialization * process are done. diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h index 0b415805c921..9ba11808bd45 100644 --- a/arch/x86/virt/vmx/tdx/tdx.h +++ b/arch/x86/virt/vmx/tdx/tdx.h @@ -16,6 +16,7 @@ * TDX module SEAMCALL leaf functions */ #define TDH_SYS_INIT 33 +#define TDH_SYS_LP_INIT 35 #define TDH_SYS_LP_SHUTDOWN 44 /* -- 2.38.1