From patchwork Mon Feb 13 11:59:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Kai" X-Patchwork-Id: 13138302 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 488DFC636D7 for ; Mon, 13 Feb 2023 12:00:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA6DE6B007D; Mon, 13 Feb 2023 07:00:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D30326B007E; Mon, 13 Feb 2023 07:00:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA9EA6B0080; Mon, 13 Feb 2023 07:00:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id AA6DB6B007D for ; Mon, 13 Feb 2023 07:00:47 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 78597C0B0E for ; Mon, 13 Feb 2023 12:00:47 +0000 (UTC) X-FDA: 80462126934.24.A32AADE Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf14.hostedemail.com (Postfix) with ESMTP id 41A08100004 for ; Mon, 13 Feb 2023 12:00:44 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JXgMi7ak; spf=pass (imf14.hostedemail.com: domain of kai.huang@intel.com designates 192.55.52.88 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=1676289645; 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=lmf70MF5krij5Y4lBqNrIJaapHYZyaFsGjseg0AJ/bQ=; b=phzYje6ScPtKKzDRFDbXYaiuVJSAuARaX8pFB0OOU/ZqU0X10+Tmww/uHAW5uMKuS6AucA Sa2B/c7QcSLzSvnIoUB7sBXoc92iai6NenMfmU6+DokfE7ZgEuWWL9JiTQNt9ItvHjqenm 4tfrob5ndUO4mA8NJaqZ2T4aoCYB74Y= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=JXgMi7ak; spf=pass (imf14.hostedemail.com: domain of kai.huang@intel.com designates 192.55.52.88 as permitted sender) smtp.mailfrom=kai.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676289645; a=rsa-sha256; cv=none; b=Mr58w/2R9IU35YRwV6Km0CqVkDMWqHWQWWmjR00CjXfLfdm6onmuSzG+Bc/MVTfLwEEoe4 qQOuS/SFNDtlO2W3StgpKqZmxlplug07Z0gp9yd2QCEDSCRR0dM3ThXvwkeu8HFyIJTcAK BxdCoz5HtEqZ655T9bTpcMaMGp3Pi4E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1676289645; x=1707825645; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mUsApv8gVb1LZP98vlXGPOGZoTIkXgs3y140taNjlGw=; b=JXgMi7akNTLFGHVNxSvHG+5obpxB4m7gBaXMS6hGoTym6Ql60lGiR+Do wyhP5jd0afbdaiXofP1uAqdVCiZqRVkOfZ2iOraoIsmieE6fmN9CfSeXl 5C6r0ig4azFkjSfrgNzd0G5nXBkRk42TzMBAoOhjGkjc5hWPpAbp1exQe XlVVHEKMSKGcfK5jvaUGty2QAEqlRAdzV46FMeMi7iqKFoBSF+D/37MBm JnKUa7159Hbq5lx6iuC3nh/dT8dDlQ8MOu7JVIDcboL3+qoo30QkEmUOG uzYl+aTmsk1kpuPaJYOjtgIuG2opU74pEjDdDc7un57lY6N13gSQgAIRQ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="358283222" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="358283222" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 04:00:44 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10619"; a="701243238" X-IronPort-AV: E=Sophos;i="5.97,293,1669104000"; d="scan'208";a="701243238" Received: from wonger-mobl.amr.corp.intel.com (HELO khuang2-desk.gar.corp.intel.com) ([10.209.188.34]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Feb 2023 04:00:39 -0800 From: Kai Huang To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: linux-mm@kvack.org, dave.hansen@intel.com, peterz@infradead.org, tglx@linutronix.de, seanjc@google.com, pbonzini@redhat.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, ak@linux.intel.com, isaku.yamahata@intel.com, chao.gao@intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, david@redhat.com, bagasdotme@gmail.com, sagis@google.com, imammedo@redhat.com, kai.huang@intel.com Subject: [PATCH v9 06/18] x86/virt/tdx: Do TDX module global initialization Date: Tue, 14 Feb 2023 00:59:13 +1300 Message-Id: X-Mailer: git-send-email 2.39.1 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Queue-Id: 41A08100004 X-Stat-Signature: nxcjar9fww41phpwe4nkrku5pzw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orxlGjFmrcMQjDXCSCpD7+Iimmzy0m0gkupjI++avaAK3aEWycXHbV7x57cG07excKIjOXID9DAmuGoeOjJ1BBwIF5jnNu8Mnv6uVXmmyW0gzqBylspqx67A1gAMpq2Po2mBQ= 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: Start to transit out the "multi-steps" of initializing the TDX module as listed in the skeleton infrastructure. Do the first step to do module global initialization, which is one SEAMCALL on any logical cpu. Signed-off-by: Kai Huang Reviewed-by: Isaku Yamahata --- v8 -> v9: - Added this patch back. --- arch/x86/virt/vmx/tdx/tdx.c | 11 ++++++++++- arch/x86/virt/vmx/tdx/tdx.h | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c index 5ae3d71b70b4..79cee28c51b5 100644 --- a/arch/x86/virt/vmx/tdx/tdx.c +++ b/arch/x86/virt/vmx/tdx/tdx.c @@ -172,10 +172,19 @@ static int __always_unused seamcall(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, static int init_tdx_module(void) { + int ret; + + /* + * TDX module global initialization. All '0's are just + * unused parameters. + */ + ret = seamcall(TDH_SYS_INIT, 0, 0, 0, 0, NULL, NULL); + if (ret) + return ret; + /* * TODO: * - * - TDX module global initialization. * - TDX module per-cpu initialization. * - Get TDX module information and TDX-capable memory regions. * - Build the list of TDX-usable memory regions. diff --git a/arch/x86/virt/vmx/tdx/tdx.h b/arch/x86/virt/vmx/tdx/tdx.h index 931a50f0f44c..55472e085bc8 100644 --- a/arch/x86/virt/vmx/tdx/tdx.h +++ b/arch/x86/virt/vmx/tdx/tdx.h @@ -4,6 +4,18 @@ #include +/* + * This file contains both macros and data structures defined by the TDX + * architecture and Linux defined software data structures and functions. + * The two should not be mixed together for better readability. The + * architectural definitions come first. + */ + + /* + * TDX module SEAMCALL leaf functions + */ +#define TDH_SYS_INIT 33 + /* Kernel defined TDX module status during module initialization. */ enum tdx_module_status_t { TDX_MODULE_UNKNOWN,