From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web10.128317.1671093895214005705 for ; Thu, 15 Dec 2022 00:44:55 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=BW+t/sjQ; spf=pass (domain: intel.com, ip: 192.55.52.151, 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=1671093895; x=1702629895; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wplXkgVeB2yOD378ZfngKM8vFkejnHxctwpCX5XkuYM=; b=BW+t/sjQwG0Yp1gFlvOw4yCkczrDurY2wTd38DKT8wBywF13xOJir57P /f2FG5stH76rfOm/Y3T8zayDnuyHwvLRt5Qf5q+DYOcoTamUbfIWAoAW0 WiJqrtu866rMumNbajvVmzRx9o9KmUzl+gkwSztsPfkiM6y3ihmA+udsP ek521i7GMnmzyAfN/TeXOGxLsyURxYXljQtjrYbE+08h4X/piUKM4bmd+ WEBUDLiYbCk6CpaUMjUH7mP+k3znLYBf8LjJ42o9v3hPmsdLdyi3AWWzg h15bU7ppDF10jEUZd/aAMr2DH/dWHExeoiIthzj+2skUYRu0/I02pedho g==; X-IronPort-AV: E=McAfee;i="6500,9779,10561"; a="298967854" X-IronPort-AV: E=Sophos;i="5.96,246,1665471600"; d="scan'208";a="298967854" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2022 00:44:54 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10561"; a="651464789" X-IronPort-AV: E=Sophos;i="5.96,246,1665471600"; d="scan'208";a="651464789" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.170.19]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2022 00:44:52 -0800 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Erdem Aktas , Gerd Hoffmann , James Bottomley , Jiewen Yao , Tom Lendacky Subject: [PATCH V1 0/6] Enable Multi-core based lazy-accept for TDVF Date: Thu, 15 Dec 2022 16:44:34 +0800 Message-Id: <20221215084440.481-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.v1 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