From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A70BC4332F for ; Mon, 21 Nov 2022 00:27:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20A9D6B0081; Sun, 20 Nov 2022 19:27:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E0916B0082; Sun, 20 Nov 2022 19:27:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CFB06B0083; Sun, 20 Nov 2022 19:27:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id F34396B0081 for ; Sun, 20 Nov 2022 19:27:30 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B615A1603D4 for ; Mon, 21 Nov 2022 00:27:30 +0000 (UTC) X-FDA: 80155560660.25.BE838BF Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by imf22.hostedemail.com (Postfix) with ESMTP id 31E81C000B for ; Mon, 21 Nov 2022 00:27:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668990450; x=1700526450; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gOZ0T77u1owzOZnOoSrcaq1f36vBbh2UkFPGd0zudQU=; b=FBZhep2J7Dv0XWOkhn71KVHivwQPtmyfaoOj2hOk9t8cephEnZUDtRFe PYqnwTn7femhLplCfscS+oHH5bx7AipXLwTFRcTgBViy1cVsQ8amcYDgv isdzSYtosMF+RmP0luCDt7Xi/fGbdEkEoJv43CP8IWeP91vNctwpniLyt xMYol72Wa0PMdDJ3YoKYvlvq9R8MFr5sg0+N/rh4Pog76y6m09IR6FO9H hyMV3TtZI14Aen0nyr97q0Qr3wxRj2R+cSsoZIFy4c+fy08u76K/F/DuW 3D/qCAigaePs5pDEXXs/id5/y++Y8y/7asIBZ0GAawP/k/1kpjYlVNVmX g==; X-IronPort-AV: E=McAfee;i="6500,9779,10537"; a="296803691" X-IronPort-AV: E=Sophos;i="5.96,180,1665471600"; d="scan'208";a="296803691" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga106.jf.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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668990450; a=rsa-sha256; cv=none; b=bsV3t5RAap55PrJ0AgJKh95K8VUgpCtp2NNumVeSJvum9srlCkU1eY9MQmEOLPseDnQinL Ic/Vm8MCodmELGLh98pz2l3OSj5dp+d/UA2EiU1W24SPzCI0GAzN/HrZLQKk6C9Wrx30t9 SoCvGsBV48XAuV99oGewN5rF64fu1yk= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=FBZhep2J; spf=pass (imf22.hostedemail.com: domain of kai.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=kai.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668990450; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=S8HROhjstKfGAUz4QI9Bcnwwg4WUDsfi30P1C7QwVIY=; b=NjOCCZBzvskcf8c0aJyioC+eYgFdkulldA9fACpide6zwnFhbxUBOJQPwAP6brtopvWvaU UKFmA+6B+8wi3LbkP2A+rpjtVKKH32FhUG0bKHN1gZ3AuecTcwwCmKYSv88OmfpeselVzT XueWtF3n20rGXg8gfTH72h9csP/hgnM= X-Rspam-User: X-Stat-Signature: 59q7jg8c4ssj3dxghkihwa6dc9r38ncm X-Rspamd-Queue-Id: 31E81C000B Authentication-Results: imf22.hostedemail.com; dkim=none ("invalid DKIM record") header.d=intel.com header.s=Intel header.b=FBZhep2J; spf=pass (imf22.hostedemail.com: domain of kai.huang@intel.com designates 134.134.136.126 as permitted sender) smtp.mailfrom=kai.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com X-Rspamd-Server: rspam07 X-HE-Tag: 1668990450-1962 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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