From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web11.46058.1671525777169185136 for ; Tue, 20 Dec 2022 00:42:57 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=NTpj+bBo; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: min.m.xu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671525777; x=1703061777; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=9+KTlah9DrxCCGzonCGEiVQPTZ6r4fC9a18wsIq0Vgc=; b=NTpj+bBonDY8Y1ElK3ywK6l1EralKztcRgEo38L6a5X6Fak5Kgg65wET mEMJIu4s00tbypwd7Jbm06Uckzv9dCK7gNMX4L87GnXwfUkvEoW3QB1Xz sjosaHUO/7ok4jPqBABwBnsluH8QZhKAW2M2wnapXStK8gSIEHv3PDNCr uJKaH7H8ZhLPOyKESNiMLlFBC8rgN9D+uGuKd8BJ1qUH5ZfpJjzv1AUbl sB06SS3qAoTDLoO1es1FJqAE0knMFZugYRIfYjapatQPvvFhD7T5StnsG HpvJbP2MGTvDe4eKrIbQ/XIxG5/RviN4Hop7vc4Hpsa8cJnfg1HP5E1aa Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10566"; a="383908199" X-IronPort-AV: E=Sophos;i="5.96,258,1665471600"; d="scan'208";a="383908199" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2022 00:42:56 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10566"; a="628644641" X-IronPort-AV: E=Sophos;i="5.96,259,1665471600"; d="scan'208";a="628644641" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.255.29.12]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2022 00:42:53 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [PATCH V2 0/6] Enable Multi-core based lazy-accept for TDVF Date: Tue, 20 Dec 2022 16:42:34 +0800 Message-Id: <20221220084240.1922-1-min.m.xu@intel.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4172 TDVF once accepts memory only by BSP. To improve the boot performance this patch-set introduce the multi-core accpet memory. Multi-core means BSP and APs work together to accept memory. TDVF leverages mailbox to wake up APs. It is not enabled in MpInitLib (Which requires SIPI). So multi-core accept memory cannot leverages MpInitLib to coordinate BSP and APs to work together. So TDVF split the accept memory into 2 phases. - AcceptMemoryForAPsStack: BSP accepts a small piece of memory which is then used by APs to setup stack. We assign a 16KB stack for each AP. So a td-guest with 256 vCPU requires 255*16KB = 4080KB. - AcceptMemory: After above small piece of memory is accepted, BSP commands APs to accept memory by sending AcceptPages command in td-mailbox. Together with the command and accpet-function, the APsStack address is send as well. APs then set the stack and jump to accept-function to accept memory. Patch 1-3: TdxMailboxLib is refactored to help multi-core lazy accept. Patch 4-5: Refactor APs' logical to support accpet page. Patch 6: Implement multi-core accept in TDVF. Code: https://github.com/mxu9/edk2/tree/Multi-Core-Lazy-Accept.v2 v2 changes: - Fix an override error when vCPU number is larger than 64. Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Signed-off-by: Min Xu Min M Xu (6): OvmfPkg/TdxMailboxLib: Delete global variables OvmfPkg/TdxMailboxLib: Add NULL instance of TdxMailboxLib OvmfPkg: Add TdxMailboxLibNull in some platform dsc OvmfPkg/Sec: Move TDX APs related nasm code to IntelTdxAPs.nasm OvmfPkg: Enable APs to accept memory for TDVF OvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF OvmfPkg/AmdSev/AmdSevX64.dsc | 1 + OvmfPkg/CloudHv/CloudHvX64.dsc | 1 + OvmfPkg/Include/TdxCommondefs.inc | 4 +- OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm | 119 +++++ OvmfPkg/IntelTdx/Sec/X64/SecEntry.nasm | 58 +-- OvmfPkg/Library/PlatformInitLib/IntelTdx.c | 411 +++++++++++++++--- .../PlatformInitLib/PlatformInitLib.inf | 1 + OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c | 22 +- .../Library/TdxMailboxLib/TdxMailboxLib.inf | 7 +- .../TdxMailboxLib/TdxMailboxLibNull.inf | 34 ++ OvmfPkg/Microvm/MicrovmX64.dsc | 1 + OvmfPkg/OvmfPkgIa32.dsc | 1 + OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/Sec/X64/SecEntry.nasm | 58 +-- 14 files changed, 545 insertions(+), 175 deletions(-) create mode 100644 OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm create mode 100644 OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf -- 2.29.2.windows.2